Skip to content

Commit 72ae4f8

Browse files
author
Oleksii Korshenko
committed
MAGETWO-55501: Add support of queue testing in integration tests framework
1 parent f553937 commit 72ae4f8

File tree

5 files changed

+92
-0
lines changed

5 files changed

+92
-0
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
{
2+
"name": "magento/module-sample-test",
3+
"description": "test sample module",
4+
"require": {
5+
"php": "~5.6.0|7.0.2|7.0.4|~7.0.6",
6+
"magento/framework": "100.1.*",
7+
"magento/module-integration": "100.1.*"
8+
},
9+
"type": "magento2-module",
10+
"version": "1.0",
11+
"extra": {
12+
"map": [
13+
[
14+
"*",
15+
"Magento/TestModuleSample"
16+
]
17+
]
18+
}
19+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
<?xml version="1.0"?>
2+
<!--
3+
/**
4+
* Copyright © 2016 Magento. All rights reserved.
5+
* See COPYING.txt for license details.
6+
*/
7+
-->
8+
<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:Module/etc/module.xsd">
9+
<module name="Magento_TestModuleSample" setup_version="0.0.1" active="true">
10+
</module>
11+
</config>
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
<?php
2+
/**
3+
* Copyright © 2016 Magento. All rights reserved.
4+
* See COPYING.txt for license details.
5+
*/
6+
7+
use Magento\Framework\Component\ComponentRegistrar;
8+
9+
$registrar = new ComponentRegistrar();
10+
if ($registrar->getPath(ComponentRegistrar::MODULE, 'Magento_TestModuleSample') === null) {
11+
ComponentRegistrar::register(ComponentRegistrar::MODULE, 'Magento_TestModuleSample', __DIR__);
12+
}

dev/tests/integration/framework/bootstrap.php

+29
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,35 @@
1515
define('TESTS_TEMP_DIR', $testsBaseDir . '/tmp');
1616
}
1717

18+
/** Copy test modules to app/code/Magento to make them visible for Magento instance */
19+
$pathToCommittedTestModules = __DIR__ . '/../_files/Magento';
20+
$pathToInstalledMagentoInstanceModules = __DIR__ . '/../../../../app/code/Magento';
21+
$iterator = new RecursiveIteratorIterator(new RecursiveDirectoryIterator($pathToCommittedTestModules));
22+
/** @var SplFileInfo $file */
23+
foreach ($iterator as $file) {
24+
if (!$file->isDir()) {
25+
$source = $file->getPathname();
26+
$relativePath = substr($source, strlen($pathToCommittedTestModules));
27+
$destination = $pathToInstalledMagentoInstanceModules . $relativePath;
28+
$targetDir = dirname($destination);
29+
if (!is_dir($targetDir)) {
30+
mkdir($targetDir, 0755, true);
31+
}
32+
copy($source, $destination);
33+
}
34+
}
35+
unset($iterator, $file);
36+
37+
// Register the modules under '_files/'
38+
$pathPattern = $pathToInstalledMagentoInstanceModules . '/TestModule*/registration.php';
39+
$files = glob($pathPattern, GLOB_NOSORT);
40+
if ($files === false) {
41+
throw new \RuntimeException('glob() returned error while searching in \'' . $pathPattern . '\'');
42+
}
43+
foreach ($files as $file) {
44+
include $file;
45+
}
46+
1847
try {
1948
/* Bootstrap the application */
2049
$settings = new \Magento\TestFramework\Bootstrap\Settings($testsBaseDir, get_defined_constants());
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
<?php
2+
/**
3+
* Copyright © 2016 Magento. All rights reserved.
4+
* See COPYING.txt for license details.
5+
*/
6+
namespace Magento\TestModuleSample;
7+
8+
class ModuleInstallationTest extends \PHPUnit_Framework_TestCase
9+
{
10+
public function testSampleModuleInstallation()
11+
{
12+
/** @var \Magento\Framework\Module\ModuleListInterface $moduleList */
13+
$moduleList = \Magento\TestFramework\Helper\Bootstrap::getObjectManager()->get(
14+
\Magento\Framework\Module\ModuleListInterface::class
15+
);
16+
$this->assertTrue(
17+
$moduleList->has('Magento_TestModuleSample'),
18+
'Test module [Magento_TestModuleSample] is not installed'
19+
);
20+
}
21+
}

0 commit comments

Comments
 (0)