update
This commit is contained in:
+9
@@ -0,0 +1,9 @@
|
||||
views_config_entity_test.type.*:
|
||||
type: config_entity
|
||||
label: 'Config entity type with Views data'
|
||||
mapping:
|
||||
id:
|
||||
type: string
|
||||
name:
|
||||
type: label
|
||||
label: 'Name'
|
||||
+26
@@ -0,0 +1,26 @@
|
||||
<?php
|
||||
|
||||
namespace Drupal\views_config_entity_test\Entity;
|
||||
|
||||
use Drupal\Core\Config\Entity\ConfigEntityBase;
|
||||
|
||||
/**
|
||||
* Defines a configuration-based entity type used for testing Views data.
|
||||
*
|
||||
* @ConfigEntityType(
|
||||
* id = "views_config_entity_test",
|
||||
* label = @Translation("Test config entity type with Views data"),
|
||||
* handlers = {
|
||||
* "list_builder" = "Drupal\Core\Entity\EntityListBuilder",
|
||||
* "views_data" = "Drupal\views_config_entity_test\ViewsConfigEntityTestViewsData"
|
||||
* },
|
||||
* admin_permission = "administer modules",
|
||||
* config_prefix = "type",
|
||||
* entity_keys = {
|
||||
* "id" = "id",
|
||||
* "label" = "name"
|
||||
* }
|
||||
* )
|
||||
*/
|
||||
class ViewsConfigEntityTest extends ConfigEntityBase {
|
||||
}
|
||||
+27
@@ -0,0 +1,27 @@
|
||||
<?php
|
||||
|
||||
namespace Drupal\views_config_entity_test;
|
||||
|
||||
use Drupal\Core\Entity\EntityTypeInterface;
|
||||
use Drupal\views\EntityViewsDataInterface;
|
||||
|
||||
/**
|
||||
* Provides a view to override views data for config test entity types.
|
||||
*/
|
||||
class ViewsConfigEntityTestViewsData implements EntityViewsDataInterface {
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function getViewsData() {
|
||||
return [];
|
||||
}
|
||||
|
||||
/**
|
||||
* @inheritDoc
|
||||
*/
|
||||
public function getViewsTableForEntityType(EntityTypeInterface $entity_type) {
|
||||
return 'views_config_entity_test';
|
||||
}
|
||||
|
||||
}
|
||||
+5
@@ -0,0 +1,5 @@
|
||||
name: 'views_config_entity_test'
|
||||
description: 'Adds a Config Entity with views data'
|
||||
type: module
|
||||
package: Testing
|
||||
version: VERSION
|
||||
@@ -68,7 +68,11 @@ class BulkFormTest extends BrowserTestBase {
|
||||
// Log in as a user with 'administer nodes' permission to have access to the
|
||||
// bulk operation.
|
||||
$this->drupalCreateContentType(['type' => 'page']);
|
||||
$admin_user = $this->drupalCreateUser(['administer nodes', 'edit any page content', 'delete any page content']);
|
||||
$admin_user = $this->drupalCreateUser([
|
||||
'administer nodes',
|
||||
'edit any page content',
|
||||
'delete any page content',
|
||||
]);
|
||||
$this->drupalLogin($admin_user);
|
||||
|
||||
$this->drupalGet('test_bulk_form');
|
||||
|
||||
@@ -57,7 +57,10 @@ class AreaTest extends ViewTestBase {
|
||||
* Tests the generic UI of a area handler.
|
||||
*/
|
||||
public function testUI() {
|
||||
$admin_user = $this->drupalCreateUser(['administer views', 'administer site configuration']);
|
||||
$admin_user = $this->drupalCreateUser([
|
||||
'administer views',
|
||||
'administer site configuration',
|
||||
]);
|
||||
$this->drupalLogin($admin_user);
|
||||
|
||||
$types = ['header', 'footer', 'empty'];
|
||||
@@ -158,7 +161,10 @@ class AreaTest extends ViewTestBase {
|
||||
* Tests global tokens.
|
||||
*/
|
||||
public function testRenderAreaToken() {
|
||||
$admin_user = $this->drupalCreateUser(['administer views', 'administer site configuration']);
|
||||
$admin_user = $this->drupalCreateUser([
|
||||
'administer views',
|
||||
'administer site configuration',
|
||||
]);
|
||||
$this->drupalLogin($admin_user);
|
||||
|
||||
$view = Views::getView('test_example_area');
|
||||
|
||||
@@ -37,7 +37,11 @@ class FieldDropButtonTest extends ViewTestBase {
|
||||
protected function setUp($import_test_views = TRUE) {
|
||||
parent::setUp($import_test_views);
|
||||
|
||||
$admin_user = $this->drupalCreateUser(['access content overview', 'administer nodes', 'bypass node access']);
|
||||
$admin_user = $this->drupalCreateUser([
|
||||
'access content overview',
|
||||
'administer nodes',
|
||||
'bypass node access',
|
||||
]);
|
||||
$this->drupalLogin($admin_user);
|
||||
}
|
||||
|
||||
|
||||
@@ -66,7 +66,11 @@ class FieldEntityOperationsTest extends ViewTestBase {
|
||||
$entities[$i] = $entity;
|
||||
}
|
||||
|
||||
$admin_user = $this->drupalCreateUser(['access administration pages', 'administer nodes', 'bypass node access']);
|
||||
$admin_user = $this->drupalCreateUser([
|
||||
'access administration pages',
|
||||
'administer nodes',
|
||||
'bypass node access',
|
||||
]);
|
||||
$this->drupalLogin($this->rootUser);
|
||||
$this->drupalGet('test-entity-operations');
|
||||
/** @var $entity \Drupal\entity_test\Entity\EntityTest */
|
||||
|
||||
@@ -125,6 +125,7 @@ class FieldWebTest extends ViewTestBase {
|
||||
* The message to display along with the assertion.
|
||||
* @param string $group
|
||||
* The type of assertion - examples are "Browser", "PHP".
|
||||
*
|
||||
* @return bool
|
||||
* TRUE if the assertion succeeded, FALSE otherwise.
|
||||
*/
|
||||
@@ -143,6 +144,7 @@ class FieldWebTest extends ViewTestBase {
|
||||
* The message to display along with the assertion.
|
||||
* @param string $group
|
||||
* The type of assertion - examples are "Browser", "PHP".
|
||||
*
|
||||
* @return bool
|
||||
* TRUE if the assertion succeeded, FALSE otherwise.
|
||||
*/
|
||||
|
||||
@@ -184,7 +184,10 @@ class FilterDateTest extends ViewTestBase {
|
||||
*/
|
||||
protected function _testUiValidation() {
|
||||
|
||||
$this->drupalLogin($this->drupalCreateUser(['administer views', 'administer site configuration']));
|
||||
$this->drupalLogin($this->drupalCreateUser([
|
||||
'administer views',
|
||||
'administer site configuration',
|
||||
]));
|
||||
|
||||
$this->drupalGet('admin/structure/views/view/test_filter_date_between/edit');
|
||||
$this->drupalGet('admin/structure/views/nojs/handler/test_filter_date_between/default/filter/created');
|
||||
|
||||
@@ -58,7 +58,9 @@ class AccessTest extends ViewTestBase {
|
||||
$this->webUser = $this->drupalCreateUser();
|
||||
|
||||
$normal_role = $this->drupalCreateRole([]);
|
||||
$this->normalUser = $this->drupalCreateUser(['views_test_data test permission']);
|
||||
$this->normalUser = $this->drupalCreateUser([
|
||||
'views_test_data test permission',
|
||||
]);
|
||||
$this->normalUser->addRole($normal_role);
|
||||
// @todo when all the plugin information is cached make a reset function and
|
||||
// call it here.
|
||||
|
||||
@@ -91,7 +91,10 @@ class ArgumentDefaultTest extends ViewTestBase {
|
||||
* Tests the use of a default argument plugin that provides no options.
|
||||
*/
|
||||
public function testArgumentDefaultNoOptions() {
|
||||
$admin_user = $this->drupalCreateUser(['administer views', 'administer site configuration']);
|
||||
$admin_user = $this->drupalCreateUser([
|
||||
'administer views',
|
||||
'administer site configuration',
|
||||
]);
|
||||
$this->drupalLogin($admin_user);
|
||||
|
||||
// The current_user plugin has no options form, and should pass validation.
|
||||
|
||||
+4
-1
@@ -81,7 +81,10 @@ class ContextualFiltersBlockContextTest extends ViewTestBase {
|
||||
* Tests exposed context.
|
||||
*/
|
||||
public function testBlockContext() {
|
||||
$this->drupalLogin($this->drupalCreateUser(['administer views', 'administer blocks']));
|
||||
$this->drupalLogin($this->drupalCreateUser([
|
||||
'administer views',
|
||||
'administer blocks',
|
||||
]));
|
||||
|
||||
// Check if context was correctly propagated to the block.
|
||||
$definition = $this->container->get('plugin.manager.block')
|
||||
|
||||
@@ -38,7 +38,9 @@ class DisabledDisplayTest extends ViewTestBase {
|
||||
|
||||
$this->drupalPlaceBlock('page_title_block');
|
||||
|
||||
$admin_user = $this->drupalCreateUser(['administer site configuration']);
|
||||
$admin_user = $this->drupalCreateUser([
|
||||
'administer site configuration',
|
||||
]);
|
||||
$this->drupalLogin($admin_user);
|
||||
}
|
||||
|
||||
|
||||
@@ -136,7 +136,7 @@ class DisplayTest extends ViewTestBase {
|
||||
|
||||
// Check the new value has been saved by checking the UI summary text.
|
||||
$this->drupalGet('admin/structure/views/view/test_view/edit/display_test_1');
|
||||
$this->assertLink($test_option);
|
||||
$this->assertSession()->linkExists($test_option);
|
||||
|
||||
// Test the enable/disable status of a display.
|
||||
$view->display_handler->setOption('enabled', FALSE);
|
||||
|
||||
@@ -53,7 +53,10 @@ class MenuLinkTest extends ViewTestBase {
|
||||
|
||||
$this->enableViewsTestModule();
|
||||
|
||||
$this->adminUser = $this->drupalCreateUser(['administer views', 'administer menu']);
|
||||
$this->adminUser = $this->drupalCreateUser([
|
||||
'administer views',
|
||||
'administer menu',
|
||||
]);
|
||||
$this->drupalPlaceBlock('system_menu_block:main');
|
||||
$this->drupalCreateContentType(['type' => 'page']);
|
||||
}
|
||||
|
||||
@@ -36,7 +36,10 @@ class NumericFormatPluralTest extends ViewTestBase {
|
||||
protected function setUp($import_test_views = TRUE) {
|
||||
parent::setUp($import_test_views);
|
||||
|
||||
$web_user = $this->drupalCreateUser(['administer views', 'administer languages']);
|
||||
$web_user = $this->drupalCreateUser([
|
||||
'administer views',
|
||||
'administer languages',
|
||||
]);
|
||||
$this->drupalLogin($web_user);
|
||||
}
|
||||
|
||||
|
||||
@@ -51,7 +51,10 @@ class PagerTest extends ViewTestBase {
|
||||
// Show the master display so the override selection is shown.
|
||||
\Drupal::configFactory()->getEditable('views.settings')->set('ui.show.master_display', TRUE)->save();
|
||||
|
||||
$admin_user = $this->drupalCreateUser(['administer views', 'administer site configuration']);
|
||||
$admin_user = $this->drupalCreateUser([
|
||||
'administer views',
|
||||
'administer site configuration',
|
||||
]);
|
||||
$this->drupalLogin($admin_user);
|
||||
// Test behavior described in
|
||||
// https://www.drupal.org/node/652712#comment-2354918.
|
||||
@@ -384,7 +387,12 @@ class PagerTest extends ViewTestBase {
|
||||
$this->container->get('module_installer')->install(['locale', 'language', 'config_translation']);
|
||||
$this->resetAll();
|
||||
|
||||
$admin_user = $this->drupalCreateUser(['access content overview', 'administer nodes', 'bypass node access', 'translate configuration']);
|
||||
$admin_user = $this->drupalCreateUser([
|
||||
'access content overview',
|
||||
'administer nodes',
|
||||
'bypass node access',
|
||||
'translate configuration',
|
||||
]);
|
||||
$this->drupalLogin($admin_user);
|
||||
|
||||
$langcode = 'nl';
|
||||
|
||||
@@ -211,6 +211,8 @@ class StyleTableTest extends ViewTestBase {
|
||||
|
||||
// Ensure that we don't find the caption containing unsafe markup.
|
||||
$this->assertNoRaw($unsafe_markup, "Didn't find caption containing unsafe markup.");
|
||||
// Ensure that the summary isn't shown.
|
||||
$this->assertEmpty($this->xpath('//caption/details'));
|
||||
|
||||
// Ensure that all expected captions are found.
|
||||
foreach ($expected_captions as $raw_caption) {
|
||||
|
||||
@@ -69,21 +69,21 @@ class SearchIntegrationTest extends ViewTestBase {
|
||||
|
||||
// Page with a keyword filter of 'pizza'.
|
||||
$this->drupalGet('test-filter');
|
||||
$this->assertLink('pizza');
|
||||
$this->assertNoLink('sandwich');
|
||||
$this->assertLink('cola');
|
||||
$this->assertSession()->linkExists('pizza');
|
||||
$this->assertSession()->linkNotExists('sandwich');
|
||||
$this->assertSession()->linkExists('cola');
|
||||
|
||||
// Page with a keyword argument, various argument values.
|
||||
// Verify that the correct nodes are shown, and only once.
|
||||
$this->drupalGet('test-arg/pizza');
|
||||
$this->assertOneLink('pizza');
|
||||
$this->assertNoLink('sandwich');
|
||||
$this->assertSession()->linkNotExists('sandwich');
|
||||
$this->assertOneLink('cola');
|
||||
|
||||
$this->drupalGet('test-arg/sandwich');
|
||||
$this->assertNoLink('pizza');
|
||||
$this->assertSession()->linkNotExists('pizza');
|
||||
$this->assertOneLink('sandwich');
|
||||
$this->assertNoLink('cola');
|
||||
$this->assertSession()->linkNotExists('cola');
|
||||
|
||||
$this->drupalGet('test-arg/pizza OR sandwich');
|
||||
$this->assertOneLink('pizza');
|
||||
@@ -91,18 +91,18 @@ class SearchIntegrationTest extends ViewTestBase {
|
||||
$this->assertOneLink('cola');
|
||||
|
||||
$this->drupalGet('test-arg/pizza sandwich OR cola');
|
||||
$this->assertNoLink('pizza');
|
||||
$this->assertNoLink('sandwich');
|
||||
$this->assertSession()->linkNotExists('pizza');
|
||||
$this->assertSession()->linkNotExists('sandwich');
|
||||
$this->assertOneLink('cola');
|
||||
|
||||
$this->drupalGet('test-arg/cola pizza');
|
||||
$this->assertNoLink('pizza');
|
||||
$this->assertNoLink('sandwich');
|
||||
$this->assertSession()->linkNotExists('pizza');
|
||||
$this->assertSession()->linkNotExists('sandwich');
|
||||
$this->assertOneLink('cola');
|
||||
|
||||
$this->drupalGet('test-arg/"cola is good"');
|
||||
$this->assertNoLink('pizza');
|
||||
$this->assertNoLink('sandwich');
|
||||
$this->assertSession()->linkNotExists('pizza');
|
||||
$this->assertSession()->linkNotExists('sandwich');
|
||||
$this->assertOneLink('cola');
|
||||
|
||||
// Test sorting.
|
||||
|
||||
@@ -45,7 +45,14 @@ class SearchMultilingualTest extends ViewTestBase {
|
||||
public function testMultilingualSearchFilter() {
|
||||
// Create a user with admin for languages, content, and content types, plus
|
||||
// the ability to access content and searches.
|
||||
$user = $this->drupalCreateUser(['administer nodes', 'administer content types', 'administer languages', 'administer content translation', 'access content', 'search content']);
|
||||
$user = $this->drupalCreateUser([
|
||||
'administer nodes',
|
||||
'administer content types',
|
||||
'administer languages',
|
||||
'administer content translation',
|
||||
'access content',
|
||||
'search content',
|
||||
]);
|
||||
$this->drupalLogin($user);
|
||||
|
||||
// Add Spanish language programmatically.
|
||||
@@ -87,8 +94,8 @@ class SearchMultilingualTest extends ViewTestBase {
|
||||
// translated node, which has 'pizza' in the title, but not the English
|
||||
// one, which does not have the word 'pizza' in it.
|
||||
$this->drupalGet('test-filter');
|
||||
$this->assertLink('pizza', 0, 'Found translation with matching title');
|
||||
$this->assertNoLink('sandwich', 'Did not find translation with non-matching title');
|
||||
$this->assertSession()->linkExists('pizza', 0, 'Found translation with matching title');
|
||||
$this->assertSession()->linkNotExists('sandwich', 'Did not find translation with non-matching title');
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -40,7 +40,7 @@ class MenuTest extends WizardTestBase {
|
||||
// expect the main menu to display).
|
||||
$this->drupalGet('');
|
||||
$this->assertSession()->statusCodeEquals(200);
|
||||
$this->assertLink($view['page[link_properties][title]']);
|
||||
$this->assertSession()->linkExists($view['page[link_properties][title]']);
|
||||
$this->assertLinkByHref(Url::fromUri('base:' . $view['page[path]'])->toString());
|
||||
|
||||
// Make sure the link is associated with the main menu.
|
||||
|
||||
@@ -20,7 +20,13 @@ abstract class WizardTestBase extends ViewTestBase {
|
||||
parent::setUp($import_test_views);
|
||||
|
||||
// Create and log in a user with administer views permission.
|
||||
$views_admin = $this->drupalCreateUser(['administer views', 'administer blocks', 'bypass node access', 'access user profiles', 'view all revisions']);
|
||||
$views_admin = $this->drupalCreateUser([
|
||||
'administer views',
|
||||
'administer blocks',
|
||||
'bypass node access',
|
||||
'access user profiles',
|
||||
'view all revisions',
|
||||
]);
|
||||
$this->drupalLogin($views_admin);
|
||||
$this->drupalPlaceBlock('local_actions_block');
|
||||
}
|
||||
|
||||
@@ -2,15 +2,19 @@
|
||||
|
||||
namespace Drupal\Tests\views\Kernel;
|
||||
|
||||
use Drupal\Component\Render\FormattableMarkup;
|
||||
use Drupal\Core\Form\FormState;
|
||||
use Drupal\views\Plugin\views\area\Broken as BrokenArea;
|
||||
use Drupal\views\Plugin\views\field\Broken as BrokenField;
|
||||
use Drupal\views\Plugin\views\filter\Broken as BrokenFilter;
|
||||
use Drupal\views\Plugin\views\filter\Standard;
|
||||
use Drupal\views\Views;
|
||||
|
||||
/**
|
||||
* Tests basic functions from the Views module.
|
||||
*
|
||||
* @group views
|
||||
*/
|
||||
use Drupal\views\Plugin\views\filter\Standard;
|
||||
use Drupal\views\Views;
|
||||
use Drupal\Component\Render\FormattableMarkup;
|
||||
|
||||
class ModuleTest extends ViewsKernelTestBase {
|
||||
|
||||
/**
|
||||
@@ -42,14 +46,41 @@ class ModuleTest extends ViewsKernelTestBase {
|
||||
* @see \Drupal\views\Plugin\ViewsHandlerManager::getHandler()
|
||||
*/
|
||||
public function testViewsGetHandler() {
|
||||
$types = ['field', 'area', 'filter'];
|
||||
foreach ($types as $type) {
|
||||
$item = [
|
||||
'table' => $this->randomMachineName(),
|
||||
'field' => $this->randomMachineName(),
|
||||
];
|
||||
$handler = $this->container->get('plugin.manager.views.' . $type)->getHandler($item);
|
||||
$this->assertEqual('Drupal\views\Plugin\views\\' . $type . '\Broken', get_class($handler), new FormattableMarkup('Make sure that a broken handler of type: @type is created.', ['@type' => $type]));
|
||||
$types = [
|
||||
'field' => BrokenField::class,
|
||||
'area' => BrokenArea::class,
|
||||
'filter' => BrokenFilter::class,
|
||||
];
|
||||
// Test non-existent tables/fields.
|
||||
$items = [
|
||||
[
|
||||
'table' => 'table_invalid',
|
||||
'field' => 'id',
|
||||
],
|
||||
[
|
||||
'table' => 'views_test_data',
|
||||
'field' => 'field_invalid',
|
||||
],
|
||||
];
|
||||
$form_state = new FormState();
|
||||
$description_top = '<p>' . t('The handler for this item is broken or missing. The following details are available:') . '</p>';
|
||||
$description_bottom = '<p>' . t('Enabling the appropriate module may solve this issue. Otherwise, check to see if there is a module update available.') . '</p>';
|
||||
foreach ($types as $type => $class) {
|
||||
foreach ($items as $item) {
|
||||
$handler = $this->container->get('plugin.manager.views.' . $type)
|
||||
->getHandler($item);
|
||||
$this->assertTrue($handler instanceof $class);
|
||||
// Make sure details available at edit form.
|
||||
$form = [];
|
||||
$handler->buildOptionsForm($form, $form_state);
|
||||
$this->assertEquals($description_top, $form['description']['description_top']['#markup']);
|
||||
$this->assertEquals($description_bottom, $form['description']['description_bottom']['#markup']);
|
||||
$details = [];
|
||||
foreach ($item as $key => $value) {
|
||||
$details[] = new FormattableMarkup('@key: @value', ['@key' => $key, '@value' => $value]);
|
||||
}
|
||||
$this->assertEquals($details, $form['description']['detail_list']['#items']);
|
||||
}
|
||||
}
|
||||
|
||||
$views_data = $this->viewsData();
|
||||
@@ -77,61 +108,6 @@ class ModuleTest extends ViewsKernelTestBase {
|
||||
];
|
||||
$handler = $this->container->get('plugin.manager.views.filter')->getHandler($item, 'standard');
|
||||
$this->assertInstanceOf(Standard::class, $handler);
|
||||
|
||||
// @todo Reinstate these tests when the debug() in views_get_handler() is
|
||||
// restored.
|
||||
return;
|
||||
|
||||
// Test non-existent tables/fields.
|
||||
set_error_handler([$this, 'customErrorHandler']);
|
||||
$item = [
|
||||
'table' => 'views_test_data',
|
||||
'field' => 'field_invalid',
|
||||
];
|
||||
$this->container->get('plugin.manager.views.field')->getHandler($item);
|
||||
$this->assertStringContainsString(new FormattableMarkup("Missing handler: @table @field @type", ['@table' => 'views_test_data', '@field' => 'field_invalid', '@type' => 'field']), $this->lastErrorMessage, 'An invalid field name throws a debug message.');
|
||||
unset($this->lastErrorMessage);
|
||||
|
||||
$item = [
|
||||
'table' => 'table_invalid',
|
||||
'field' => 'id',
|
||||
];
|
||||
$this->container->get('plugin.manager.views.filter')->getHandler($item);
|
||||
$this->assertStringContainsString(new FormattableMarkup("Missing handler: @table @field @type", ['@table' => 'table_invalid', '@field' => 'id', '@type' => 'filter']), $this->lastErrorMessage, 'An invalid table name throws a debug message.');
|
||||
unset($this->lastErrorMessage);
|
||||
|
||||
$item = [
|
||||
'table' => 'table_invalid',
|
||||
'field' => 'id',
|
||||
];
|
||||
$this->container->get('plugin.manager.views.filter')->getHandler($item);
|
||||
$this->assertStringContainsString(new FormattableMarkup("Missing handler: @table @field @type", ['@table' => 'table_invalid', '@field' => 'id', '@type' => 'filter']), $this->lastErrorMessage, 'An invalid table name throws a debug message.');
|
||||
unset($this->lastErrorMessage);
|
||||
|
||||
restore_error_handler();
|
||||
}
|
||||
|
||||
/**
|
||||
* Defines an error handler which is used in the test.
|
||||
*
|
||||
* Because this is registered in set_error_handler(), it has to be public.
|
||||
*
|
||||
* @param int $error_level
|
||||
* The level of the error raised.
|
||||
* @param string $message
|
||||
* The error message.
|
||||
* @param string $filename
|
||||
* The filename that the error was raised in.
|
||||
* @param int $line
|
||||
* The line number the error was raised at.
|
||||
* @param array $context
|
||||
* An array that points to the active symbol table at the point the error
|
||||
* occurred.
|
||||
*
|
||||
* @see set_error_handler()
|
||||
*/
|
||||
public function customErrorHandler($error_level, $message, $filename, $line, $context) {
|
||||
$this->lastErrorMessage = $message;
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -19,6 +19,11 @@ class ViewsConfigUpdaterTest extends ViewsKernelTestBase {
|
||||
*/
|
||||
protected $configUpdater;
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public static $modules = ['views_config_entity_test'];
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
|
||||
@@ -2,6 +2,7 @@
|
||||
|
||||
namespace Drupal\Tests\views\Unit;
|
||||
|
||||
use Drupal\Core\Entity\EntityStorageInterface;
|
||||
use Drupal\Core\Entity\EntityTypeManagerInterface;
|
||||
use Drupal\Tests\UnitTestCase;
|
||||
use Drupal\views\Views;
|
||||
@@ -72,6 +73,21 @@ class ViewsTest extends UnitTestCase {
|
||||
$this->assertEquals(spl_object_hash($view), spl_object_hash($executable->storage));
|
||||
}
|
||||
|
||||
/**
|
||||
* Tests the getView() method against a non-existent view.
|
||||
*
|
||||
* @covers ::getView
|
||||
*/
|
||||
public function testGetNonExistentView() {
|
||||
$entity_type_manager = $this->prophesize(EntityTypeManagerInterface::class);
|
||||
$storage = $this->prophesize(EntityStorageInterface::class);
|
||||
$storage->load('test_view_non_existent')->willReturn(NULL);
|
||||
$entity_type_manager->getStorage('view')->willReturn($storage->reveal());
|
||||
$this->container->set('entity_type.manager', $entity_type_manager->reveal());
|
||||
$executable_does_not_exist = Views::getView('test_view_non_existent');
|
||||
$this->assertNull($executable_does_not_exist);
|
||||
}
|
||||
|
||||
/**
|
||||
* @covers ::getApplicableViews
|
||||
*
|
||||
|
||||
Reference in New Issue
Block a user