diff --git a/core/modules/simpletest/lib/Drupal/simpletest/DrupalUnitTestBase.php b/core/modules/simpletest/lib/Drupal/simpletest/DrupalUnitTestBase.php index d6bd64f..2fe3778 100644 --- a/core/modules/simpletest/lib/Drupal/simpletest/DrupalUnitTestBase.php +++ b/core/modules/simpletest/lib/Drupal/simpletest/DrupalUnitTestBase.php @@ -124,6 +124,13 @@ protected function prepareConfigDirectories() { protected function setUp() { $this->keyValueFactory = new KeyValueMemoryFactory(); + // Allow for test-specific overrides. + $settings_services_file = DRUPAL_ROOT . '/' . $this->originalSite . '/testing.services.yml'; + if (file_exists($settings_services_file)) { + // Copy the testing-specific service overrides in place. + copy($settings_services_file, DRUPAL_ROOT . '/' . $this->siteDirectory . '/services.yml'); + } + parent::setUp(); // Create and set new configuration directories. diff --git a/core/modules/simpletest/lib/Drupal/simpletest/Tests/SimpleTestTest.php b/core/modules/simpletest/lib/Drupal/simpletest/Tests/SimpleTestTest.php index 492b86f..a7d2d8f 100755 --- a/core/modules/simpletest/lib/Drupal/simpletest/Tests/SimpleTestTest.php +++ b/core/modules/simpletest/lib/Drupal/simpletest/Tests/SimpleTestTest.php @@ -33,6 +33,9 @@ class SimpleTestTest extends WebTestBase { */ protected $test_ids = array(); + /** + * {@inheritdoc} + */ public static function getInfo() { return array( 'name' => 'SimpleTest functionality', @@ -76,6 +79,8 @@ class: Drupal\Core\Cache\MemoryBackendFactory $this->drupalLogin($this->drupalCreateUser(array('administer unit tests'))); } else { + // This causes three of the five fails that are asserted in + // confirmStubResults(). self::$modules = array('non_existent_module'); parent::setUp(); } @@ -211,15 +216,23 @@ function testWebTestRunner() { * Test to be run and the results confirmed. */ function stubTest() { + // The first three fails are caused by enabling a non-existent module in + // setUp(). This causes the fourth of the five fails asserted in + // confirmStubResults(). $this->pass($this->pass); + // This causes $this->fail($this->fail); + // This causes three of the ten passes asserted in confirmStubResults(). $this->drupalCreateUser(array($this->valid_permission)); + // This causes the fifth of the five fails asserted in confirmStubResults(). $this->drupalCreateUser(array($this->invalid_permission)); + // This causes the fourth of the ten passes asserted in confirmStubResults(). $this->pass(t('Test ID is @id.', array('@id' => $this->testId))); - // These four assertions are tested by asserting the right number of - // passes and failures. + + // These cause the fifth to ninth of the ten passes asserted in + // confirmStubResults(). $this->assertTrue(file_exists(conf_path() . '/settings.testing.php')); // Check the settings.testing.php file got included. $this->assertTrue(function_exists('simpletest_test_stub_settings_function')); @@ -227,15 +240,17 @@ function stubTest() { $this->assertTrue($this->container->has('site.service.yml')); $this->assertIdentical(get_class($this->container->get('cache.backend.database')), 'Drupal\Core\Cache\MemoryBackendFactory'); + // These cause the two exceptions asserted in confirmStubResults(). // Call trigger_error() without the required argument to trigger an E_WARNING. trigger_error(); - - // Call an assert function specific to that class. - $this->assertNothing(); - // Generates a warning inside a PHP function. array_key_exists(NULL, NULL); + // This causes the the tenth of the ten passes asserted in + // confirmStubResults(). + $this->assertNothing(); + + // This causes the debug message asserted in confirmStubResults(). debug('Foo', 'Debug'); } diff --git a/core/modules/simpletest/lib/Drupal/simpletest/WebTestBase.php b/core/modules/simpletest/lib/Drupal/simpletest/WebTestBase.php index 963de4a..ce4441a 100644 --- a/core/modules/simpletest/lib/Drupal/simpletest/WebTestBase.php +++ b/core/modules/simpletest/lib/Drupal/simpletest/WebTestBase.php @@ -847,7 +847,7 @@ protected function setUp() { // Allow for test-specific overrides. $settings_testing_file = DRUPAL_ROOT . '/' . $this->originalSite . '/settings.testing.php'; if (file_exists($settings_testing_file)) { - // Copy the testing-specific overrides in place. + // Copy the testing-specific settings.php overrides in place. copy($settings_testing_file, $directory . '/settings.testing.php'); // Add the name of the testing class to settings.php and include the // testing specific overrides