Commit f62b4c76 authored by catch's avatar catch

Issue #2757023 by claudiu.cristea, naveenvalecha, GoZ, jibran, Jo Fitzgerald,...

Issue #2757023 by claudiu.cristea, naveenvalecha, GoZ, jibran, Jo Fitzgerald, dawehner, klausi: Convert all aggregator web tests to BrowserTestBase
parent 9dfbd47a
<?php <?php
namespace Drupal\aggregator\Tests; namespace Drupal\Tests\aggregator\Functional;
/** /**
* Add feed test. * Add feed test.
......
<?php <?php
namespace Drupal\aggregator\Tests; namespace Drupal\Tests\aggregator\Functional;
/** /**
* Tests aggregator admin pages. * Tests aggregator admin pages.
...@@ -67,18 +67,22 @@ public function testOverviewPage() { ...@@ -67,18 +67,22 @@ public function testOverviewPage() {
// Check if the amount of feeds in the overview matches the amount created. // 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'); $this->assertEqual(1, count($result), 'Created feed is found in the overview');
// Check if the fields in the table match with what's expected. // Check if the fields in the table match with what's expected.
$this->assertEqual($feed->label(), (string) $result[0]->td[0]->a); $link = $this->xpath('//table/tbody/tr//td[1]/a');
$this->assertEquals($feed->label(), $link[0]->getText());
$count = $this->container->get('entity.manager')->getStorage('aggregator_item')->getItemCount($feed); $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]); $td = $this->xpath('//table/tbody/tr//td[2]');
$this->assertEquals(\Drupal::translation()->formatPlural($count, '1 item', '@count items'), $td[0]->getText());
// Update the items of the first feed. // Update the items of the first feed.
$feed->refreshItems(); $feed->refreshItems();
$this->drupalGet('admin/config/services/aggregator'); $this->drupalGet('admin/config/services/aggregator');
$result = $this->xpath('//table/tbody/tr'); $result = $this->xpath('//table/tbody/tr');
// Check if the fields in the table match with what's expected. // Check if the fields in the table match with what's expected.
$this->assertEqual($feed->label(), (string) $result[0]->td[0]->a); $link = $this->xpath('//table/tbody/tr//td[1]/a');
$this->assertEquals($feed->label(), $link[0]->getText());
$count = $this->container->get('entity.manager')->getStorage('aggregator_item')->getItemCount($feed); $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]); $td = $this->xpath('//table/tbody/tr//td[2]');
$this->assertEquals(\Drupal::translation()->formatPlural($count, '1 item', '@count items'), $td[0]->getText());
} }
} }
<?php <?php
namespace Drupal\aggregator\Tests; namespace Drupal\Tests\aggregator\Functional;
use Drupal\Tests\Traits\Core\CronRunTrait;
/** /**
* Update feeds on cron. * Update feeds on cron.
...@@ -8,6 +10,9 @@ ...@@ -8,6 +10,9 @@
* @group aggregator * @group aggregator
*/ */
class AggregatorCronTest extends AggregatorTestBase { class AggregatorCronTest extends AggregatorTestBase {
use CronRunTrait;
/** /**
* Adds feeds and updates them via cron process. * Adds feeds and updates them via cron process.
*/ */
......
<?php <?php
namespace Drupal\aggregator\Tests; namespace Drupal\Tests\aggregator\Functional;
use Drupal\Component\Utility\SafeMarkup; use Drupal\Component\Utility\SafeMarkup;
use Drupal\views\Entity\View; use Drupal\views\Entity\View;
...@@ -132,10 +132,14 @@ public function testFeedPage() { ...@@ -132,10 +132,14 @@ public function testFeedPage() {
// Check the opml aggregator page. // Check the opml aggregator page.
$this->drupalGet('aggregator/opml'); $this->drupalGet('aggregator/opml');
$outline = $this->xpath('//outline[1]'); $content = $this->getSession()->getPage()->getContent();
$this->assertEqual($outline[0]['type'], 'rss', 'The correct type attribute is used for rss OPML.'); // We can't use Mink xpath queries here because it only supports HTML pages,
$this->assertEqual($outline[0]['text'], $feed->label(), 'The correct text attribute is used for rss OPML.'); // but we are dealing with XML here.
$this->assertEqual($outline[0]['xmlurl'], $feed->getUrl(), 'The correct xmlUrl attribute is used for rss OPML.'); $xml = simplexml_load_string($content);
$attributes = $xml->xpath('//outline[1]')[0]->attributes();
$this->assertEquals('rss', $attributes->type);
$this->assertEquals($feed->label(), $attributes->text);
$this->assertEquals($feed->getUrl(), $attributes->xmlUrl);
// Check for the presence of a pager. // Check for the presence of a pager.
$this->drupalGet('aggregator/sources/' . $feed->id()); $this->drupalGet('aggregator/sources/' . $feed->id());
......
<?php <?php
namespace Drupal\aggregator\Tests; namespace Drupal\Tests\aggregator\Functional;
/** /**
* Tests the display of a feed on the Aggregator list page. * Tests the display of a feed on the Aggregator list page.
......
<?php <?php
namespace Drupal\aggregator\Tests; namespace Drupal\Tests\aggregator\Functional;
use Drupal\language\Entity\ConfigurableLanguage; use Drupal\language\Entity\ConfigurableLanguage;
use Drupal\Tests\Traits\Core\CronRunTrait;
/** /**
* Tests aggregator feeds in multiple languages. * Tests aggregator feeds in multiple languages.
...@@ -11,6 +12,8 @@ ...@@ -11,6 +12,8 @@
*/ */
class FeedLanguageTest extends AggregatorTestBase { class FeedLanguageTest extends AggregatorTestBase {
use CronRunTrait;
/** /**
* Modules to install. * Modules to install.
* *
......
<?php <?php
namespace Drupal\aggregator\Tests; namespace Drupal\Tests\aggregator\Functional;
use Drupal\aggregator\Entity\Feed; use Drupal\aggregator\Entity\Feed;
/** /**
......
<?php <?php
namespace Drupal\aggregator\Tests; namespace Drupal\Tests\aggregator\Functional;
/** /**
* Update feed test. * Update feed test.
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment