function AggregatorDisplayConfigurableTest::testFeedDisplayConfigurable
Same name in other branches
- 9 core/modules/aggregator/tests/src/Functional/AggregatorDisplayConfigurableTest.php \Drupal\Tests\aggregator\Functional\AggregatorDisplayConfigurableTest::testFeedDisplayConfigurable()
Sets feed base fields to configurable display and checks settings are respected.
File
-
core/
modules/ aggregator/ tests/ src/ Functional/ AggregatorDisplayConfigurableTest.php, line 34
Class
- AggregatorDisplayConfigurableTest
- Tests making aggregator_feed and aggregator_item base fields' displays configurable.
Namespace
Drupal\Tests\aggregator\FunctionalCode
public function testFeedDisplayConfigurable() {
$display = EntityViewDisplay::load('aggregator_feed.aggregator_feed.summary');
$display->setComponent('description', [
'region' => 'content',
])
->setComponent('items', [
'region' => 'hidden',
])
->save();
$feed = $this->createFeed($this->getRSS091Sample());
$feed->refreshItems();
$assert = $this->assertSession();
// Check the aggregator_feed with Drupal default non-configurable display.
$this->drupalGet('/aggregator/sources');
$assert->elementTextContains('css', 'div.aggregator-feed > h2', $feed->label());
$assert->elementTextContains('css', 'div.feed-description', $feed->getDescription());
$assert->elementNotExists('css', '.field--name-title');
$assert->elementNotExists('css', '.field--name-description');
// Enable helper module to make base fields' displays configurable.
\Drupal::service('module_installer')->install([
'aggregator_display_configurable_test',
]);
// Configure display.
$display->setComponent('title', [
'type' => 'text_default',
'label' => 'above',
]);
$display->setComponent('description', [
'type' => 'aggregator_xss',
'label' => 'hidden',
])
->save();
// Recheck the aggregator_feed with configurable display.
$this->drupalGet('/aggregator/sources');
$assert->elementTextContains('css', 'div.aggregator-feed > div.field--name-title > div.field__item', $feed->label());
$assert->elementExists('css', 'div.field--name-title > div.field__label');
$assert->elementTextContains('css', 'div.field--name-description.field__item', $feed->getDescription());
// Remove 'title' field from display.
$display->removeComponent('title')
->save();
// Recheck the aggregator_feed with 'title' field removed from display.
$this->drupalGet('/aggregator/sources');
$assert->elementNotExists('css', 'div.aggregator-feed > div.field--name-title');
}
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.