function ViewsConfigUpdaterTest::testUpdateRssViewModeWithoutKnownPreviousMode
Tests the `needsRssViewModeUpdate` method.
File
-
core/
modules/ views/ tests/ src/ Kernel/ ViewsConfigUpdaterTest.php, line 71
Class
Namespace
Drupal\Tests\views\KernelCode
public function testUpdateRssViewModeWithoutKnownPreviousMode() : void {
$this->installEntitySchema('node');
$this->installConfig([
'text',
'field',
'node',
]);
$this->strictConfigSchema = FALSE;
/** @var \Drupal\views\ViewsConfigUpdater $view_config_updater */
$view_config_updater = \Drupal::classResolver(ViewsConfigUpdater::class);
// Load the test view.
$view_id = 'views.view.test_display_feed';
$test_view = $this->loadTestView($view_id);
$display = $test_view->getDisplay('feed_1');
// Check the initial view mode.
$rowViewMode = $display['display_options']['row']['options']['view_mode'] ?? FALSE;
$this->assertEquals('default', $rowViewMode);
// Update the view mode using the method under test.
$view_config_updater->needsRssViewModeUpdate($test_view);
// Assert if the view mode was updated correctly.
$display = $test_view->getDisplay('feed_1');
$updatedRowViewMode = $display['display_options']['row']['options']['view_mode'] ?? FALSE;
// This should be the first node view mode since we have nothing else
$this->assertEquals('rss', $updatedRowViewMode);
}
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.