View source
<?php
namespace Drupal\Tests\media_library\Functional\Update;
use Drupal\FunctionalTests\Update\UpdatePathTestBase;
use Drupal\views\Entity\View;
class MediaLibrarySetAdministrativePageToTableDisplayTest extends UpdatePathTestBase {
public function setDatabaseDumpFiles() {
$this->databaseDumpFiles = [
__DIR__ . '/../../../../../system/tests/fixtures/update/drupal-8.4.0.bare.standard.php.gz',
__DIR__ . '/../../../../../media/tests/fixtures/update/drupal-8.4.0-media_installed.php',
__DIR__ . '/../../../fixtures/update/drupal-8.7.2-media_library_installed.php',
];
}
public function testUpdateWithoutCustomizations() {
$view = View::load('media');
$display = $view
->getDisplay('media_page_list');
$this
->assertSame('admin/content/media-table', $display['display_options']['path']);
$this
->assertArrayNotHasKey('menu', $display['display_options']);
$view = View::load('media_library');
$display = $view
->getDisplay('page');
$this
->assertSame('admin/content/media', $display['display_options']['path']);
$this
->assertSame('tab', $display['display_options']['menu']['type']);
$this
->assertSame('Media', $display['display_options']['menu']['title']);
$this
->runUpdates();
$view = View::load('media');
$display = $view
->getDisplay('media_page_list');
$this
->assertSame('admin/content/media', $display['display_options']['path']);
$this
->assertArrayNotHasKey('menu', $display['display_options']);
$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']);
}
public function testUpdateWithCustomizedMediaViewPath() {
$view = View::load('media');
$display =& $view
->getDisplay('media_page_list');
$display['display_options']['path'] = 'admin/content/all-media';
$view
->save();
$this
->runUpdates();
$view = View::load('media');
$display = $view
->getDisplay('media_page_list');
$this
->assertSame('admin/content/all-media', $display['display_options']['path']);
$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']);
}
public function testUpdateWithCustomizedMediaViewMenuSettings() {
$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();
$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']);
}
public function testUpdateWithCustomizedMediaLibraryViewPath() {
$view = View::load('media_library');
$display =& $view
->getDisplay('page');
$display['display_options']['path'] = 'admin/content/media-pretty';
$view
->save();
$this
->runUpdates();
$view = View::load('media_library');
$display = $view
->getDisplay('page');
$this
->assertSame('admin/content/media-pretty', $display['display_options']['path']);
$this
->assertSame('tab', $display['display_options']['menu']['type']);
$this
->assertSame('Media', $display['display_options']['menu']['title']);
}
public function testUpdateWithCustomizedMediaLibraryMenuSettings() {
$view = View::load('media_library');
$display =& $view
->getDisplay('page');
$display['display_options']['menu'] = [
'type' => 'normal',
'title' => 'A treasure trove of interesting pictures',
'parent' => 'system.admin_structure',
];
$view
->save();
$this
->runUpdates();
$view = View::load('media_library');
$display = $view
->getDisplay('page');
$this
->assertSame('admin/content/media-grid', $display['display_options']['path']);
$this
->assertSame('normal', $display['display_options']['menu']['type']);
$this
->assertSame('A treasure trove of interesting pictures', $display['display_options']['menu']['title']);
$this
->assertSame('system.admin_structure', $display['display_options']['menu']['parent']);
}
}