function SimpleTestDiscoveryTestCase::testDiscovery in Drupal 7
Tests existence of test cases.
File
- modules/
simpletest/ simpletest.test, line 770 - Tests for simpletest.module.
Class
- SimpleTestDiscoveryTestCase
- Verifies that tests in other installation profiles are not found.
Code
function testDiscovery() {
$this
->drupalGet('admin/config/development/testing');
// Tests within enabled modules.
// (without these, this test wouldn't happen in the first place, so this is
// a bit pointless. We still run it for proof-of-concept.)
// This one is defined in system module.
$this
->assertText('Drupal error handlers');
// This one is defined in simpletest module.
$this
->assertText('Discovery of test classes');
// Tests within disabled modules.
if (version_compare(PHP_VERSION, '5.3') < 0) {
// Don't expect PSR-0 tests to be discovered on older PHP versions.
return;
}
// These are provided by simpletest itself via PSR-0 and PSR-4.
$this
->assertText('PSR0 web test');
$this
->assertText('PSR4 web test');
$this
->assertText('PSR0 example test: PSR-0 in disabled modules.');
$this
->assertText('PSR4 example test: PSR-4 in disabled modules.');
$this
->assertText('PSR0 example test: PSR-0 in nested subfolders.');
$this
->assertText('PSR4 example test: PSR-4 in nested subfolders.');
// Test each test individually.
foreach (array(
'Drupal\\psr_0_test\\Tests\\ExampleTest',
'Drupal\\psr_0_test\\Tests\\Nested\\NestedExampleTest',
'Drupal\\psr_4_test\\Tests\\ExampleTest',
'Drupal\\psr_4_test\\Tests\\Nested\\NestedExampleTest',
) as $class) {
$this
->drupalGet('admin/config/development/testing');
$edit = array(
$class => TRUE,
);
$this
->drupalPost(NULL, $edit, t('Run tests'));
$this
->assertText('The test run finished', t('Test @class must finish.', array(
'@class' => $class,
)));
$this
->assertText('1 pass, 0 fails, and 0 exceptions', t('Test @class must pass.', array(
'@class' => $class,
)));
}
}