class AggregatorDisplayConfigurableTest
Tests aggregator_feed and aggregator_item base fields' displays.
@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 implements \PHPUnit\Framework\TestCase
- class \Drupal\Tests\aggregator\Functional\AggregatorTestBase implements \Drupal\Tests\BrowserTestBase
- class \Drupal\Tests\aggregator\Functional\AggregatorDisplayConfigurableTest implements \Drupal\Tests\aggregator\Functional\AggregatorTestBase
- class \Drupal\Tests\aggregator\Functional\AggregatorTestBase implements \Drupal\Tests\BrowserTestBase
Expanded class hierarchy of AggregatorDisplayConfigurableTest
File
-
core/
modules/ aggregator/ tests/ src/ Functional/ AggregatorDisplayConfigurableTest.php, line 14
Namespace
Drupal\Tests\aggregator\FunctionalView source
class AggregatorDisplayConfigurableTest extends AggregatorTestBase {
/**
* {@inheritdoc}
*/
protected $defaultTheme = 'classy';
/**
* {@inheritdoc}
*/
protected function setUp() : void {
parent::setUp();
$this->drupalPlaceBlock('page_title_block');
}
/**
* Tests base fields to configurable display settings.
*/
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');
}
/**
* Tests item base fields settings.
*/
public function testItemDisplayConfigurable() {
$this->createSampleNodes(1);
$item = Node::load(1);
$feed = $this->createFeed();
$this->updateFeedItems($feed);
$assert = $this->assertSession();
// Check the aggregator_feed with Drupal default non-configurable display.
$this->drupalGet('/aggregator');
$assert->elementTextContains('css', 'h3.feed-item-title', $item->label());
$assert->elementNotExists('css', '.field--name-title .field__item');
$assert->elementNotExists('css', '.field--name-title .field__label');
// Enable helper module to make base fields' displays configurable.
\Drupal::service('module_installer')->install([
'aggregator_display_configurable_test',
]);
// Recheck the aggregator_feed with configurable display.
$this->drupalGet('/aggregator');
$assert->elementNotExists('css', 'h3.feed-item-title');
$assert->elementTextContains('css', 'div.field--name-title > div.field__item', $item->label());
}
}
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.