function MediaLibrarySetAdministrativePageToTableDisplayTest::testUpdateWithCustomizedMediaViewMenuSettings

Tests that the update does not alter custom 'media' view menu settings.

File

core/modules/media_library/tests/src/Functional/Update/MediaLibrarySetAdministrativePageToTableDisplayTest.php, line 82

Class

MediaLibrarySetAdministrativePageToTableDisplayTest
Tests update to set 'media' view's table display as the administrative page.

Namespace

Drupal\Tests\media_library\Functional\Update

Code

public function testUpdateWithCustomizedMediaViewMenuSettings() {
    
    /** @var \Drupal\views\ViewEntityInterface $view */
    $view = View::load('media');
    $display =& $view->getDisplay('media_page_list');
    $display['display_options']['menu'] = [
        'type' => 'normal',
        'title' => 'All media',
        'parent' => 'system.admin_structure',
    ];
    $view->save();
    $this->runUpdates();
    // The update should not have modified the path.
    $view = View::load('media');
    $display = $view->getDisplay('media_page_list');
    $this->assertSame('admin/content/media', $display['display_options']['path']);
    $this->assertSame('normal', $display['display_options']['menu']['type']);
    $this->assertSame('All media', $display['display_options']['menu']['title']);
    $this->assertSame('system.admin_structure', $display['display_options']['menu']['parent']);
    $view = View::load('media_library');
    $display = $view->getDisplay('page');
    $this->assertSame('admin/content/media-grid', $display['display_options']['path']);
    $this->assertArrayNotHasKey('menu', $display['display_options']);
}

Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.