function ViewsConfigUpdaterTest::testUpdateRssViewModeWithoutKnownPreviousModeOnSaveHandler

Tests if onSave also updates the view.

File

core/modules/views/tests/src/Kernel/ViewsConfigUpdaterTest.php, line 103

Class

ViewsConfigUpdaterTest
Tests Drupal\views\ViewsConfigUpdater.

Namespace

Drupal\Tests\views\Kernel

Code

public function testUpdateRssViewModeWithoutKnownPreviousModeOnSaveHandler() : void {
  $this->installEntitySchema('node');
  $this->installConfig([
    'text',
    'field',
    'node',
  ]);
  $this->strictConfigSchema = FALSE;
  // 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);
  $test_view->save();
  // Assert if the view mode was updated correctly onSave.
  $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.