class StyleOpmlTest
Same name and namespace in other branches
- 8.9.x core/modules/views/tests/src/Functional/Plugin/StyleOpmlTest.php \Drupal\Tests\views\Functional\Plugin\StyleOpmlTest
Tests the OPML feed style plugin.
@group aggregator @group legacy
Hierarchy
- class \Drupal\Tests\BrowserTestBase uses \Drupal\Core\Test\FunctionalTestSetupTrait, \Drupal\Tests\UiHelperTrait, \Drupal\Core\Test\TestSetupTrait, \Drupal\Tests\block\Traits\BlockCreationTrait, \Drupal\FunctionalTests\AssertLegacyTrait, \Drupal\Tests\RandomGeneratorTrait, \Drupal\Tests\node\Traits\NodeCreationTrait, \Drupal\Tests\node\Traits\ContentTypeCreationTrait, \Drupal\Tests\ConfigTestTrait, \Drupal\Tests\TestRequirementsTrait, \Drupal\Tests\user\Traits\UserCreationTrait, \Drupal\Tests\XdebugRequestTrait, \Drupal\Tests\Traits\PhpUnitWarnings, \Drupal\Tests\PhpUnitCompatibilityTrait, \Symfony\Bridge\PhpUnit\ExpectDeprecationTrait, \Drupal\Tests\ExtensionListTestTrait extends \PHPUnit\Framework\TestCase
- class \Drupal\Tests\views\Functional\ViewTestBase uses \Drupal\views\Tests\ViewResultAssertionTrait extends \Drupal\Tests\BrowserTestBase
- class \Drupal\Tests\aggregator\Functional\Views\Plugin\StyleOpmlTest extends \Drupal\Tests\views\Functional\ViewTestBase
- class \Drupal\Tests\views\Functional\ViewTestBase uses \Drupal\views\Tests\ViewResultAssertionTrait extends \Drupal\Tests\BrowserTestBase
Expanded class hierarchy of StyleOpmlTest
See also
\Drupal\views\Plugin\views\style\Opml
File
-
core/
modules/ aggregator/ tests/ src/ Functional/ Views/ Plugin/ StyleOpmlTest.php, line 14
Namespace
Drupal\Tests\aggregator\Functional\Views\PluginView source
class StyleOpmlTest extends ViewTestBase {
/**
* Views used by this test.
*
* @var array
*/
public static $testViews = [
'test_aggregator_style_opml',
];
/**
* Modules to enable.
*
* @var array
*/
protected static $modules = [
'aggregator',
'aggregator_test_views',
];
/**
* {@inheritdoc}
*/
protected $defaultTheme = 'stark';
/**
* {@inheritdoc}
*/
protected function setUp($import_test_views = TRUE, $modules = [
'aggregator_test_views',
]) : void {
parent::setUp($import_test_views, $modules);
$admin_user = $this->drupalCreateUser([
'administer news feeds',
]);
$this->drupalLogin($admin_user);
}
/**
* Tests the rendered output.
*/
public function testOpmlOutput() {
// Create a test feed.
$values = [
'title' => $this->randomMachineName(10),
'url' => 'http://example.com/rss.xml',
'refresh' => '900',
];
$feed = $this->container
->get('entity_type.manager')
->getStorage('aggregator_feed')
->create($values);
$feed->save();
$this->drupalGet('test-feed-opml-style');
$outline = $this->getSession()
->getDriver()
->find('//outline[1]')[0];
$this->assertEquals('rss', $outline->getAttribute('type'));
$this->assertEquals($feed->label(), $outline->getAttribute('text'));
$this->assertEquals($feed->getUrl(), $outline->getAttribute('xmlUrl'));
$view = $this->container
->get('entity_type.manager')
->getStorage('view')
->load('test_aggregator_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->getSession()
->getDriver()
->find('//outline[1]')[0];
$this->assertEquals('link', $outline->getAttribute('type'));
$this->assertEquals($feed->label(), $outline->getAttribute('text'));
$this->assertEquals($feed->getUrl(), $outline->getAttribute('url'));
// xmlUrl should not be present when type is link.
$this->assertNull($outline->getAttribute('xmlUrl'));
}
}
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.