Skip to content
Snippets Groups Projects
Commit af11d7b2 authored by Alex Pott's avatar Alex Pott
Browse files

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

parent 13dcfc2d
No related branches found
No related tags found
No related merge requests found
<?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";
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment