Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 13 additions & 8 deletions core/modules/simpletest/tests/simpletest.test
Original file line number Diff line number Diff line change
Expand Up @@ -153,13 +153,16 @@ class SimpleTestFunctionalTest extends BackdropWebTestCase {
$this->pass(t('Test ID is @id.', array('@id' => $this->testId)));

// Generates a warning.
$i = 1 / 0;
$a = '';
foreach ($a as $b) {

}

// Call an assert function specific to that class.
$this->assertNothing();

// Generates a warning inside a PHP function.
array_key_exists(NULL, NULL);
// Generates 3 warnings inside a PHP function.
simplexml_load_string('<fake>');

debug('Foo', 'Debug');
}
Expand All @@ -184,19 +187,21 @@ class SimpleTestFunctionalTest extends BackdropWebTestCase {
$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.
$this->assertAssertion('Division by zero', 'Warning', 'Fail', 'simpletest.test', 'SimpleTestFunctionalTest->stubTest()');
// 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 'array_key_exists'.
$this->assertAssertion('array_key_exists', 'Warning', 'Fail', 'simpletest.test', 'SimpleTestFunctionalTest->stubTest()');
// 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->assertTrue(strpos($this->childTestResults['summary'], '6 passes, 5 fails, 2 exceptions, and 1 debug message.') === 0, 'Stub test summary is correct');
$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.');
Expand Down