diff --git a/core/modules/aggregator/tests/src/Functional/AddFeedTest.php b/core/modules/aggregator/tests/src/Functional/AddFeedTest.php
index bb7e348..90fff77 100644
--- a/core/modules/aggregator/tests/src/Functional/AddFeedTest.php
+++ b/core/modules/aggregator/tests/src/Functional/AddFeedTest.php
@@ -49,7 +49,7 @@ public function testAddFeed() {
/**
* Ensures that the feed label is escaping when rendering the feed icon.
*/
- public function _testFeedLabelEscaping() {
+ public function testFeedLabelEscaping() {
$feed = $this->createFeed(NULL, ['title[0][value]' => 'Test feed title ']);
$this->checkForMetaRefresh();
@@ -60,7 +60,7 @@ public function _testFeedLabelEscaping() {
$this->assertNoRaw('Test feed title ');
// Ensure the feed icon title is escaped.
- $this->assertTrue(strpos(str_replace(["\n", "\r"], '', $this->getTextContent()), 'class="feed-icon"> Subscribe to Test feed title <script>alert(123);</script> feed') !== FALSE);
+ $this->assertTrue(strpos(str_replace(["\n", "\r"], '', $this->getRawContent()), 'class="feed-icon"> Subscribe to Test feed title <script>alert(123);</script> feed') !== FALSE);
}
/**
diff --git a/core/modules/aggregator/tests/src/Functional/AggregatorAdminTest.php b/core/modules/aggregator/tests/src/Functional/AggregatorAdminTest.php
index 8f37fa0..329dee1 100644
--- a/core/modules/aggregator/tests/src/Functional/AggregatorAdminTest.php
+++ b/core/modules/aggregator/tests/src/Functional/AggregatorAdminTest.php
@@ -67,18 +67,21 @@ function testOverviewPage() {
// Check if the amount of feeds in the overview matches the amount created.
$this->assertEqual(1, count($result), 'Created feed is found in the overview');
// Check if the fields in the table match with what's expected.
- $this->assertSession()->pageTextContains($feed->label());
+ $link = $this->xpath('//table/tbody/tr//td[1]/a');
+ $this->assertEqual($feed->label(), $link[0]->getText());
$count = $this->container->get('entity.manager')->getStorage('aggregator_item')->getItemCount($feed);
- $this->assertSession()->pageTextContains(\Drupal::translation()->formatPlural($count, '1 item', '@count items'));
+ $td = $this->xpath('//table/tbody/tr//td[2]');
+ $this->assertEqual(\Drupal::translation()->formatPlural($count, '1 item', '@count items'), $td[0]->getText());
// Update the items of the first feed.
$feed->refreshItems();
$this->drupalGet('admin/config/services/aggregator');
- $result = $this->xpath('//table/tbody/tr');
// Check if the fields in the table match with what's expected.
- $this->assertSession()->pageTextContains($feed->label());
+ $link = $this->xpath('//table/tbody/tr//td[1]/a');
+ $this->assertEqual($feed->label(), $link[0]->getText());
$count = $this->container->get('entity.manager')->getStorage('aggregator_item')->getItemCount($feed);
- $this->assertSession()->pageTextContains(\Drupal::translation()->formatPlural($count, '1 item', '@count items'));
+ $td = $this->xpath('//table/tbody/tr//td[2]');
+ $this->assertEqual(\Drupal::translation()->formatPlural($count, '1 item', '@count items'), $td[0]->getText());
}
}
diff --git a/core/modules/aggregator/tests/src/Functional/AggregatorRenderingTest.php b/core/modules/aggregator/tests/src/Functional/AggregatorRenderingTest.php
index bbb0c1e..aa48927 100644
--- a/core/modules/aggregator/tests/src/Functional/AggregatorRenderingTest.php
+++ b/core/modules/aggregator/tests/src/Functional/AggregatorRenderingTest.php
@@ -132,12 +132,11 @@ public function testFeedPage() {
// Check the opml aggregator page.
$this->drupalGet('aggregator/opml');
- // @todo Find better way to handle this.
- // Can't do this see http://stackoverflow.com/a/17081317/1177774.
- $outline = $this->xpath('//outline[1]');
-// $this->assertEqual($outline[0]['type'], 'rss', 'The correct type attribute is used for rss OPML.');
-// $this->assertEqual($outline[0]['text'], $feed->label(), 'The correct text attribute is used for rss OPML.');
-// $this->assertEqual($outline[0]['xmlurl'], $feed->getUrl(), 'The correct xmlUrl attribute is used for rss OPML.');
+ $xml = simplexml_load_string($this->getRawContent());
+ $attributes = $xml->xpath('//outline[1]')[0]->attributes();
+ self::assertEquals($attributes->type, 'rss');
+ self::assertEquals($attributes->text, $feed->label());
+ self::assertEquals($attributes->xmlUrl, $feed->getUrl());
// Check for the presence of a pager.
$this->drupalGet('aggregator/sources/' . $feed->id());
diff --git a/core/modules/aggregator/tests/src/Functional/AggregatorTestBase.php b/core/modules/aggregator/tests/src/Functional/AggregatorTestBase.php
index ec9a626..c271fc7 100644
--- a/core/modules/aggregator/tests/src/Functional/AggregatorTestBase.php
+++ b/core/modules/aggregator/tests/src/Functional/AggregatorTestBase.php
@@ -61,11 +61,11 @@ protected function setUp() {
public function createFeed($feed_url = NULL, array $edit = array()) {
$edit = $this->getFeedEditArray($feed_url, $edit);
$this->drupalPostForm('aggregator/sources/add', $edit, t('Save'));
- $this->assertText(t('The feed @name has been added.', array('@name' => $edit['title[0][value]'])), format_string('The feed @name has been added.', array('@name' => $edit['title[0][value]'])));
+ $this->assertText(t("The feed {$edit['title[0][value]']} has been added."), format_string('The feed @name has been added.', array('@name' => $edit['title[0][value]'])));
// Verify that the creation message contains a link to a feed.
$view_link = $this->xpath('//div[@class="messages"]//a[contains(@href, :href)]', array(':href' => 'aggregator/sources/'));
- $this->assertTrue(isset($view_link), 'The message area contains a link to a feed');
+ $this->assert(isset($view_link), 'The message area contains a link to a feed');
$fid = db_query("SELECT fid FROM {aggregator_feed} WHERE title = :title AND url = :url", array(':title' => $edit['title[0][value]'], ':url' => $edit['url[0][value]']))->fetchField();
$this->assertTrue(!empty($fid), 'The feed found in database.');
diff --git a/core/tests/Drupal/Tests/BrowserTestBase.php b/core/tests/Drupal/Tests/BrowserTestBase.php
index 53db896..4cecbb8 100644
--- a/core/tests/Drupal/Tests/BrowserTestBase.php
+++ b/core/tests/Drupal/Tests/BrowserTestBase.php
@@ -1594,10 +1594,19 @@ protected function getTextContent() {
}
/**
+ * Retrieves the raw content from the current page.
+ */
+ protected function getRawContent() {
+ return $this->getSession()->getPage()->getContent();
+ }
+
+ /**
* Runs cron.
*/
protected function cronRun() {
- $this->drupalGet('cron/' . \Drupal::state()->get('system.cron_key'));
+ /** @var \Drupal\Core\State\StateInterface $state */
+ $state = $this->container->get('state');
+ $this->drupalGet("cron/{$state->get('system.cron_key')}");
}
/**
@@ -1606,7 +1615,7 @@ protected function cronRun() {
* This function looks for the http-equiv attribute to be set to "Refresh" and
* is case-sensitive.
*
- * @return
+ * @return string|false
* Either the new page content or FALSE.
*/
protected function checkForMetaRefresh() {