function SimpleTestDiscoveryTestCase::testDiscovery
7.x simpletest.test | SimpleTestDiscoveryTestCase::testDiscovery() |
Tests existence of test cases.
File
- drupal-7.x/
modules/ simpletest/ simpletest.test, line 715 - 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;
}
// This one is provided by simpletest itself via PSR-0.
$this->assertText('PSR0 web test');
$this->assertText('PSR0 example test: PSR-0 in disabled modules.');
$this->assertText('PSR0 example test: PSR-0 in nested subfolders.');
// Test each test individually.
foreach (array(
'Drupal\\psr_0_test\\Tests\\ExampleTest',
'Drupal\\psr_0_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)));
}
}