Skip to content

Commit 343009b

Browse files
authored
Merge pull request magento#134 from magento/MQE-987
MQE-987: Decouple MFTF from Magento
2 parents 486a5be + 1af30e0 commit 343009b

28 files changed

+715
-335
lines changed

RoboFile.php

-214
This file was deleted.

bin/mftf

+15-1
Original file line numberDiff line numberDiff line change
@@ -11,13 +11,27 @@ if (PHP_SAPI !== 'cli') {
1111
exit(1);
1212
}
1313

14+
$autoload_path = realpath(__DIR__ . '/../../../autoload.php');
15+
$test_bootstrap_path = realpath(__DIR__ . '/../dev/tests/functional/_bootstrap.php');
16+
17+
if (file_exists($autoload_path)) {
18+
require_once $autoload_path;
19+
} else {
20+
require_once $test_bootstrap_path;
21+
}
22+
23+
1424
try {
15-
require_once __DIR__ . '/../bootstrap.php';
1625
$application = new Symfony\Component\Console\Application();
1726
$application->setName('Magento Functional Testing Framework CLI');
1827
$application->setVersion('1.0.0');
1928
$application->add(new Magento\FunctionalTestingFramework\Console\SetupEnvCommand());
29+
$application->add(new Magento\FunctionalTestingFramework\Console\CleanProjectCommand());
2030
$application->add(new Magento\FunctionalTestingFramework\Console\BuildProjectCommand());
31+
$application->add(new Magento\FunctionalTestingFramework\Console\GenerateSuiteCommand());
32+
$application->add(new Magento\FunctionalTestingFramework\Console\GenerateTestsCommand());
33+
$application->add(new Magento\FunctionalTestingFramework\Console\RunTestGroupCommand());
34+
$application->add(new Magento\FunctionalTestingFramework\Console\RunTestCommand());
2135
$application->run();
2236
} catch (\Exception $e) {
2337
while ($e) {

bootstrap.php

-8
This file was deleted.

composer.json

+1
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@
3434
"symfony/stopwatch": "~3.4.6"
3535
},
3636
"autoload": {
37+
"files": ["src/Magento/FunctionalTestingFramework/_bootstrap.php"],
3738
"psr-4": {
3839
"Magento\\FunctionalTestingFramework\\": "src/Magento/FunctionalTestingFramework",
3940
"MFTF\\": "dev/tests/functional/MFTF"

dev/tests/_bootstrap.php

+7-3
Original file line numberDiff line numberDiff line change
@@ -6,14 +6,18 @@
66

77
error_reporting(~E_USER_NOTICE);
88
define('PROJECT_ROOT', dirname(dirname(__DIR__)));
9-
require_once PROJECT_ROOT . '/vendor/autoload.php';
10-
require_once 'util/MftfTestCase.php';
9+
10+
$vendorAutoloadPath = realpath(PROJECT_ROOT . '/vendor/autoload.php');
11+
$mftfTestCasePath = realpath(PROJECT_ROOT . '/dev/tests/util/MftfTestCase.php');
12+
13+
require_once $vendorAutoloadPath;
14+
require_once $mftfTestCasePath;
1115

1216
// Set up AspectMock
1317
$kernel = \AspectMock\Kernel::getInstance();
1418
$kernel->init([
1519
'debug' => true,
16-
'includePaths' => [PROJECT_ROOT . '/src'],
20+
'includePaths' => [PROJECT_ROOT . DIRECTORY_SEPARATOR . 'src'],
1721
'cacheDir' => PROJECT_ROOT .
1822
DIRECTORY_SEPARATOR .
1923
'dev' .

dev/tests/functional/MFTF/_bootstrap.php

-7
This file was deleted.

dev/tests/functional/_bootstrap.php

+14-17
Original file line numberDiff line numberDiff line change
@@ -5,22 +5,9 @@
55
*/
66

77
define('PROJECT_ROOT', dirname(dirname(dirname(__DIR__))));
8-
require_once PROJECT_ROOT . '/vendor/autoload.php';
9-
$RELATIVE_FW_PATH = PROJECT_ROOT;
8+
require_once realpath(PROJECT_ROOT . '/vendor/autoload.php');
109

1110
//Load constants from .env file
12-
if (file_exists(PROJECT_ROOT . '/.env')) {
13-
$env = new \Dotenv\Loader(PROJECT_ROOT . '/.env');
14-
$env->load();
15-
16-
if (array_key_exists('TESTS_MODULE_PATH', $_ENV) xor array_key_exists('TESTS_BP', $_ENV)) {
17-
throw new Exception('You must define both parameters TESTS_BP and TESTS_MODULE_PATH or neither parameter');
18-
}
19-
20-
foreach ($_ENV as $key => $var) {
21-
defined($key) || define($key, $var);
22-
}
23-
}
2411
defined('FW_BP') || define('FW_BP', PROJECT_ROOT);
2512

2613
// add the debug flag here
@@ -29,7 +16,17 @@
2916
xdebug_disable();
3017
}
3118

32-
$RELATIVE_TESTS_MODULE_PATH = '/MFTF/FunctionalTest';
19+
$RELATIVE_TESTS_MODULE_PATH = '/tests/functional/tests/MFTF';
3320

34-
defined('TESTS_BP') || define('TESTS_BP', __DIR__);
35-
defined('TESTS_MODULE_PATH') || define('TESTS_MODULE_PATH', TESTS_BP . $RELATIVE_TESTS_MODULE_PATH);
21+
defined('MAGENTO_BP') || define('MAGENTO_BP', PROJECT_ROOT);
22+
defined('TESTS_BP') || define('TESTS_BP', dirname(dirname(__DIR__)));
23+
defined('TESTS_MODULE_PATH') || define('TESTS_MODULE_PATH', realpath(TESTS_BP . $RELATIVE_TESTS_MODULE_PATH));
24+
25+
if (file_exists(TESTS_BP . DIRECTORY_SEPARATOR . '.env')) {
26+
$env = new \Dotenv\Loader(TESTS_BP . DIRECTORY_SEPARATOR . '.env');
27+
$env->load();
28+
29+
foreach ($_ENV as $key => $var) {
30+
defined($key) || define($key, $var);
31+
}
32+
}

dev/tests/unit/Magento/FunctionalTestFramework/Suite/SuiteGeneratorTest.php

+11-1
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,17 @@
2323
class SuiteGeneratorTest extends TestCase
2424
{
2525

26+
/**
27+
* Setup entry append and clear for Suite Generator
28+
*/
29+
public static function setUpBeforeClass()
30+
{
31+
AspectMock::double(SuiteGenerator::class, [
32+
'clearPreviousSessionConfigEntries' => null,
33+
'appendEntriesToConfig' => null
34+
]);
35+
}
36+
2637
/**
2738
* Tests generating a single suite given a set of parsed test data
2839
* @throws \Exception
@@ -169,6 +180,5 @@ private function setMockTestAndSuiteParserOutput($testData, $suiteData)
169180
$property = new \ReflectionProperty(SuiteGenerator::class, 'groupClassGenerator');
170181
$property->setAccessible(true);
171182
$property->setValue($instance, $instance);
172-
173183
}
174184
}

0 commit comments

Comments
 (0)