You are here

public function StyleOpmlTest::testOpmlOutput in Zircon Profile 8

Same name and namespace in other branches
  1. 8.0 core/modules/views/src/Tests/Plugin/StyleOpmlTest.php \Drupal\views\Tests\Plugin\StyleOpmlTest::testOpmlOutput()

Tests the rendered output.

File

core/modules/views/src/Tests/Plugin/StyleOpmlTest.php, line 47
Contains \Drupal\views\Tests\Plugin\StyleOpmlTest.

Class

StyleOpmlTest
Tests the OPML feed style plugin.

Namespace

Drupal\views\Tests\Plugin

Code

public function testOpmlOutput() {

  // Create a test feed.
  $values = array(
    'title' => $this
      ->randomMachineName(10),
    'url' => 'http://example.com/rss.xml',
    'refresh' => '900',
  );
  $feed = $this->container
    ->get('entity.manager')
    ->getStorage('aggregator_feed')
    ->create($values);
  $feed
    ->save();
  $this
    ->drupalGet('test-feed-opml-style');
  $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.');
  $view = $this->container
    ->get('entity.manager')
    ->getStorage('view')
    ->load('test_style_opml');
  $display =& $view
    ->getDisplay('feed_1');
  $display['display_options']['row']['options']['type_field'] = 'link';
  $display['display_options']['row']['options']['url_field'] = 'url';
  $view
    ->save();
  $this
    ->drupalGet('test-feed-opml-style');
  $outline = $this
    ->xpath('//outline[1]');
  $this
    ->assertEqual($outline[0]['type'], 'link', 'The correct type attribute is used for link OPML.');
  $this
    ->assertEqual($outline[0]['text'], $feed
    ->label(), 'The correct text attribute is used for link OPML.');
  $this
    ->assertEqual($outline[0]['url'], $feed
    ->getUrl(), 'The correct url attribute is used for link OPML.');

  // xmlUrl should not be present when type is link.
  $this
    ->assertNull($outline[0]['xmlUrl'], 'The xmlUrl attribute is not used for link OPML.');
}