Commit ac4b5c7f authored by alexpott's avatar alexpott

Issue #2723585 by danielmrichards, valthebald, John Cook: Remove entity_load*...

Issue #2723585 by danielmrichards, valthebald, John Cook: Remove entity_load* usage for view entity type
parent 1d847657
......@@ -3,6 +3,7 @@
namespace Drupal\aggregator\Tests;
use Drupal\Component\Utility\SafeMarkup;
use Drupal\views\Entity\View;
/**
* Tests display of aggregator items on the page.
......@@ -90,7 +91,7 @@ public function testBlockLinks() {
public function testFeedPage() {
// Increase the number of items published in the rss.xml feed so we have
// enough articles to test paging.
$view = entity_load('view', 'frontpage');
$view = View::load('frontpage');
$display = &$view->getDisplay('feed_1');
$display['display_options']['pager']['options']['items_per_page'] = 30;
$view->save();
......
......@@ -85,11 +85,16 @@ public function testInstallConfigEntityModuleFirst() {
*/
public function testUninstall() {
$this->installModule('views');
$this->assertTrue(entity_load('view', 'frontpage', TRUE) === NULL, 'After installing Views, frontpage view which is dependant on the Node and Views modules does not exist.');
$storage = $this->container->get('entity_type.manager')->getStorage('view');
$storage->resetCache(array('frontpage'));
$this->assertTrue($storage->load('frontpage') === NULL, 'After installing Views, frontpage view which is dependant on the Node and Views modules does not exist.');
$this->installModule('node');
$this->assertTrue(entity_load('view', 'frontpage', TRUE) !== NULL, 'After installing Node, frontpage view which is dependant on the Node and Views modules exists.');
$storage->resetCache(array('frontpage'));
$this->assertTrue($storage->load('frontpage') !== NULL, 'After installing Node, frontpage view which is dependant on the Node and Views modules exists.');
$this->uninstallModule('node');
$this->assertTrue(entity_load('view', 'frontpage', TRUE) === NULL, 'After uninstalling Node, frontpage view which is dependant on the Node and Views modules does not exist.');
$storage = $this->container->get('entity_type.manager')->getStorage('view');
$storage->resetCache(array('frontpage'));
$this->assertTrue($storage->load('frontpage') === NULL, 'After uninstalling Node, frontpage view which is dependant on the Node and Views modules does not exist.');
}
/**
......
......@@ -6,6 +6,7 @@
use Drupal\Core\Url;
use Drupal\shortcut\Entity\Shortcut;
use Drupal\shortcut\Entity\ShortcutSet;
use Drupal\views\Entity\View;
/**
* Create, view, edit, delete, and change shortcut links.
......@@ -233,7 +234,7 @@ public function testShortcutLinkChangeRoute() {
$this->drupalGet('admin/content');
$this->assertResponse(200);
// Disable the view.
entity_load('view', 'content')->disable()->save();
View::load('content')->disable()->save();
/** @var \Drupal\Core\Routing\RouteBuilderInterface $router_builder */
$router_builder = \Drupal::service('router.builder');
$router_builder->rebuildIfNeeded();
......
......@@ -7,6 +7,7 @@
use Drupal\taxonomy\Entity\Vocabulary;
use Drupal\views\Tests\ViewTestData;
use Drupal\views_ui\Tests\UITestBase;
use Drupal\views\Entity\View;
/**
* Tests the taxonomy index filter handler UI.
......@@ -102,7 +103,7 @@ public function testFilterUI() {
// Ensure the autocomplete input element appears when using the 'textfield'
// type.
$view = entity_load('view', 'test_filter_taxonomy_index_tid');
$view = View::load('test_filter_taxonomy_index_tid');
$display =& $view->getDisplay('default');
$display['display_options']['filters']['tid']['type'] = 'textfield';
$view->save();
......
......@@ -8,6 +8,7 @@
use Drupal\views\Tests\ViewTestBase;
use Drupal\views\ViewExecutable;
use Drupal\views\Views;
use Drupal\views\Entity\View;
/**
* Tests exposed forms functionality.
......@@ -241,7 +242,7 @@ public function testExposedBlock() {
* Test the input required exposed form type.
*/
public function testInputRequired() {
$view = entity_load('view', 'test_exposed_form_buttons');
$view = View::load('test_exposed_form_buttons');
$display = &$view->getDisplay('default');
$display['display_options']['exposed_form']['type'] = 'input_required';
$view->save();
......
......@@ -2,6 +2,8 @@
namespace Drupal\views\Tests\Plugin;
use Drupal\views\Entity\View;
/**
* Tests the table style views plugin.
*
......@@ -44,7 +46,7 @@ public function testAccessibilitySettings() {
$this->assertEqual(trim((string) $result[0]), 'description-text');
// Remove the caption and ensure the caption is not displayed anymore.
$view = entity_load('view', 'test_table');
$view = View::load('test_table');
$display = &$view->getDisplay('default');
$display['display_options']['style']['options']['caption'] = '';
$view->save();
......@@ -88,7 +90,7 @@ public function testFieldInColumns() {
$this->assertTrue(count($result), 'Ensure there is a td with the class views-field-job-1');
// Combine the second job-column with the first one, with ', ' as separator.
$view = entity_load('view', 'test_table');
$view = View::load('test_table');
$display = &$view->getDisplay('default');
$display['display_options']['style']['options']['columns']['job_1'] = 'job';
$display['display_options']['style']['options']['info']['job']['separator'] = ', ';
......
......@@ -99,7 +99,7 @@ protected function setUpFixtures() {
public function testFactoryService() {
$factory = $this->container->get('views.executable');
$this->assertTrue($factory instanceof ViewExecutableFactory, 'A ViewExecutableFactory instance was returned from the container.');
$view = entity_load('view', 'test_executable_displays');
$view = View::load('test_executable_displays');
$this->assertTrue($factory->get($view) instanceof ViewExecutable, 'A ViewExecutable instance was returned from the factory.');
}
......
......@@ -78,7 +78,7 @@ function testConfigurationEntityCRUD() {
* Tests loading configuration entities.
*/
protected function loadTests() {
$view = entity_load('view', 'test_view_storage');
$view = View::load('test_view_storage');
$data = $this->config('views.view.test_view_storage')->get();
// Confirm that an actual view object is loaded and that it returns all of
......@@ -143,7 +143,7 @@ protected function createTests() {
// Check the UUID of the loaded View.
$created->save();
$created_loaded = entity_load('view', 'test_view_storage_new');
$created_loaded = View::load('test_view_storage_new');
$this->assertIdentical($created->uuid(), $created_loaded->uuid(), 'The created UUID has been saved correctly.');
}
......@@ -152,7 +152,7 @@ protected function createTests() {
*/
protected function displayTests() {
// Check whether a display can be added and saved to a View.
$view = entity_load('view', 'test_view_storage_new');
$view = View::load('test_view_storage_new');
$new_id = $view->addDisplay('page', 'Test', 'test');
$display = $view->get('display');
......
......@@ -191,7 +191,7 @@ public function testLinkDisplay() {
*/
public function testPageContextualLinks() {
$this->drupalLogin($this->drupalCreateUser(array('administer views', 'access contextual links')));
$view = entity_load('view', 'test_display');
$view = View::load('test_display');
$view->enable()->save();
$this->container->get('router.builder')->rebuildIfNeeded();
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment