class SearchPageValidationTest
Same name and namespace in other branches
- 11.x core/modules/search/tests/src/Kernel/SearchPageValidationTest.php \Drupal\Tests\search\Kernel\SearchPageValidationTest
Tests validation of search_page entities.
@group search @group #slow
Hierarchy
- class \Drupal\KernelTests\Core\Config\ConfigEntityValidationTestBase
- class \Drupal\Tests\search\Kernel\SearchPageValidationTest implements \Drupal\KernelTests\Core\Config\ConfigEntityValidationTestBase
Expanded class hierarchy of SearchPageValidationTest
File
-
core/
modules/ search/ tests/ src/ Kernel/ SearchPageValidationTest.php, line 18
Namespace
Drupal\Tests\search\KernelView source
class SearchPageValidationTest extends ConfigEntityValidationTestBase {
/**
* {@inheritdoc}
*/
protected static $modules = [
'search',
'user',
];
/**
* {@inheritdoc}
*/
protected function setUp() : void {
parent::setUp();
$this->entity = SearchPage::create([
'id' => 'test',
'label' => 'Test',
'plugin' => 'user_search',
]);
$this->entity
->save();
}
/**
* Tests that the search plugin ID is validated.
*/
public function testInvalidPluginId() : void {
$this->entity
->set('plugin', 'non_existent');
$this->assertValidationErrors([
'plugin' => "The 'non_existent' plugin does not exist.",
]);
}
/**
* Test that the base route stored in definition is correct.
*/
public function testBaseRouteIsValid() : void {
$search_page_repository = new SearchPageRepository(\Drupal::configFactory(), \Drupal::entityTypeManager());
$search_local_task = new SearchLocalTask($search_page_repository);
$definitions = $search_local_task->getDerivativeDefinitions([]);
$route_provider = \Drupal::service('router.route_provider');
$base_route = $route_provider->getRouteByName($definitions['test']['base_route']);
$this->assertSame($base_route, $route_provider->getRouteByName('search.view'));
}
}
Members
Title Sort descending | Modifiers | Object type | Summary | Overriden Title | Overrides |
---|---|---|---|---|---|
ConfigEntityValidationTestBase::$entity | protected | property | The config entity being tested. | ||
ConfigEntityValidationTestBase::$hasLabel | protected | property | Whether a config entity of this type has a label. | 4 | |
ConfigEntityValidationTestBase::$propertiesWithOptionalValues | protected static | property | The config entity properties whose values are optional (set to NULL). | 4 | |
ConfigEntityValidationTestBase::$propertiesWithRequiredKeys | protected static | property | The config entity mapping properties with >=1 required keys. | 1 | |
ConfigEntityValidationTestBase::assertValidationErrors | protected | function | Asserts a set of validation errors is raised when the entity is validated. | ||
ConfigEntityValidationTestBase::getMachineNameConstraints | protected | function | Returns the validation constraints applied to the entity's ID. | ||
ConfigEntityValidationTestBase::getPropertiesWithOptionalValues | protected | function | Determines the config entity properties with optional values. | ||
ConfigEntityValidationTestBase::getRequiredPropertyKeys | protected | function | Determines the config entity mapping properties with required keys. | ||
ConfigEntityValidationTestBase::isFullyValidatable | protected | function | Whether the tested config entity type is fully validatable. | ||
ConfigEntityValidationTestBase::providerConfigDependenciesValidation | public static | function | Data provider for ::testConfigDependenciesValidation(). | ||
ConfigEntityValidationTestBase::providerInvalidMachineNameCharacters | public static | function | Data provider for ::testInvalidMachineNameCharacters(). | 5 | |
ConfigEntityValidationTestBase::setLabel | protected static | function | Sets the label of the given config entity. | 1 | |
ConfigEntityValidationTestBase::testConfigDependenciesValidation | public | function | Tests validation of config dependencies. | ||
ConfigEntityValidationTestBase::testEntityIsValid | public | function | Ensures that the entity created in ::setUp() has no validation errors. | ||
ConfigEntityValidationTestBase::testImmutableProperties | public | function | Tests that immutable properties cannot be changed. | 11 | |
ConfigEntityValidationTestBase::testInvalidMachineNameCharacters | public | function | Tests that the entity's ID is tested for invalid characters. | ||
ConfigEntityValidationTestBase::testLabelValidation | public | function | Tests validation of config entity's label. | 3 | |
ConfigEntityValidationTestBase::testLangcode | public | function | Tests that the config entity's langcode is validated. | ||
ConfigEntityValidationTestBase::testMachineNameLength | public | function | Tests that the entity ID's length is validated if it is a machine name. | ||
ConfigEntityValidationTestBase::testRequiredPropertyKeysMissing | public | function | A property that is required must have a value (i.e. not NULL). | 2 | |
ConfigEntityValidationTestBase::testRequiredPropertyValuesMissing | public | function | A property that is required must have a value (i.e. not NULL). | 2 | |
SearchPageValidationTest::$modules | protected static | property | Modules to install. | ||
SearchPageValidationTest::setUp | protected | function | Overrides ConfigEntityValidationTestBase::setUp | ||
SearchPageValidationTest::testBaseRouteIsValid | public | function | Test that the base route stored in definition is correct. | ||
SearchPageValidationTest::testInvalidPluginId | public | function | Tests that the search plugin ID is validated. |
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.