You are here

function SimpleTestFunctionalTest::confirmStubTestResults in Drupal 7

Confirm that the stub test produced the desired results.

1 call to SimpleTestFunctionalTest::confirmStubTestResults()
SimpleTestFunctionalTest::testWebTestRunner in modules/simpletest/simpletest.test
Make sure that tests selected through the web interface are run and that the results are displayed correctly.

File

modules/simpletest/simpletest.test, line 191
Tests for simpletest.module.

Class

SimpleTestFunctionalTest
@file Tests for simpletest.module.

Code

function confirmStubTestResults() {
  $this
    ->assertAssertion(t('Enabled modules: %modules', array(
    '%modules' => 'non_existent_module',
  )), 'Other', 'Fail', 'simpletest.test', 'SimpleTestFunctionalTest->setUp()');
  $this
    ->assertAssertion($this->pass, 'Other', 'Pass', 'simpletest.test', 'SimpleTestFunctionalTest->stubTest()');
  $this
    ->assertAssertion($this->fail, 'Other', 'Fail', 'simpletest.test', 'SimpleTestFunctionalTest->stubTest()');
  $this
    ->assertAssertion(t('Created permissions: @perms', array(
    '@perms' => $this->valid_permission,
  )), 'Role', 'Pass', 'simpletest.test', 'SimpleTestFunctionalTest->stubTest()');
  $this
    ->assertAssertion(t('Invalid permission %permission.', array(
    '%permission' => $this->invalid_permission,
  )), 'Role', 'Fail', 'simpletest.test', 'SimpleTestFunctionalTest->stubTest()');

  // Check that a warning is caught by simpletest.
  // The exact error message differs between PHP versions so we check only
  // the presense of the 'foreach' statement.
  $this
    ->assertAssertion('foreach()', 'Warning', 'Fail', 'simpletest.test', 'SimpleTestFunctionalTest->stubTest()');

  // Check that the backtracing code works for specific assert function.
  $this
    ->assertAssertion('This is nothing.', 'Other', 'Pass', 'simpletest.test', 'SimpleTestFunctionalTest->stubTest()');

  // Check that errors that occur inside PHP internal functions are correctly reported.
  // The exact error message differs between PHP versions so we check only
  // the function name 'simplexml_load_string'.
  $this
    ->assertAssertion('simplexml_load_string', 'Warning', 'Fail', 'simpletest.test', 'SimpleTestFunctionalTest->stubTest()');
  $this
    ->assertAssertion("Debug: 'Foo'", 'Debug', 'Fail', 'simpletest.test', 'SimpleTestFunctionalTest->stubTest()');
  $this
    ->assertEqual('6 passes, 5 fails, 4 exceptions, and 1 debug message', $this->childTestResults['summary'], 'Stub test summary is correct');
  $this->test_ids[] = $test_id = $this
    ->getTestIdFromResults();
  $this
    ->assertTrue($test_id, 'Found test ID in results.');
}