Skip to content

Commit 4f548b1

Browse files
committed
MQE-2242: Add static check to flag use of <pause>
1 parent 85d4fa6 commit 4f548b1

File tree

16 files changed

+547
-51
lines changed

16 files changed

+547
-51
lines changed

dev/tests/_bootstrap.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,9 +9,11 @@
99

1010
$vendorAutoloadPath = realpath(PROJECT_ROOT . '/vendor/autoload.php');
1111
$mftfTestCasePath = realpath(PROJECT_ROOT . '/dev/tests/util/MftfTestCase.php');
12+
$mftfStaticTestCasePath = realpath(PROJECT_ROOT . '/dev/tests/util/MftfStaticTestCase.php');
1213

1314
require_once $vendorAutoloadPath;
1415
require_once $mftfTestCasePath;
16+
require_once $mftfStaticTestCasePath;
1517

1618
// Set up AspectMock
1719
$kernel = \AspectMock\Kernel::getInstance();

dev/tests/util/MftfStaticTestCase.php

Lines changed: 57 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,57 @@
1+
<?php
2+
/**
3+
* Copyright © Magento, Inc. All rights reserved.
4+
* See COPYING.txt for license details.
5+
*/
6+
7+
namespace tests\util;
8+
9+
use Magento\FunctionalTestingFramework\Util\Filesystem\DirSetupUtil;
10+
use PHPUnit\Framework\TestCase;
11+
use Symfony\Component\Console\Input\InputInterface;
12+
13+
class MftfStaticTestCase extends TestCase
14+
{
15+
const STATIC_RESULTS_DIR = TESTS_MODULE_PATH .
16+
DIRECTORY_SEPARATOR .
17+
'_output' .
18+
DIRECTORY_SEPARATOR .
19+
'static-results';
20+
21+
const RESOURCES_PATH = TESTS_MODULE_PATH .
22+
DIRECTORY_SEPARATOR .
23+
"Resources" .
24+
DIRECTORY_SEPARATOR .
25+
'StaticChecks';
26+
27+
public static function setUpBeforeClass(): void
28+
{
29+
// remove static-results if it exists
30+
if (file_exists(self::STATIC_RESULTS_DIR)) {
31+
DirSetupUtil::rmdirRecursive(self::STATIC_RESULTS_DIR);
32+
}
33+
}
34+
35+
/**
36+
* Sets input interface
37+
* @param $path
38+
* @return \PHPUnit\Framework\MockObject\MockObject
39+
*/
40+
public function mockInputInterface($path = null)
41+
{
42+
$input = $this->getMockBuilder(InputInterface::class)
43+
->disableOriginalConstructor()
44+
->getMock();
45+
if ($path) {
46+
$input->method('getOption')
47+
->with('path')
48+
->willReturn($path);
49+
}
50+
return $input;
51+
}
52+
53+
public function tearDown(): void
54+
{
55+
DirSetupUtil::rmdirRecursive(self::STATIC_RESULTS_DIR);
56+
}
57+
}
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
<?xml version="1.0" encoding="UTF-8" ?>
2+
<!--
3+
/**
4+
* Copyright © Magento, Inc. All rights reserved.
5+
* See COPYING.txt for license details.
6+
*/
7+
-->
8+
<actionGroups xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
9+
xsi:noNamespaceSchemaLocation="urn:magento:mftf:Test/etc/actionGroupSchema.xsd">
10+
<actionGroup name="MultiplePausesActionGroup">
11+
<fillField selector="#foo" userInput="foo" stepKey="fillField1"/>
12+
<pause stepKey="pauseAfterFillField1"/>
13+
<fillField selector="#bar" userInput="bar" stepKey="fillField2"/>
14+
<pause stepKey="pauseAfterFillField2"/>
15+
<fillField selector="#baz" userInput="baz" stepKey="fillField3"/>
16+
<pause stepKey="pauseAfterFillField3"/>
17+
</actionGroup>
18+
</actionGroups>
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
<?xml version="1.0" encoding="UTF-8" ?>
2+
<!--
3+
/**
4+
* Copyright © Magento, Inc. All rights reserved.
5+
* See COPYING.txt for license details.
6+
*/
7+
-->
8+
<actionGroups xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
9+
xsi:noNamespaceSchemaLocation="urn:magento:mftf:Test/etc/actionGroupSchema.xsd">
10+
<actionGroup name="NoPauseActionGroup">
11+
<fillField selector="#foo" userInput="foo" stepKey="fillField1"/>
12+
<fillField selector="#bar" userInput="bar" stepKey="fillField2"/>
13+
<fillField selector="#baz" userInput="baz" stepKey="fillField3"/>
14+
</actionGroup>
15+
</actionGroups>
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
<?xml version="1.0" encoding="UTF-8" ?>
2+
<!--
3+
/**
4+
* Copyright © Magento, Inc. All rights reserved.
5+
* See COPYING.txt for license details.
6+
*/
7+
-->
8+
<actionGroups xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
9+
xsi:noNamespaceSchemaLocation="urn:magento:mftf:Test/etc/actionGroupSchema.xsd">
10+
<actionGroup name="PauseActionGroup">
11+
<fillField selector="#foo" userInput="myData1" stepKey="fillField1"/>
12+
<fillField selector="#bar" userInput="myData2" stepKey="fillField2"/>
13+
<pause stepKey="pauseAfterFillField2"/>
14+
</actionGroup>
15+
</actionGroups>
Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<!--
3+
/**
4+
* Copyright © Magento, Inc. All rights reserved.
5+
* See COPYING.txt for license details.
6+
*/
7+
-->
8+
9+
<suites xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:mftf:Suite/etc/suiteSchema.xsd">
10+
<suite name="multiplePauseActionsSuite">
11+
<include>
12+
<group name="include" />
13+
<pause stepKey="pauseInclude"/>
14+
</include>
15+
<before>
16+
<amOnPage url="some.url" stepKey="before"/>
17+
<createData entity="SecretData" stepKey="create1">
18+
<field key="someKey">dataHere</field>
19+
</createData>
20+
<pause stepKey="pauseCreate1"/>
21+
</before>
22+
<after>
23+
<deleteData createDataKey="create1" stepKey="delete1"/>
24+
<deleteData url="deleteThis" stepKey="deleteThis"/>
25+
<fillField selector="#fill" userInput="{{SecretData.key2}}" stepKey="fillAfter"/>
26+
<pause stepKey="pauseFillAfter"/>
27+
</after>
28+
</suite>
29+
</suites>
Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<!--
3+
/**
4+
* Copyright © Magento, Inc. All rights reserved.
5+
* See COPYING.txt for license details.
6+
*/
7+
-->
8+
9+
<suites xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:mftf:Suite/etc/suiteSchema.xsd">
10+
<suite name="pauseActionSuite">
11+
<include>
12+
<group name="include" />
13+
</include>
14+
<before>
15+
<amOnPage url="some.url" stepKey="before"/>
16+
<createData entity="createThis" stepKey="create">
17+
<field key="someKey">dataHere</field>
18+
</createData>
19+
<pause stepKey="pauseSuite"/>
20+
<click stepKey="clickWithData" userInput="$create.data$"/>
21+
<fillField selector="#foo" userInput="myData1" stepKey="fillField1"/>
22+
</before>
23+
<after>
24+
<comment userInput="afterBlock" stepKey="afterBlock"/>
25+
</after>
26+
</suite>
27+
</suites>
Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<!--
3+
/**
4+
* Copyright © Magento, Inc. All rights reserved.
5+
* See COPYING.txt for license details.
6+
*/
7+
-->
8+
9+
<tests xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
10+
xsi:noNamespaceSchemaLocation="urn:magento:mftf:Test/etc/testSchema.xsd">
11+
<test name="MultiplePauseActionsTest">
12+
<annotations>
13+
<severity value="CRITICAL"/>
14+
<group value="functional"/>
15+
<features value="Pause check"/>
16+
<stories value="MQE-433"/>
17+
</annotations>
18+
<amOnPage stepKey="step1" url="/step1"/>
19+
<fillField stepKey="step2" selector="#username" userInput="step2"/>
20+
<pause stepKey="pauseAfterStep2"/>
21+
<fillField stepKey="step3" selector="#password" userInput="step3"/>
22+
<pause stepKey="pauseAfterStep3"/>
23+
</test>
24+
</tests>
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<!--
3+
/**
4+
* Copyright © Magento, Inc. All rights reserved.
5+
* See COPYING.txt for license details.
6+
*/
7+
-->
8+
9+
<tests xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
10+
xsi:noNamespaceSchemaLocation="urn:magento:mftf:Test/etc/testSchema.xsd">
11+
<test name="PauseActionTest">
12+
<annotations>
13+
<severity value="CRITICAL"/>
14+
<group value="functional"/>
15+
<features value="Pause check"/>
16+
<stories value="MQE-433"/>
17+
</annotations>
18+
<amOnPage stepKey="step1" url="/step1"/>
19+
<fillField stepKey="step2" selector="#username" userInput="step2"/>
20+
<fillField stepKey="step3" selector="#password" userInput="step3"/>
21+
<pause stepKey="pauseAfterStep3"/>
22+
</test>
23+
</tests>
Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
2+
File "/verification/PauseCheckModule/ActionGroup/PauseActionGroup.xml"
3+
contains pause action(s):
4+
5+
PauseActionGroup has pause action at stepKey(s): pauseAfterFillField2
6+
7+
File "/verification/PauseCheckModule/ActionGroup/MultiplePausesActionGroup.xml"
8+
contains pause action(s):
9+
10+
MultiplePausesActionGroup has pause action at stepKey(s): pauseAfterFillField1, pauseAfterFillField2, pauseAfterFillField3
11+
12+
File "/verification/PauseCheckModule/Test/PauseActionTest.xml"
13+
contains pause action(s):
14+
15+
PauseActionTest has pause action at stepKey(s): pauseAfterStep3
16+
17+
File "/verification/PauseCheckModule/Test/MultiplePauseActionsTest.xml"
18+
contains pause action(s):
19+
20+
MultiplePauseActionsTest has pause action at stepKey(s): pauseAfterStep2, pauseAfterStep3
21+
22+
File "/verification/PauseCheckModule/Suite/multiplePauseActionsSuite.xml"
23+
contains pause action(s):
24+
25+
multiplePauseActionsSuite has pause action at stepKey(s): pauseInclude, pauseCreate1, pauseFillAfter
26+
27+
File "/verification/PauseCheckModule/Suite/pauseActionSuite.xml"
28+
contains pause action(s):
29+
30+
pauseActionSuite has pause action at stepKey(s): pauseSuite

0 commit comments

Comments
 (0)