You are here

function SimpleTestTest::confirmStubTestResults in Zircon Profile 8

Same name and namespace in other branches
  1. 8.0 core/modules/simpletest/src/Tests/SimpleTestTest.php \Drupal\simpletest\Tests\SimpleTestTest::confirmStubTestResults()

Confirm that the stub test produced the desired results.

1 call to SimpleTestTest::confirmStubTestResults()
SimpleTestTest::testWebTestRunner in core/modules/simpletest/src/Tests/SimpleTestTest.php
Ensures the tests selected through the web interface are run and displayed.

File

core/modules/simpletest/src/Tests/SimpleTestTest.php, line 245
Contains \Drupal\simpletest\Tests\SimpleTestTest.

Class

SimpleTestTest
Tests SimpleTest's web interface: check that the intended tests were run and ensure that test reports display the intended results. Also test SimpleTest's internal browser and APIs implicitly.

Namespace

Drupal\simpletest\Tests

Code

function confirmStubTestResults() {
  $this
    ->assertAssertion(t('Unable to install modules %modules due to missing modules %missing.', array(
    '%modules' => 'non_existent_module',
    '%missing' => 'non_existent_module',
  )), 'Other', 'Fail', 'SimpleTestTest.php', 'Drupal\\simpletest\\Tests\\SimpleTestTest->setUp()');
  $this
    ->assertAssertion($this->passMessage, 'Other', 'Pass', 'SimpleTestTest.php', 'Drupal\\simpletest\\Tests\\SimpleTestTest->stubTest()');
  $this
    ->assertAssertion($this->failMessage, 'Other', 'Fail', 'SimpleTestTest.php', 'Drupal\\simpletest\\Tests\\SimpleTestTest->stubTest()');
  $this
    ->assertAssertion(t('Created permissions: @perms', array(
    '@perms' => $this->validPermission,
  )), 'Role', 'Pass', 'SimpleTestTest.php', 'Drupal\\simpletest\\Tests\\SimpleTestTest->stubTest()');
  $this
    ->assertAssertion(t('Invalid permission %permission.', array(
    '%permission' => $this->invalidPermission,
  )), 'Role', 'Fail', 'SimpleTestTest.php', 'Drupal\\simpletest\\Tests\\SimpleTestTest->stubTest()');

  // Check that the user was logged in successfully.
  $this
    ->assertAssertion('User SimpleTestTest successfully logged in.', 'User login', 'Pass', 'SimpleTestTest.php', 'Drupal\\simpletest\\Tests\\SimpleTestTest->stubTest()');

  // Check that a warning is caught by simpletest. The exact error message
  // differs between PHP versions so only the function name is checked.
  $this
    ->assertAssertion('trigger_error()', 'Warning', 'Fail', 'SimpleTestTest.php', 'Drupal\\simpletest\\Tests\\SimpleTestTest->stubTest()');

  // Check that the backtracing code works for specific assert function.
  $this
    ->assertAssertion('This is nothing.', 'Other', 'Pass', 'SimpleTestTest.php', 'Drupal\\simpletest\\Tests\\SimpleTestTest->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 'array_key_exists'.
  $this
    ->assertAssertion('array_key_exists', 'Warning', 'Fail', 'SimpleTestTest.php', 'Drupal\\simpletest\\Tests\\SimpleTestTest->stubTest()');
  $this
    ->assertAssertion("Debug: 'Foo'", 'Debug', 'Fail', 'SimpleTestTest.php', 'Drupal\\simpletest\\Tests\\SimpleTestTest->stubTest()');
  $this
    ->assertEqual('16 passes, 3 fails, 2 exceptions, 3 debug messages', $this->childTestResults['summary']);
  $this->testIds[] = $test_id = $this
    ->getTestIdFromResults();
  $this
    ->assertTrue($test_id, 'Found test ID in results.');
}