Skip to content

Commit b95d5d7

Browse files
authored
Merge branch 'develop' into MQE-1015
2 parents 195f540 + 5dc4c0d commit b95d5d7

38 files changed

+401
-110
lines changed

.gitignore

+3-1
Original file line numberDiff line numberDiff line change
@@ -13,4 +13,6 @@ coverage/
1313
.vscode
1414
codeception.yml
1515
dev/tests/functional/MFTF.suite.yml
16-
dev/tests/functional/_output
16+
dev/tests/functional/_output
17+
dev/mftf.log
18+
dev/tests/mftf.log

bin/all-checks.bat

+8
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
:: Copyright © Magento, Inc. All rights reserved.
2+
:: See COPYING.txt for license details.
3+
4+
@echo off
5+
call bin\static-checks.bat
6+
7+
@echo off
8+
call bin\phpunit-checks.bat

bin/copyright-check.bat

+41
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
:: Copyright © Magento, Inc. All rights reserved.
2+
:: See COPYING.txt for license details.
3+
4+
@echo off
5+
SETLOCAL EnableDelayedExpansion
6+
SET BLACKLIST_FILE=bin/blacklist.txt
7+
SET i=0
8+
9+
FOR /F %%x IN ('git ls-tree --full-tree -r --name-only HEAD') DO (
10+
SET GOOD_EXT=
11+
if "%%~xx"==".php" set GOOD_EXT=1
12+
if "%%~xx"==".xml" set GOOD_EXT=1
13+
if "%%~xx"==".xsd" set GOOD_EXT=1
14+
IF DEFINED GOOD_EXT (
15+
SET BLACKLISTED=
16+
FOR /F "tokens=* skip=5" %%f IN (%BLACKLIST_FILE%) DO (
17+
SET LINE=%%x
18+
IF NOT "!LINE!"=="!LINE:%%f=!" (
19+
SET BLACKLISTED=1
20+
)
21+
)
22+
IF NOT DEFINED BLACKLISTED (
23+
FIND "Copyright © Magento, Inc. All rights reserved." %%x >nul
24+
IF ERRORLEVEL 1 (
25+
SET /A i+=1
26+
SET NO_COPYRIGHT_LIST[!i!]=%%x
27+
)
28+
)
29+
)
30+
)
31+
32+
IF DEFINED NO_COPYRIGHT_LIST[1] (
33+
ECHO THE FOLLOWING FILES ARE MISSING THE MAGENTO COPYRIGHT:
34+
ECHO.
35+
ECHO Copyright © Magento, Inc. All rights reserved.
36+
ECHO See COPYING.txt for license details.
37+
ECHO.
38+
FOR /L %%a IN (1,1,%i%) DO (
39+
ECHO !NO_COPYRIGHT_LIST[%%a]!
40+
)
41+
)

bin/static-checks.bat

+6-8
Original file line numberDiff line numberDiff line change
@@ -5,17 +5,15 @@
55

66
@echo off
77
@echo ===============================PHP CODE SNIFFER REPORT===============================
8-
call vendor\bin\phpcs .\src --standard=.\dev\tests\static\Magento --ignore=src\Magento\FunctionalTestingFramework\Group,src\Magento\FunctionalTestingFramework\AcceptanceTester.php
9-
call vendor\bin\phpcs .\dev\tests\unit --standard=.\dev\tests\static\Magento
10-
call vendor\bin\phpcs .\dev\tests\verification --standard=.\dev\tests\static\Magento --ignore=dev\tests\verification\_generated
8+
call vendor\bin\phpcs --standard=.\dev\tests\static\Magento --ignore=src/Magento/FunctionalTestingFramework/Group,src/Magento/FunctionalTestingFramework/AcceptanceTester.php .\src
9+
call vendor\bin\phpcs --standard=.\dev\tests\static\Magento .\dev\tests\unit
10+
call vendor\bin\phpcs --standard=.\dev\tests\static\Magento --ignore=dev/tests/verification/_generated .\dev\tests\verification
1111

1212
@echo ===============================COPY PASTE DETECTOR REPORT===============================
1313
call vendor\bin\phpcpd .\src
1414

15-
@echo "===============================PHP MESS DETECTOR REPORT===============================
16-
vendor\bin\phpmd .\src text \dev\tests\static\Magento\CodeMessDetector\ruleset.xml --exclude _generated,src\Magento\FunctionalTestingFramework\Group,src\Magento\FunctionalTestingFramework\AcceptanceTester.php
15+
@echo ===============================PHP MESS DETECTOR REPORT===============================
16+
call vendor\bin\phpmd --exclude _generated,src\Magento\FunctionalTestingFramework\Group,src\Magento\FunctionalTestingFramework\AcceptanceTester.php .\src text \dev\tests\static\Magento\CodeMessDetector\ruleset.xml
1717

1818
@echo ===============================MAGENTO COPYRIGHT REPORT===============================
19-
echo msgbox "INFO:Copyright check currently not run as part of .bat implementation" > "%temp%\popup.vbs"
20-
wscript.exe "%temp%\popup.vbs"
21-
::bin\copyright-check
19+
call bin\copyright-check.bat
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,108 @@
1+
<?php
2+
/**
3+
* Copyright © Magento, Inc. All rights reserved.
4+
* See COPYING.txt for license details.
5+
*/
6+
namespace Tests\unit\Magento\FunctionalTestFramework\Test\Config\Reader;
7+
8+
use Magento\FunctionalTestingFramework\Config\FileResolver\Module;
9+
use Magento\FunctionalTestingFramework\Config\Reader\Filesystem;
10+
use Magento\FunctionalTestingFramework\Config\ValidationState;
11+
use Magento\FunctionalTestingFramework\Util\Iterator\File;
12+
use PHPUnit\Framework\TestCase;
13+
use AspectMock\Test as AspectMock;
14+
use tests\unit\Util\TestLoggingUtil;
15+
16+
class FilesystemTest extends TestCase
17+
{
18+
/**
19+
* Before test functionality
20+
* @return void
21+
*/
22+
public function setUp()
23+
{
24+
TestLoggingUtil::getInstance()->setMockLoggingUtil();
25+
}
26+
27+
/**
28+
* Test Reading Empty Files
29+
* @throws \Exception
30+
*/
31+
public function testEmptyXmlFile()
32+
{
33+
// create mocked items and read the file
34+
$someFile = $this->setMockFile("somepath.xml", "");
35+
$filesystem = $this->createPseudoFileSystem($someFile);
36+
$filesystem->read();
37+
38+
// validate log statement
39+
TestLoggingUtil::getInstance()->validateMockLogStatement(
40+
"warning",
41+
"XML File is empty.",
42+
["File" => "somepath.xml"]
43+
);
44+
}
45+
46+
/**
47+
* Function used to set mock for File created in test
48+
*
49+
* @param string $fileName
50+
* @param string $content
51+
* @return object
52+
* @throws \Exception
53+
*/
54+
public function setMockFile($fileName, $content)
55+
{
56+
$file = AspectMock::double(
57+
File::class,
58+
[
59+
'current' => "",
60+
'count' => 1,
61+
'getFilename' => $fileName
62+
]
63+
)->make();
64+
65+
//set mocked data property for File
66+
$property = new \ReflectionProperty(File::class, 'data');
67+
$property->setAccessible(true);
68+
$property->setValue($file, [$fileName => $content]);
69+
70+
return $file;
71+
}
72+
73+
/**
74+
* Function used to set mock for filesystem class during test
75+
*
76+
* @param string $fileList
77+
* @return object
78+
* @throws \Exception
79+
*/
80+
public function createPseudoFileSystem($fileList)
81+
{
82+
$filesystem = AspectMock::double(Filesystem::class)->make();
83+
84+
//set resolver to use mocked resolver
85+
$mockFileResolver = AspectMock::double(Module::class, ['get' => $fileList])->make();
86+
$property = new \ReflectionProperty(Filesystem::class, 'fileResolver');
87+
$property->setAccessible(true);
88+
$property->setValue($filesystem, $mockFileResolver);
89+
90+
//set validator to use mocked validator
91+
$mockValidation = AspectMock::double(ValidationState::class, ['isValidationRequired' => false])->make();
92+
$property = new \ReflectionProperty(Filesystem::class, 'validationState');
93+
$property->setAccessible(true);
94+
$property->setValue($filesystem, $mockValidation);
95+
96+
return $filesystem;
97+
}
98+
99+
/**
100+
* After class functionality
101+
* @return void
102+
*/
103+
public static function tearDownAfterClass()
104+
{
105+
TestLoggingUtil::getInstance()->clearMockLoggingUtil();
106+
parent::tearDownAfterClass();
107+
}
108+
}

dev/tests/unit/Magento/FunctionalTestFramework/Util/Sorter/ParallelGroupSorterTest.php

+18-16
Original file line numberDiff line numberDiff line change
@@ -36,9 +36,9 @@ public function testBasicTestGroupSort()
3636
$expectedResult = [
3737
1 => ['test2'],
3838
2 => ['test7'],
39-
3 => ['test6', 'test9'],
40-
4 => ['test1', 'test4', 'test3'],
41-
5 => ['test5', 'test10', 'test8']
39+
3 => ['test6', 'test4', 'test8'],
40+
4 => ['test1', 'test9'],
41+
5 => ['test3', 'test5', 'test10']
4242
];
4343

4444
$testSorter = new ParallelGroupSorter();
@@ -59,13 +59,16 @@ public function testSortWithSuites()
5959
{
6060
// mock tests for test object handler.
6161
$numberOfCalls = 0;
62-
$mockTest1 = AspectMock::double(TestObject::class, ['getTestActionCount' => function () use (&$numberOfCalls) {
63-
$actionCount = [200, 275];
64-
$result = $actionCount[$numberOfCalls];
65-
$numberOfCalls++;
66-
67-
return $result;
68-
}])->make();
62+
$mockTest1 = AspectMock::double(
63+
TestObject::class,
64+
['getEstimatedDuration' => function () use (&$numberOfCalls) {
65+
$actionCount = [300, 275];
66+
$result = $actionCount[$numberOfCalls];
67+
$numberOfCalls++;
68+
69+
return $result;
70+
}]
71+
)->make();
6972

7073
$mockHandler = AspectMock::double(
7174
TestObjectHandler::class,
@@ -92,17 +95,16 @@ public function testSortWithSuites()
9295

9396
// perform sort
9497
$testSorter = new ParallelGroupSorter();
95-
$actualResult = $testSorter->getTestsGroupedBySize($sampleSuiteArray, $sampleTestArray, 200);
98+
$actualResult = $testSorter->getTestsGroupedBySize($sampleSuiteArray, $sampleTestArray, 500);
9699

97100
// verify the resulting groups
98-
$this->assertCount(5, $actualResult);
101+
$this->assertCount(4, $actualResult);
99102

100103
$expectedResults = [
101104
1 => ['test3'],
102-
2 => ['test2'],
103-
3 => ['mockSuite1_0'],
104-
4 => ['mockSuite1_1'],
105-
5 => ['test5', 'test4', 'test1']
105+
2 => ['test2','test5', 'test4'],
106+
3 => ['mockSuite1_0', 'test1'],
107+
4 => ['mockSuite1_1']
106108
];
107109

108110
foreach ($actualResult as $groupNum => $group) {

dev/tests/verification/Resources/ActionGroupWithDataOverrideTest.txt

-1
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,6 @@ use Yandex\Allure\Adapter\Model\SeverityLevel;
1616
use Yandex\Allure\Adapter\Annotation\TestCaseId;
1717

1818
/**
19-
* @Title("A Functional Cest")
2019
* @group functional
2120
*/
2221
class ActionGroupWithDataOverrideTestCest

dev/tests/verification/Resources/ActionGroupWithDataTest.txt

-1
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,6 @@ use Yandex\Allure\Adapter\Model\SeverityLevel;
1616
use Yandex\Allure\Adapter\Annotation\TestCaseId;
1717

1818
/**
19-
* @Title("A Functional Cest")
2019
* @group functional
2120
*/
2221
class ActionGroupWithDataTestCest

dev/tests/verification/Resources/ActionGroupWithNoDefaultTest.txt

-1
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,6 @@ use Yandex\Allure\Adapter\Model\SeverityLevel;
1616
use Yandex\Allure\Adapter\Annotation\TestCaseId;
1717

1818
/**
19-
* @Title("A Functional Cest")
2019
* @group functional
2120
*/
2221
class ActionGroupWithNoDefaultTestCest

dev/tests/verification/Resources/ActionGroupWithPersistedData.txt

-1
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,6 @@ use Yandex\Allure\Adapter\Model\SeverityLevel;
1616
use Yandex\Allure\Adapter\Annotation\TestCaseId;
1717

1818
/**
19-
* @Title("A Functional Cest")
2019
* @group functional
2120
*/
2221
class ActionGroupWithPersistedDataCest

dev/tests/verification/Resources/ActionGroupWithTopLevelPersistedData.txt

-1
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,6 @@ use Yandex\Allure\Adapter\Model\SeverityLevel;
1616
use Yandex\Allure\Adapter\Annotation\TestCaseId;
1717

1818
/**
19-
* @Title("A Functional Cest")
2019
* @group functional
2120
*/
2221
class ActionGroupWithTopLevelPersistedDataCest

dev/tests/verification/Resources/ArgumentWithSameNameAsElement.txt

-1
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,6 @@ use Yandex\Allure\Adapter\Model\SeverityLevel;
1616
use Yandex\Allure\Adapter\Annotation\TestCaseId;
1717

1818
/**
19-
* @Title("A Functional Cest")
2019
* @group functional
2120
*/
2221
class ArgumentWithSameNameAsElementCest

dev/tests/verification/Resources/BasicActionGroupTest.txt

-1
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,6 @@ use Yandex\Allure\Adapter\Model\SeverityLevel;
1616
use Yandex\Allure\Adapter\Annotation\TestCaseId;
1717

1818
/**
19-
* @Title("A Functional Cest")
2019
* @group functional
2120
*/
2221
class BasicActionGroupTestCest

dev/tests/verification/Resources/BasicMergeTest.txt

+1-1
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ use Yandex\Allure\Adapter\Model\SeverityLevel;
1616
use Yandex\Allure\Adapter\Annotation\TestCaseId;
1717

1818
/**
19-
* @Title("A Functional Cest")
19+
* @Title("BasicMergeTest")
2020
* @group functional
2121
* @group mergeTest
2222
*/

dev/tests/verification/Resources/ChildExtendedTestAddHooks.txt

+1-1
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ use Yandex\Allure\Adapter\Model\SeverityLevel;
1616
use Yandex\Allure\Adapter\Annotation\TestCaseId;
1717

1818
/**
19-
* @Title("Parent")
19+
* @Title("ChildExtendedTestAddHooks")
2020
* @group Parent
2121
*/
2222
class ChildExtendedTestAddHooksCest

dev/tests/verification/Resources/ChildExtendedTestMerging.txt

+1-1
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ use Yandex\Allure\Adapter\Model\SeverityLevel;
1616
use Yandex\Allure\Adapter\Annotation\TestCaseId;
1717

1818
/**
19-
* @Title("Child")
19+
* @Title("ChildExtendedTestMerging")
2020
* @group Child
2121
*/
2222
class ChildExtendedTestMergingCest

dev/tests/verification/Resources/ChildExtendedTestNoParent.txt

+1-1
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ use Yandex\Allure\Adapter\Model\SeverityLevel;
1616
use Yandex\Allure\Adapter\Annotation\TestCaseId;
1717

1818
/**
19-
* @Title("Child")
19+
* @Title("ChildExtendedTestNoParent")
2020
* @group Child
2121
* @group skip
2222
*/

dev/tests/verification/Resources/ChildExtendedTestRemoveAction.txt

+1-1
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ use Yandex\Allure\Adapter\Model\SeverityLevel;
1616
use Yandex\Allure\Adapter\Annotation\TestCaseId;
1717

1818
/**
19-
* @Title("Child")
19+
* @Title("ChildExtendedTestRemoveAction")
2020
* @group Child
2121
*/
2222
class ChildExtendedTestRemoveActionCest

dev/tests/verification/Resources/ChildExtendedTestRemoveHookAction.txt

+1-1
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ use Yandex\Allure\Adapter\Model\SeverityLevel;
1616
use Yandex\Allure\Adapter\Annotation\TestCaseId;
1717

1818
/**
19-
* @Title("Child")
19+
* @Title("ChildExtendedTestRemoveHookAction")
2020
* @group Child
2121
*/
2222
class ChildExtendedTestRemoveHookActionCest

dev/tests/verification/Resources/ChildExtendedTestReplace.txt

+1-1
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ use Yandex\Allure\Adapter\Model\SeverityLevel;
1616
use Yandex\Allure\Adapter\Annotation\TestCaseId;
1717

1818
/**
19-
* @Title("Child")
19+
* @Title("ChildExtendedTestReplace")
2020
* @group Child
2121
*/
2222
class ChildExtendedTestReplaceCest

dev/tests/verification/Resources/ChildExtendedTestReplaceHook.txt

+1-1
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ use Yandex\Allure\Adapter\Model\SeverityLevel;
1616
use Yandex\Allure\Adapter\Annotation\TestCaseId;
1717

1818
/**
19-
* @Title("Child")
19+
* @Title("ChildExtendedTestReplaceHook")
2020
* @group Child
2121
*/
2222
class ChildExtendedTestReplaceHookCest

dev/tests/verification/Resources/MergedActionGroupTest.txt

-1
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,6 @@ use Yandex\Allure\Adapter\Model\SeverityLevel;
1616
use Yandex\Allure\Adapter\Annotation\TestCaseId;
1717

1818
/**
19-
* @Title("A Functional Cest")
2019
* @group functional
2120
*/
2221
class MergedActionGroupTestCest

dev/tests/verification/Resources/MergedReferencesTest.txt

+1-1
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ use Yandex\Allure\Adapter\Model\SeverityLevel;
1616
use Yandex\Allure\Adapter\Annotation\TestCaseId;
1717

1818
/**
19-
* @Title("A Functional Cest")
19+
* @Title("MergedReferencesTest")
2020
* @group functional
2121
*/
2222
class MergedReferencesTestCest

0 commit comments

Comments
 (0)