Issue #1974266 by ParisLiakos: Register test module classes to PHPunit.
parent
13dcfc2d66
commit
af11d7b2eb
|
@ -0,0 +1,32 @@
|
|||
<?php
|
||||
|
||||
/**
|
||||
* @file
|
||||
* Contains \Drupal\simpletest\Tests\PhpUnitAutoloaderTest.
|
||||
*/
|
||||
|
||||
namespace Drupal\simpletest\Tests;
|
||||
|
||||
use Drupal\Tests\UnitTestCase;
|
||||
|
||||
/**
|
||||
* Test PHPUnit autoloader works correctly.
|
||||
*/
|
||||
class PhpUnitAutoloaderTest extends UnitTestCase {
|
||||
|
||||
public static function getInfo() {
|
||||
return array(
|
||||
'name' => 'PHPUnit autoloader',
|
||||
'description' => 'Test that classes are correctly loaded during PHPUnit initialization.',
|
||||
'group' => 'Simpletest',
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Test loading of classes provided by test sub modules.
|
||||
*/
|
||||
public function testPhpUnitTestClassesLoading() {
|
||||
$this->assertTrue(class_exists('\Drupal\phpunit_test\PhpUnitTestDummyClass'), 'Class provided by test module was not autoloaded.');
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,11 @@
|
|||
<?php
|
||||
|
||||
/**
|
||||
* @file
|
||||
* Contains \Drupal\phpunit_test\PhpUnitTestDummyClass.
|
||||
*/
|
||||
|
||||
namespace Drupal\phpunit_test;
|
||||
|
||||
class PhpUnitTestDummyClass {
|
||||
}
|
|
@ -8,6 +8,13 @@ $loader->add('Drupal\Component', __DIR__ . "/../../core/lib");
|
|||
|
||||
foreach (scandir(__DIR__ . "/../modules") as $module) {
|
||||
$loader->add('Drupal\\' . $module, __DIR__ . "/../modules/" . $module . "/lib");
|
||||
// Add test module classes.
|
||||
$test_modules_dir = __DIR__ . "/../modules/$module/tests/modules";
|
||||
if (is_dir($test_modules_dir)) {
|
||||
foreach (scandir($test_modules_dir) as $test_module) {
|
||||
$loader->add('Drupal\\' . $test_module, $test_modules_dir . '/' . $test_module . '/lib');
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
require __DIR__ . "/../../core/lib/Drupal.php";
|
||||
|
|
Loading…
Reference in New Issue