Commit af11d7b2 authored by alexpott's avatar alexpott

Issue #1974266 by ParisLiakos: Register test module classes to PHPunit.

parent 13dcfc2d
<?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.');
}
}
<?php
/**
* @file
* Contains \Drupal\phpunit_test\PhpUnitTestDummyClass.
*/
namespace Drupal\phpunit_test;
class PhpUnitTestDummyClass {
}
......@@ -8,6 +8,13 @@
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";
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment