Skip to content

Commit 2410096

Browse files
committed
Merge branch 'sprint-develop' of https://github.com/magento-pangolin/magento2-functional-testing-framework into sprint-develop
2 parents 724af1d + 3b84770 commit 2410096

File tree

11 files changed

+81
-27
lines changed

11 files changed

+81
-27
lines changed

.gitattributes

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
# Declare files that will always have LF line endings on checkout.
2+
dev/tests/verification/Resources/TestSuiteGeneration1.txt text=auto !eol
3+
dev/tests/verification/Resources/*.txt text eol=lf

bin/phpunit-checks.bat

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
:: Copyright © Magento, Inc. All rights reserved.
2+
:: See COPYING.txt for license details.
3+
4+
@echo ===============================UNIT TESTS===============================
5+
@echo off
6+
call vendor\bin\phpunit --configuration dev\tests\phpunit.xml --testsuite unit --coverage-xml build\coverage-xml
7+
8+
@echo off
9+
@echo ===============================VERIFICATION TESTS===============================
10+
call vendor\bin\phpunit --configuration dev\tests\phpunit.xml --testsuite verification --coverage-xml build\coverage-xml

bin/static-checks.bat

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
:: Copyright © Magento, Inc. All rights reserved.
2+
:: See COPYING.txt for license details.
3+
4+
@echo off
5+
@echo ===============================PHP CODE SNIFFER REPORT===============================
6+
call vendor\bin\phpcs .\src --standard=.\dev\tests\static\Magento
7+
call vendor\bin\phpcs .\dev\tests\unit --standard=.\dev\tests\static\Magento
8+
call vendor\bin\phpcs .\dev\tests\verification --standard=.\dev\tests\static\Magento --ignore=dev\tests\verification\_generated
9+
10+
@echo ===============================COPY PASTE DETECTOR REPORT===============================
11+
call vendor\bin\phpcpd .\src
12+
13+
:: Uncomment lines as part of MQE-590
14+
:: @echo "===============================PHP MESS DETECTOR REPORT===============================
15+
:: vendor\bin\phpmd .\src text \dev\tests\static\Magento\CodeMessDetector\ruleset.xml --exclude _generated
16+
17+
@echo ===============================MAGENTO COPYRIGHT REPORT===============================
18+
echo msgbox "INFO:Copyright check currently not run as part of .bat implementation" > "%temp%\popup.vbs"
19+
wscript.exe "%temp%\popup.vbs"
20+
::bin\copyright-check

dev/tests/verification/Resources/TestSuiteGeneration1.txt

Lines changed: 0 additions & 4 deletions
This file was deleted.

dev/tests/verification/Tests/SuiteGenerationTest.php

Lines changed: 29 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,13 @@ class SuiteGenerationTest extends TestCase
1616
const RESOURCES_DIR = TESTS_BP . DIRECTORY_SEPARATOR . 'verification' . DIRECTORY_SEPARATOR . 'Resources';
1717
const CONFIG_YML_FILE = FW_BP . DIRECTORY_SEPARATOR . SuiteGenerator::YAML_CODECEPTION_CONFIG_FILENAME;
1818

19+
const MANIFEST_RESULTS = [
20+
'SampleSuite3Cest.php:IncludeTest',
21+
'SampleSuite5Cest.php:additionalTest',
22+
'SampleSuiteCest.php:IncludeTest',
23+
'SampleSuite4Cest.php:IncludeTest'
24+
];
25+
1926
private static $YML_EXISTS_FLAG = false;
2027
private static $TEST_GROUPS = [];
2128

@@ -45,18 +52,34 @@ public function testSuiteGeneration1()
4552
$yml = Yaml::parse(file_get_contents(self::CONFIG_YML_FILE));
4653
$this->assertArrayHasKey($groupName, $yml['groups']);
4754

48-
// Validate test manifest contents
49-
$actualManifest = TESTS_BP .
55+
$suiteResultBaseDir = TESTS_BP .
5056
DIRECTORY_SEPARATOR .
5157
"verification" .
5258
DIRECTORY_SEPARATOR .
5359
"_generated" .
5460
DIRECTORY_SEPARATOR .
5561
$groupName .
56-
DIRECTORY_SEPARATOR .
57-
TestManifest::TEST_MANIFEST_FILENAME;
58-
$expectedManifest = self::RESOURCES_DIR . DIRECTORY_SEPARATOR . "TestSuiteGeneration1.txt";
59-
$this->assertFileEquals($expectedManifest, $actualManifest, '', true, true);
62+
DIRECTORY_SEPARATOR;
63+
64+
// Validate test manifest contents
65+
$actualManifest = $suiteResultBaseDir . TestManifest::TEST_MANIFEST_FILENAME;
66+
$actualTestReferences = explode(PHP_EOL, file_get_contents($actualManifest));
67+
68+
for ($i = 0; $i < count($actualTestReferences); $i++) {
69+
if (empty($actualTestReferences[$i])) {
70+
continue;
71+
}
72+
73+
$this->assertStringEndsWith(self::MANIFEST_RESULTS[$i], $actualTestReferences[$i]);
74+
$this->assertNotFalse(strpos($actualTestReferences[$i], $groupName));
75+
}
76+
77+
// Validate expected php files exist
78+
foreach (self::MANIFEST_RESULTS as $expectedTestReference) {
79+
$cestName = explode(":", $expectedTestReference, 2);
80+
$this->assertFileExists($suiteResultBaseDir . $cestName[0]);
81+
}
82+
6083
}
6184

6285
public static function tearDownAfterClass()

src/Magento/FunctionalTestingFramework/Config/FileResolver/Mask.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,7 @@ protected function getFileCollection($filename, $scope)
6464
$modulesPath = $this->moduleResolver->getModulesPath();
6565

6666
foreach ($modulesPath as $modulePath) {
67-
$path = $modulePath . '/' . $scope . '/';
67+
$path = $modulePath . DIRECTORY_SEPARATOR . $scope . DIRECTORY_SEPARATOR;
6868
if (is_readable($path)) {
6969
$directoryIterator = new \RecursiveIteratorIterator(
7070
new \RecursiveDirectoryIterator(

src/Magento/FunctionalTestingFramework/Config/FileResolver/Primary.php

Lines changed: 10 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ public function get($filename, $scope)
2828
if (!$filename) {
2929
return [];
3030
}
31-
$scope = str_replace('\\', '/', $scope);
31+
$scope = str_replace('\\', DIRECTORY_SEPARATOR, $scope);
3232
return new File($this->getFilePaths($filename, $scope));
3333
}
3434

@@ -59,19 +59,20 @@ private function getPathPatterns($filename, $scope)
5959
{
6060
if (substr($scope, 0, strlen(FW_BP)) === FW_BP) {
6161
$patterns = [
62-
$scope . '/' . $filename,
63-
$scope . '/*/' . $filename
62+
$scope . DIRECTORY_SEPARATOR . $filename,
63+
$scope . DIRECTORY_SEPARATOR . '*' . DIRECTORY_SEPARATOR . $filename
6464
];
6565
} else {
6666
$defaultPath = dirname(dirname(dirname(dirname(__DIR__))));
67-
$defaultPath = str_replace('\\', '/', $defaultPath);
67+
$defaultPath = str_replace('\\', DIRECTORY_SEPARATOR, $defaultPath);
6868
$patterns = [
69-
$defaultPath . '/' . $scope . '/' . $filename,
70-
$defaultPath . '/' . $scope . '/*/' . $filename,
71-
FW_BP . '/' . $scope . '/' . $filename,
72-
FW_BP . '/' . $scope . '/*/' . $filename
69+
$defaultPath . DIRECTORY_SEPARATOR . $scope . DIRECTORY_SEPARATOR . $filename,
70+
$defaultPath . DIRECTORY_SEPARATOR . $scope . DIRECTORY_SEPARATOR . '*' . DIRECTORY_SEPARATOR
71+
. $filename,
72+
FW_BP . DIRECTORY_SEPARATOR . $scope . DIRECTORY_SEPARATOR . $filename,
73+
FW_BP . DIRECTORY_SEPARATOR . $scope . DIRECTORY_SEPARATOR . '*' . DIRECTORY_SEPARATOR . $filename
7374
];
7475
}
75-
return str_replace('/', DIRECTORY_SEPARATOR, $patterns);
76+
return str_replace(DIRECTORY_SEPARATOR, DIRECTORY_SEPARATOR, $patterns);
7677
}
7778
}

src/Magento/FunctionalTestingFramework/Config/SchemaLocator.php

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -25,12 +25,12 @@ class SchemaLocator implements \Magento\FunctionalTestingFramework\Config\Schema
2525
*/
2626
public function __construct($schemaPath)
2727
{
28-
if (constant('FW_BP') && file_exists(FW_BP . '/' . $schemaPath)) {
29-
$this->schemaPath = FW_BP . '/' . $schemaPath;
28+
if (constant('FW_BP') && file_exists(FW_BP . DIRECTORY_SEPARATOR . $schemaPath)) {
29+
$this->schemaPath = FW_BP . DIRECTORY_SEPARATOR . $schemaPath;
3030
} else {
3131
$path = dirname(dirname(dirname(__DIR__)));
32-
$path = str_replace('\\', '/', $path);
33-
$this->schemaPath = $path . '/' . $schemaPath;
32+
$path = str_replace('\\', DIRECTORY_SEPARATOR, $path);
33+
$this->schemaPath = $path . DIRECTORY_SEPARATOR . $schemaPath;
3434
}
3535
}
3636

src/Magento/FunctionalTestingFramework/DataGenerator/Handlers/DataObjectHandler.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -132,7 +132,7 @@ private function initDataObjects()
132132
*/
133133
private function parseEnvVariables()
134134
{
135-
$envFilename = PROJECT_ROOT . '/.env';
135+
$envFilename = PROJECT_ROOT . DIRECTORY_SEPARATOR . '.env';
136136
if (file_exists($envFilename)) {
137137
$envData = [];
138138
$envFile = file($envFilename);

src/Magento/FunctionalTestingFramework/Module/MagentoSequence.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ class MagentoSequence extends Sequence
2020
}
2121

2222
if (!function_exists('msq') && !function_exists('msqs')) {
23-
require_once __DIR__ . '/../Util/msq.php';
23+
require_once __DIR__ . DIRECTORY_SEPARATOR . '..' . DIRECTORY_SEPARATOR . 'Util' . DIRECTORY_SEPARATOR . 'msq.php';
2424
} else {
2525
throw new ModuleException('Magento\FunctionalTestingFramework\Module\MagentoSequence', "function 'msq' and 'msqs' already defined");
2626
}

src/Magento/FunctionalTestingFramework/ObjectManager/Config/SchemaLocator.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,8 @@ class SchemaLocator implements SchemaLocatorInterface
2222
*/
2323
public function getSchema()
2424
{
25-
return realpath(__DIR__ . '/../etc/') . DIRECTORY_SEPARATOR . 'config.xsd';
25+
return realpath(__DIR__ . DIRECTORY_SEPARATOR . '..' . DIRECTORY_SEPARATOR . 'etc' . DIRECTORY_SEPARATOR)
26+
. DIRECTORY_SEPARATOR . 'config.xsd';
2627
}
2728

2829
/**

0 commit comments

Comments
 (0)