diff --git a/core/modules/aggregator/tests/src/Functional/AddFeedTest.php b/core/modules/aggregator/tests/src/Functional/AddFeedTest.php
index 237a7a9..bb7e348 100644
--- a/core/modules/aggregator/tests/src/Functional/AddFeedTest.php
+++ b/core/modules/aggregator/tests/src/Functional/AddFeedTest.php
@@ -23,13 +23,13 @@ public function testAddFeed() {
$feed->refreshItems();
// Check feed data.
- $this->assertUrl(\Drupal::url('aggregator.feed_add', [], ['absolute' => TRUE]));
+ $this->assertUrl(\Drupal::url('aggregator.feed_add', [], ['absolute' => TRUE]), [], 'Directed to correct URL.');
$this->assertTrue($this->uniqueFeed($feed->label(), $feed->getUrl()), 'The feed is unique.');
// Check feed source.
$this->drupalGet('aggregator/sources/' . $feed->id());
- $this->assertResponse(200);
- $this->assertText($feed->label());
+ $this->assertResponse(200, 'Feed source exists.');
+ $this->assertText($feed->label(), 'Page title');
$this->assertRaw($feed->getWebsiteUrl());
// Try to add a duplicate.
@@ -49,9 +49,9 @@ 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();
+ $this->checkForMetaRefresh();
$this->drupalGet('aggregator/sources/' . $feed->id());
$this->assertResponse(200);
@@ -84,8 +84,8 @@ public function testAddLongFeed() {
// Check feed source.
$this->drupalGet('aggregator/sources/' . $feed->id());
- $this->assertResponse(200);
- $this->assertText($feed->label());
+ $this->assertResponse(200, 'Long URL feed source exists.');
+ $this->assertText($feed->label(), 'Page title');
// Delete feeds.
$this->deleteFeed($feed);
diff --git a/core/modules/aggregator/tests/src/Functional/AggregatorAdminTest.php b/core/modules/aggregator/tests/src/Functional/AggregatorAdminTest.php
index 5ae24a0..8f37fa0 100644
--- a/core/modules/aggregator/tests/src/Functional/AggregatorAdminTest.php
+++ b/core/modules/aggregator/tests/src/Functional/AggregatorAdminTest.php
@@ -35,7 +35,7 @@ public function testSettingsPage() {
$this->assertText(t('The configuration options have been saved.'));
foreach ($edit as $name => $value) {
- $this->assertFieldByName($name, $value);
+ $this->assertFieldByName($name, $value, format_string('"@name" has correct default value.', array('@name' => $name)));
}
// Check for our test processor settings form.
@@ -46,7 +46,7 @@ public function testSettingsPage() {
);
$this->drupalPostForm('admin/config/services/aggregator/settings', $edit, t('Save configuration'));
$this->assertText(t('The configuration options have been saved.'));
- $this->assertFieldByName('dummy_length', 100);
+ $this->assertFieldByName('dummy_length', 100, '"dummy_length" has correct default value.');
// Make sure settings form is still accessible even after uninstalling a module
// that provides the selected plugins.
@@ -67,18 +67,18 @@ 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->assertEqual($feed->label(), (string) $result[0]->td[0]->a);
+ $this->assertSession()->pageTextContains($feed->label());
$count = $this->container->get('entity.manager')->getStorage('aggregator_item')->getItemCount($feed);
- $this->assertEqual(\Drupal::translation()->formatPlural($count, '1 item', '@count items'), (string) $result[0]->td[1]);
+ $this->assertSession()->pageTextContains(\Drupal::translation()->formatPlural($count, '1 item', '@count items'));
// 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->assertEqual($feed->label(), (string) $result[0]->td[0]->a);
+ $this->assertSession()->pageTextContains($feed->label());
$count = $this->container->get('entity.manager')->getStorage('aggregator_item')->getItemCount($feed);
- $this->assertEqual(\Drupal::translation()->formatPlural($count, '1 item', '@count items'), (string) $result[0]->td[1]);
+ $this->assertSession()->pageTextContains(\Drupal::translation()->formatPlural($count, '1 item', '@count items'));
}
}
diff --git a/core/modules/aggregator/tests/src/Functional/AggregatorRenderingTest.php b/core/modules/aggregator/tests/src/Functional/AggregatorRenderingTest.php
index 87117c5..bbb0c1e 100644
--- a/core/modules/aggregator/tests/src/Functional/AggregatorRenderingTest.php
+++ b/core/modules/aggregator/tests/src/Functional/AggregatorRenderingTest.php
@@ -52,7 +52,7 @@ public function testBlockLinks() {
// Confirm that the block is now being displayed on pages.
$this->drupalGet('test-page');
- $this->assertText($block->label());
+ $this->assertText($block->label(), 'Feed block is displayed on the page.');
// Confirm items appear as links.
$items = $this->container->get('entity.manager')->getStorage('aggregator_item')->loadByFeed($feed->id(), 1);
@@ -82,7 +82,7 @@ public function testBlockLinks() {
$block->save();
// Check that the block is no longer displayed.
$this->drupalGet('test-page');
- $this->assertNoText($block->label());
+ $this->assertNoText($block->label(), 'Feed block is not displayed on the page when number of items is set to 0.');
}
/**
@@ -132,10 +132,12 @@ 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.');
+// $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.');
// 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 ccf8e5b..ec9a626 100644
--- a/core/modules/aggregator/tests/src/Functional/AggregatorTestBase.php
+++ b/core/modules/aggregator/tests/src/Functional/AggregatorTestBase.php
@@ -61,7 +61,7 @@ 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]'])));
+ $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]'])));
// 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/'));
@@ -80,7 +80,7 @@ public function createFeed($feed_url = NULL, array $edit = array()) {
*/
public function deleteFeed(FeedInterface $feed) {
$this->drupalPostForm('aggregator/sources/' . $feed->id() . '/delete', array(), t('Delete'));
- $this->assertRaw(t('The feed %title has been deleted.', array('%title' => $feed->label())));
+ $this->assertRaw(t('The feed %title has been deleted.', array('%title' => $feed->label())), 'Feed deleted successfully.');
}
/**
@@ -165,7 +165,7 @@ public function getDefaultFeedItemCount() {
public function updateFeedItems(FeedInterface $feed, $expected_count = NULL) {
// First, let's ensure we can get to the rss xml.
$this->drupalGet($feed->getUrl());
- $this->assertResponse(200);
+ $this->assertResponse(200, format_string(':url is reachable.', array(':url' => $feed->getUrl())));
// Attempt to access the update link directly without an access token.
$this->drupalGet('admin/config/services/aggregator/update/' . $feed->id());
@@ -196,7 +196,7 @@ public function updateFeedItems(FeedInterface $feed, $expected_count = NULL) {
*/
public function deleteFeedItems(FeedInterface $feed) {
$this->drupalPostForm('admin/config/services/aggregator/delete/' . $feed->id(), array(), t('Delete items'));
- $this->assertRaw(t('The news items from %title have been deleted.', array('%title' => $feed->label())));
+ $this->assertRaw(t('The news items from %title have been deleted.', array('%title' => $feed->label())), 'Feed items deleted.');
}
/**
diff --git a/core/modules/aggregator/tests/src/Functional/DeleteFeedTest.php b/core/modules/aggregator/tests/src/Functional/DeleteFeedTest.php
index e7a5e52..5bf5bd3 100644
--- a/core/modules/aggregator/tests/src/Functional/DeleteFeedTest.php
+++ b/core/modules/aggregator/tests/src/Functional/DeleteFeedTest.php
@@ -40,7 +40,7 @@ public function testDeleteFeed() {
// Check feed source.
$this->drupalGet('aggregator/sources/' . $feed1->id());
- $this->assertResponse(404);
+ $this->assertResponse(404, 'Deleted feed source does not exists.');
// Check database for feed.
$result = db_query("SELECT COUNT(*) FROM {aggregator_feed} WHERE title = :title AND url = :url", array(':title' => $feed1->label(), ':url' => $feed1->getUrl()))->fetchField();
diff --git a/core/modules/aggregator/tests/src/Functional/FeedAdminDisplayTest.php b/core/modules/aggregator/tests/src/Functional/FeedAdminDisplayTest.php
index 1048763..6ae627c 100644
--- a/core/modules/aggregator/tests/src/Functional/FeedAdminDisplayTest.php
+++ b/core/modules/aggregator/tests/src/Functional/FeedAdminDisplayTest.php
@@ -17,24 +17,24 @@ public function testFeedUpdateFields() {
$scheduled_feed = $this->createFeed(NULL, array('refresh' => '900'));
$this->drupalGet('admin/config/services/aggregator');
- $this->assertResponse(200);
+ $this->assertResponse(200, 'Aggregator feed overview page exists.');
// The scheduled feed shows that it has not been updated yet and is
// scheduled.
- $this->assertText('never');
- $this->assertText('imminently');
- $this->assertNoText('ago');
- $this->assertNoText('left');
+ $this->assertText('never', 'The scheduled feed has not been updated yet. Last update shows "never".');
+ $this->assertText('imminently', 'The scheduled feed has not been updated yet. Next update shows "imminently".');
+ $this->assertNoText('ago', 'The scheduled feed has not been updated yet. Last update does not show "x x ago".');
+ $this->assertNoText('left', 'The scheduled feed has not been updated yet. Next update does not show "x x left".');
$this->updateFeedItems($scheduled_feed);
$this->drupalGet('admin/config/services/aggregator');
// After the update, an interval should be displayed on both last updated
// and next update.
- $this->assertNoText('never');
- $this->assertNoText('imminently');
- $this->assertText('ago');
- $this->assertText('left');
+ $this->assertNoText('never', 'The scheduled feed has been updated. Last updated changed.');
+ $this->assertNoText('imminently', 'The scheduled feed has been updated. Next update changed.');
+ $this->assertText('ago', 'The scheduled feed been updated. Last update shows "x x ago".');
+ $this->assertText('left', 'The scheduled feed has been updated. Next update shows "x x left".');
// Delete scheduled feed.
$this->deleteFeed($scheduled_feed);
@@ -44,20 +44,20 @@ public function testFeedUpdateFields() {
$this->drupalGet('admin/config/services/aggregator');
// The non scheduled feed shows that it has not been updated yet.
- $this->assertText('never');
- $this->assertNoText('imminently');
- $this->assertNoText('ago');
- $this->assertNoText('left');
+ $this->assertText('never', 'The non scheduled feed has not been updated yet. Last update shows "never".');
+ $this->assertNoText('imminently', 'The non scheduled feed does not show "imminently" as next update.');
+ $this->assertNoText('ago', 'The non scheduled feed has not been updated. It does not show "x x ago" as last update.');
+ $this->assertNoText('left', 'The feed is not scheduled. It does not show a timeframe "x x left" for next update.');
$this->updateFeedItems($non_scheduled_feed);
$this->drupalGet('admin/config/services/aggregator');
// After the feed update, we still need to see "never" as next update label.
// Last update will show an interval.
- $this->assertNoText('imminently');
- $this->assertText('never');
- $this->assertText('ago');
- $this->assertNoText('left');
+ $this->assertNoText('imminently', 'The updated non scheduled feed does not show "imminently" as next update.');
+ $this->assertText('never', 'The updated non scheduled feed still shows "never" as next update.');
+ $this->assertText('ago', 'The non scheduled feed has been updated. It shows "x x ago" as last update.');
+ $this->assertNoText('left', 'The feed is not scheduled. It does not show a timeframe "x x left" for next update.');
}
}
diff --git a/core/modules/aggregator/tests/src/Functional/FeedParserTest.php b/core/modules/aggregator/tests/src/Functional/FeedParserTest.php
index 65427bc..00c7b70 100644
--- a/core/modules/aggregator/tests/src/Functional/FeedParserTest.php
+++ b/core/modules/aggregator/tests/src/Functional/FeedParserTest.php
@@ -30,7 +30,7 @@ public function testRSS091Sample() {
$feed = $this->createFeed($this->getRSS091Sample());
$feed->refreshItems();
$this->drupalGet('aggregator/sources/' . $feed->id());
- $this->assertResponse(200);
+ $this->assertResponse(200, format_string('Feed %name exists.', array('%name' => $feed->label())));
$this->assertText('First example feed item title');
$this->assertLinkByHref('http://example.com/example-turns-one');
$this->assertText('First example feed item description.');
@@ -53,7 +53,7 @@ public function testAtomSample() {
$feed = $this->createFeed($this->getAtomSample());
$feed->refreshItems();
$this->drupalGet('aggregator/sources/' . $feed->id());
- $this->assertResponse(200);
+ $this->assertResponse(200, format_string('Feed %name exists.', array('%name' => $feed->label())));
$this->assertText('Atom-Powered Robots Run Amok');
$this->assertLinkByHref('http://example.org/2003/12/13/atom03');
$this->assertText('Some text.');
@@ -76,7 +76,7 @@ public function testHtmlEntitiesSample() {
$feed = $this->createFeed($this->getHtmlEntitiesSample());
$feed->refreshItems();
$this->drupalGet('aggregator/sources/' . $feed->id());
- $this->assertResponse(200);
+ $this->assertResponse(200, format_string('Feed %name exists.', array('%name' => $feed->label())));
$this->assertRaw("Quote" Amp&");
}
diff --git a/core/modules/aggregator/tests/src/Functional/ImportOpmlTest.php b/core/modules/aggregator/tests/src/Functional/ImportOpmlTest.php
index 6435472..8994e3f 100644
--- a/core/modules/aggregator/tests/src/Functional/ImportOpmlTest.php
+++ b/core/modules/aggregator/tests/src/Functional/ImportOpmlTest.php
@@ -34,10 +34,10 @@ public function openImportForm() {
$this->drupalPlaceBlock('help_block', array('region' => 'help'));
$this->drupalGet('admin/config/services/aggregator/add/opml');
- $this->assertText('A single OPML document may contain many feeds.');
- $this->assertField('files[upload]');
- $this->assertField('remote');
- $this->assertField('refresh');
+ $this->assertText('A single OPML document may contain many feeds.', 'Found OPML help text.');
+ $this->assertField('files[upload]', 'Found file upload field.');
+ $this->assertField('remote', 'Found Remote URL field.');
+ $this->assertField('refresh', '', 'Found Refresh field.');
}
/**
@@ -48,7 +48,7 @@ public function validateImportFormFields() {
$edit = array();
$this->drupalPostForm('admin/config/services/aggregator/add/opml', $edit, t('Import'));
- $this->assertRaw(t('Either upload a file or enter a URL.'));
+ $this->assertRaw(t('Either upload a file or enter a URL.'), 'Error if no fields are filled.');
$path = $this->getEmptyOpml();
$edit = array(
@@ -56,11 +56,11 @@ public function validateImportFormFields() {
'remote' => file_create_url($path),
);
$this->drupalPostForm('admin/config/services/aggregator/add/opml', $edit, t('Import'));
- $this->assertRaw(t('Either upload a file or enter a URL.'));
+ $this->assertRaw(t('Either upload a file or enter a URL.'), 'Error if both fields are filled.');
$edit = array('remote' => 'invalidUrl://empty');
$this->drupalPostForm('admin/config/services/aggregator/add/opml', $edit, t('Import'));
- $this->assertText(t('The URL invalidUrl://empty is not valid.'));
+ $this->assertText(t('The URL invalidUrl://empty is not valid.'), 'Error if the URL is invalid.');
$after = db_query('SELECT COUNT(*) FROM {aggregator_feed}')->fetchField();
$this->assertEqual($before, $after, 'No feeds were added during the three last form submissions.');
@@ -74,11 +74,11 @@ protected function submitImportForm() {
$form['files[upload]'] = $this->getInvalidOpml();
$this->drupalPostForm('admin/config/services/aggregator/add/opml', $form, t('Import'));
- $this->assertText(t('No new feed has been added.'));
+ $this->assertText(t('No new feed has been added.'), 'Attempting to upload invalid XML.');
$edit = array('remote' => file_create_url($this->getEmptyOpml()));
$this->drupalPostForm('admin/config/services/aggregator/add/opml', $edit, t('Import'));
- $this->assertText(t('No new feed has been added.'));
+ $this->assertText(t('No new feed has been added.'), 'Attempting to load empty OPML from remote URL.');
$after = db_query('SELECT COUNT(*) FROM {aggregator_feed}')->fetchField();
$this->assertEqual($before, $after, 'No feeds were added during the two last form submissions.');
@@ -93,8 +93,8 @@ protected function submitImportForm() {
'refresh' => '900',
);
$this->drupalPostForm('admin/config/services/aggregator/add/opml', $edit, t('Import'));
- $this->assertRaw(t('A feed with the URL %url already exists.', array('%url' => $feeds[0]['url[0][value]'])));
- $this->assertRaw(t('A feed named %title already exists.', array('%title' => $feeds[1]['title[0][value]'])));
+ $this->assertRaw(t('A feed with the URL %url already exists.', array('%url' => $feeds[0]['url[0][value]'])), 'Verifying that a duplicate URL was identified');
+ $this->assertRaw(t('A feed named %title already exists.', array('%title' => $feeds[1]['title[0][value]'])), 'Verifying that a duplicate title was identified');
$after = db_query('SELECT COUNT(*) FROM {aggregator_feed}')->fetchField();
$this->assertEqual($after, 2, 'Verifying that two distinct feeds were added.');
diff --git a/core/modules/aggregator/tests/src/Functional/UpdateFeedItemTest.php b/core/modules/aggregator/tests/src/Functional/UpdateFeedItemTest.php
index 3eb8daa..ba99dd0 100644
--- a/core/modules/aggregator/tests/src/Functional/UpdateFeedItemTest.php
+++ b/core/modules/aggregator/tests/src/Functional/UpdateFeedItemTest.php
@@ -1,7 +1,6 @@
assertResponse(200);
$this->drupalPostForm('aggregator/sources/add', $edit, t('Save'));
- $this->assertText(t('The feed @name has been added.', array('@name' => $edit['title[0][value]'])));
+ $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]'])));
// 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/'));
diff --git a/core/modules/aggregator/tests/src/Functional/UpdateFeedTest.php b/core/modules/aggregator/tests/src/Functional/UpdateFeedTest.php
index d045aff..bb830a5 100644
--- a/core/modules/aggregator/tests/src/Functional/UpdateFeedTest.php
+++ b/core/modules/aggregator/tests/src/Functional/UpdateFeedTest.php
@@ -24,7 +24,7 @@ public function testUpdateFeed() {
$edit[$same_field] = $feed->{$same_field}->value;
}
$this->drupalPostForm('aggregator/sources/' . $feed->id() . '/configure', $edit, t('Save'));
- $this->assertText(t('The feed @name has been updated.', array('@name' => $edit['title[0][value]'])));
+ $this->assertText(t('The feed @name has been updated.', array('@name' => $edit['title[0][value]'])), format_string('The feed %name has been updated.', 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/'));
@@ -36,8 +36,8 @@ public function testUpdateFeed() {
// Check feed source.
$this->drupalGet('aggregator/sources/' . $feed->id());
- $this->assertResponse(200);
- $this->assertText($edit['title[0][value]']);
+ $this->assertResponse(200, 'Feed source exists.');
+ $this->assertText($edit['title[0][value]'], 'Page title');
// Set correct title so deleteFeed() will work.
$feed->title = $edit['title[0][value]'];
diff --git a/core/tests/Drupal/Tests/BrowserTestBase.php b/core/tests/Drupal/Tests/BrowserTestBase.php
index 36b0b8a..e7f964a 100644
--- a/core/tests/Drupal/Tests/BrowserTestBase.php
+++ b/core/tests/Drupal/Tests/BrowserTestBase.php
@@ -232,6 +232,20 @@
protected $preserveGlobalState = FALSE;
/**
+ * The number of meta refresh redirects to follow, or NULL if unlimited.
+ *
+ * @var null|int
+ */
+ protected $maximumMetaRefreshCount = NULL;
+
+ /**
+ * The number of meta refresh redirects followed during ::drupalGet().
+ *
+ * @var int
+ */
+ protected $metaRefreshCount = 0;
+
+ /**
* Class name for HTML output logging.
*
* @var string
@@ -1715,6 +1729,28 @@ protected function cronRun() {
}
/**
+ * Checks for meta refresh tag and if found call drupalGet() recursively.
+ *
+ * This function looks for the http-equiv attribute to be set to "Refresh" and
+ * is case-sensitive.
+ *
+ * @return
+ * Either the new page content or FALSE.
+ */
+ protected function checkForMetaRefresh() {
+ $refresh = $this->cssSelect('meta[http-equiv="Refresh"]');
+ if (!empty($refresh) && (!isset($this->maximumMetaRefreshCount) || $this->metaRefreshCount < $this->maximumMetaRefreshCount)) {
+ // Parse the content attribute of the meta tag for the format:
+ // "[delay]: URL=[page_to_redirect_to]".
+ if (preg_match('/\d+;\s*URL=(?.*)/i', $refresh[0]->getAttribute('content'), $match)) {
+ $this->metaRefreshCount++;
+ return $this->drupalGet($this->getAbsoluteUrl(Html::decodeEntities($match['url'])));
+ }
+ }
+ return FALSE;
+ }
+
+ /**
* Performs an xpath search on the contents of the internal browser.
*
* The search is relative to the root element (HTML tag normally) of the page.