3 namespace Drupal\views\Tests\Plugin;
6 * Tests the OPML feed style plugin.
9 * @see \Drupal\views\Plugin\views\style\Opml
11 class StyleOpmlTest extends PluginTestBase {
14 * Views used by this test.
18 public static $testViews = ['test_style_opml'];
25 public static $modules = ['aggregator'];
30 protected function setUp() {
33 $this->enableViewsTestModule();
35 $admin_user = $this->drupalCreateUser(['administer news feeds']);
36 $this->drupalLogin($admin_user);
40 * Tests the rendered output.
42 public function testOpmlOutput() {
43 // Create a test feed.
45 'title' => $this->randomMachineName(10),
46 'url' => 'http://example.com/rss.xml',
49 $feed = $this->container->get('entity.manager')
50 ->getStorage('aggregator_feed')
54 $this->drupalGet('test-feed-opml-style');
55 $outline = $this->xpath('//outline[1]');
56 $this->assertEqual($outline[0]['type'], 'rss', 'The correct type attribute is used for rss OPML.');
57 $this->assertEqual($outline[0]['text'], $feed->label(), 'The correct text attribute is used for rss OPML.');
58 $this->assertEqual($outline[0]['xmlurl'], $feed->getUrl(), 'The correct xmlUrl attribute is used for rss OPML.');
60 $view = $this->container->get('entity.manager')
62 ->load('test_style_opml');
63 $display = &$view->getDisplay('feed_1');
64 $display['display_options']['row']['options']['type_field'] = 'link';
65 $display['display_options']['row']['options']['url_field'] = 'url';
68 $this->drupalGet('test-feed-opml-style');
69 $outline = $this->xpath('//outline[1]');
70 $this->assertEqual($outline[0]['type'], 'link', 'The correct type attribute is used for link OPML.');
71 $this->assertEqual($outline[0]['text'], $feed->label(), 'The correct text attribute is used for link OPML.');
72 $this->assertEqual($outline[0]['url'], $feed->getUrl(), 'The correct URL attribute is used for link OPML.');
73 // xmlUrl should not be present when type is link.
74 $this->assertNull($outline[0]['xmlUrl'], 'The xmlUrl attribute is not used for link OPML.');