diff --git a/core/modules/aggregator/lib/Drupal/aggregator/Tests/AggregatorTestBase.php b/core/modules/aggregator/lib/Drupal/aggregator/Tests/AggregatorTestBase.php index e900025..e5f13f9 100644 --- a/core/modules/aggregator/lib/Drupal/aggregator/Tests/AggregatorTestBase.php +++ b/core/modules/aggregator/lib/Drupal/aggregator/Tests/AggregatorTestBase.php @@ -56,7 +56,11 @@ function createFeed($feed_url = NULL, array $edit = array()) { $this->drupalPostForm('aggregator/sources/add', $edit, t('Save')); $this->assertRaw(t('The feed %name has been added.', array('%name' => $edit['title'])), format_string('The feed !name has been added.', array('!name' => $edit['title']))); - $fid = db_query("SELECT fid FROM {aggregator_feed} WHERE title = :title AND url = :url", array(':title' => $edit['title'], ':url' => $edit['url']))->fetchField(); + $fids = \Drupal::entityQuery('aggregator_feed') + ->condition('title', $edit['title']) + ->condition('url', $edit['url']) + ->execute(); + $fid = reset($fids); $this->assertTrue(!empty($fid), 'The feed found in database.'); return aggregator_feed_load($fid); } @@ -165,10 +169,11 @@ function updateFeedItems(FeedInterface $feed, $expected_count = NULL) { $this->clickLink('Update items'); // Ensure we have the right number of items. - $result = db_query('SELECT iid FROM {aggregator_item} WHERE fid = :fid', array(':fid' => $feed->id())); - $feed->items = array(); - foreach ($result as $item) { - $feed->items[] = $item->iid; + $iids = \Drupal::entityQuery('aggregator_item') + ->condition('fid', $feed->id()) + ->execute(); + foreach ($iids as $iid) { + $feed->items[] = $iid; } if ($expected_count !== NULL) { @@ -217,7 +222,11 @@ function updateAndDelete(FeedInterface $feed, $expected_count) { * TRUE if feed is unique. */ function uniqueFeed($feed_name, $feed_url) { - $result = db_query("SELECT COUNT(*) FROM {aggregator_feed} WHERE title = :title AND url = :url", array(':title' => $feed_name, ':url' => $feed_url))->fetchField(); + $result = \Drupal::entityQuery('aggregator_feed') + ->condition('title', $feed_name) + ->condition('url', $feed_url) + ->count() + ->execute(); return (1 == $result); } diff --git a/core/modules/simpletest/lib/Drupal/simpletest/WebTestBase.php b/core/modules/simpletest/lib/Drupal/simpletest/WebTestBase.php index 61c54d1..c93cbaf 100644 --- a/core/modules/simpletest/lib/Drupal/simpletest/WebTestBase.php +++ b/core/modules/simpletest/lib/Drupal/simpletest/WebTestBase.php @@ -775,7 +775,8 @@ protected function setUp() { // Copy and prepare an actual settings.php, so as to resemble a regular // installation. // Not using File API; a potential error must trigger a PHP warning. - copy(DRUPAL_ROOT . '/sites/default/default.settings.php', DRUPAL_ROOT . '/' . $this->siteDirectory . '/settings.php'); + $directory = DRUPAL_ROOT . '/' . $this->siteDirectory; + copy(DRUPAL_ROOT . '/sites/default/default.settings.php', $directory . '/settings.php'); // All file system paths are created by System module during installation. // @see system_requirements() @@ -808,6 +809,21 @@ protected function setUp() { // Execute the non-interactive installer. require_once DRUPAL_ROOT . '/core/includes/install.core.inc'; install_drupal($parameters); + if (file_exists(DRUPAL_ROOT . '/sites/default/settings.testing.php')) { + // Install made settings.php and the containing directory read-only, + // make them writeable again. + drupal_verify_install_file($directory, FILE_WRITABLE, 'dir'); + drupal_verify_install_file($directory . '/settings.php', FILE_WRITABLE); + // Copy the testing specific overrides in place. + copy(DRUPAL_ROOT . '/sites/default/settings.testing.php', $directory . '/settings.testing.php'); + // Add the name of the testing class to settings.php and include the + // testing specific overrides + file_put_contents($directory . '/settings.php', "\n\$test_class = '" . get_class($this) ."';\n" . 'include DRUPAL_ROOT . \'/\' . $conf_path . \'/settings.testing.php\';' ."\n", FILE_APPEND); + // Make the files secure again. + drupal_verify_install_file($directory . '/settings.php', FILE_NOT_WRITABLE); + drupal_verify_install_file($directory . '/settings.testing.php', FILE_NOT_WRITABLE); + drupal_verify_install_file($directory, FILE_NOT_WRITABLE, 'dir'); + } // Import new settings.php written by the installer. drupal_settings_initialize(); @@ -821,7 +837,7 @@ protected function setUp() { // directory has to be writable. // TestBase::restoreEnvironment() will delete the entire site directory. // Not using File API; a potential error must trigger a PHP warning. - chmod(DRUPAL_ROOT . '/' . $this->siteDirectory, 0777); + chmod($directory, 0777); $this->rebuildContainer();