class DependencyRemovalTest in Search API 8
Tests what happens when an index's or a server's dependencies are removed.
@group search_api
Hierarchy
- class \Drupal\KernelTests\KernelTestBase extends \PHPUnit\Framework\TestCase implements ServiceProviderInterface uses AssertContentTrait, AssertLegacyTrait, AssertHelperTrait, ConfigTestTrait, PhpunitCompatibilityTrait, RandomGeneratorTrait, TestRequirementsTrait
- class \Drupal\Tests\search_api\Kernel\ConfigEntity\DependencyRemovalTest uses PluginTestTrait, EntityReferenceTestTrait
Expanded class hierarchy of DependencyRemovalTest
File
- tests/
src/ Kernel/ ConfigEntity/ DependencyRemovalTest.php, line 20
Namespace
Drupal\Tests\search_api\Kernel\ConfigEntityView source
class DependencyRemovalTest extends KernelTestBase {
use EntityReferenceTestTrait;
use PluginTestTrait;
/**
* A search index.
*
* @var \Drupal\search_api\IndexInterface
*/
protected $index;
/**
* A config entity, to be used as a dependency in the tests.
*
* @var \Drupal\Core\Config\Entity\ConfigEntityInterface
*/
protected $dependency;
/**
* {@inheritdoc}
*/
public static $modules = [
'user',
'system',
'field',
'search_api',
'search_api_test',
];
/**
* {@inheritdoc}
*/
public function setUp() {
parent::setUp();
$this
->installEntitySchema('user');
$this
->installEntitySchema('search_api_task');
$this
->installConfig('search_api');
// Create the index object, but don't save it yet since we want to change
// its settings anyways in every test.
$this->index = Index::create([
'id' => 'test_index',
'name' => 'Test index',
'tracker_settings' => [
'default' => [],
],
'datasource_settings' => [
'entity:user' => [],
],
]);
// Use a search server as the dependency, since we have that available
// anyways. The entity type should not matter at all, though.
$this->dependency = Server::create([
'id' => 'dependency',
'name' => 'Test dependency',
'backend' => 'search_api_test',
]);
$this->dependency
->save();
}
/**
* Tests index with a field dependency that gets removed.
*/
public function testFieldDependency() {
// Add new field storage and field definitions. Use an indirect reference
// for the field to test whether this can also be handled correctly.
$this
->createEntityReferenceField('user', 'user', 'parent', 'Parent', 'user');
$parent_field_storage = FieldStorageConfig::loadByName('user', 'parent');
/** @var \Drupal\field\FieldStorageConfigInterface $field_storage */
$field_storage = FieldStorageConfig::create([
'field_name' => 'field_search',
'type' => 'string',
'entity_type' => 'user',
]);
$field_storage
->save();
$field_search = FieldConfig::create([
'field_name' => 'field_search',
'field_type' => 'string',
'entity_type' => 'user',
'bundle' => 'user',
'label' => 'Search Field',
]);
$field_search
->save();
// Add fields to the index.
$fields_helper = \Drupal::getContainer()
->get('search_api.fields_helper');
$field = $fields_helper
->createFieldFromProperty($this->index, $field_storage
->getPropertyDefinition('value'), 'entity:user', 'field_search', 'search', 'string');
$this->index
->addField($field);
$field = $fields_helper
->createFieldFromProperty($this->index, $field_storage
->getPropertyDefinition('value'), 'entity:user', 'parent:entity:field_search', 'parent_search', 'string');
$this->index
->addField($field);
$field = $fields_helper
->createFieldFromProperty($this->index, $parent_field_storage
->getPropertyDefinition('target_id'), 'entity:user', 'parent', 'parent', 'string');
$this->index
->addField($field);
$this->index
->save();
// New field has been added to the list of dependencies.
$config_dependencies = \Drupal::config('search_api.index.' . $this->index
->id())
->get('dependencies.config');
$this
->assertContains($parent_field_storage
->getConfigDependencyName(), $config_dependencies);
$this
->assertContains($field_storage
->getConfigDependencyName(), $config_dependencies);
// Remove a dependent field.
$parent_field_storage
->delete();
// Index has not been deleted and index dependencies were updated.
$this
->reloadIndex();
$index = \Drupal::config('search_api.index.' . $this->index
->id());
$dependencies = $index
->get('dependencies');
$this
->assertFalse(isset($dependencies['config'][$parent_field_storage
->getConfigDependencyName()]));
$this
->assertContains($field_storage
->getConfigDependencyName(), $config_dependencies);
// Correct fields were removed.
$this
->assertEquals([
'search',
], array_keys($index
->get('field_settings')));
// Remove a dependent field.
$field_storage
->delete();
// Index has not been deleted and index dependencies were updated.
$this
->reloadIndex();
$dependencies = \Drupal::config('search_api.index.' . $this->index
->id())
->get('dependencies');
$this
->assertFalse(isset($dependencies['config'][$field_storage
->getConfigDependencyName()]));
// Last field was removed.
$this
->assertEquals([], array_keys($index
->get('field_settings')));
}
/**
* Tests a backend with a dependency that gets removed.
*
* If the dependency does not get removed, proper cascading to the index is
* also verified.
*
* @param bool $remove_dependency
* Whether to remove the dependency from the backend when the object
* depended on is deleted.
*
* @dataProvider dependencyTestDataProvider
*/
public function testBackendDependency($remove_dependency) {
$dependency_key = $this->dependency
->getConfigDependencyKey();
$dependency_name = $this->dependency
->getConfigDependencyName();
// Create a server using the test backend, and set the dependency in the
// configuration.
/** @var \Drupal\search_api\ServerInterface $server */
$server = Server::create([
'id' => 'test_server',
'name' => 'Test server',
'backend' => 'search_api_test',
'backend_config' => [
'dependencies' => [
$dependency_key => [
$dependency_name,
],
],
],
]);
$server
->save();
$server_dependency_key = $server
->getConfigDependencyKey();
$server_dependency_name = $server
->getConfigDependencyName();
// Set the server on the index and save that, too. However, we don't want
// the index enabled, since that would lead to all kinds of overhead which
// is completely irrelevant for this test.
$this->index
->setServer($server);
$this->index
->disable();
$this->index
->save();
// Check that the dependencies were calculated correctly.
$server_dependencies = $server
->getDependencies();
$this
->assertContains($dependency_name, $server_dependencies[$dependency_key], 'Backend dependency correctly inserted');
$index_dependencies = $this->index
->getDependencies();
$this
->assertContains($server_dependency_name, $index_dependencies[$server_dependency_key], 'Server dependency correctly inserted');
// Tell the backend plugin whether it should successfully remove the
// dependency.
$this
->setReturnValue('backend', 'onDependencyRemoval', $remove_dependency);
// Delete the backend's dependency.
$this->dependency
->delete();
// Reload the index and check it's still there.
$this
->reloadIndex();
$this
->assertInstanceOf('Drupal\\search_api\\IndexInterface', $this->index, 'Index not removed');
// Reload the server.
$storage = \Drupal::entityTypeManager()
->getStorage('search_api_server');
$storage
->resetCache();
$server = $storage
->load($server
->id());
if ($remove_dependency) {
$this
->assertInstanceOf('Drupal\\search_api\\ServerInterface', $server, 'Server was not removed');
$this
->assertArrayNotHasKey('dependencies', $server
->get('backend_config'), 'Backend config was adapted');
// @todo Logically, this should not be changed: if the server does not get
// removed, there is no need to adapt the index's configuration.
// However, the way this config dependency cascading is actually
// implemented in
// \Drupal\Core\Config\ConfigManager::getConfigEntitiesToChangeOnDependencyRemoval()
// does not seem to follow that logic, but just computes the complete
// tree of dependencies once and operates generally on the assumption
// that all of them will be deleted. See #2642374.
// $this->assertEquals($server->id(), $this->index->getServerId(), "Index's server was not changed");
}
else {
$this
->assertNull($server, 'Server was removed');
$this
->assertEquals(NULL, $this->index
->getServerId(), 'Index server was changed');
}
}
/**
* Tests a datasource with a dependency that gets removed.
*
* @param bool $remove_dependency
* Whether to remove the dependency from the datasource when the object
* depended on is deleted.
*
* @dataProvider dependencyTestDataProvider
*/
public function testDatasourceDependency($remove_dependency) {
// Add the datasource to the index and save it. The datasource configuration
// contains the dependencies it will return – in our case, we use the test
// server.
$dependency_key = $this->dependency
->getConfigDependencyKey();
$dependency_name = $this->dependency
->getConfigDependencyName();
// Also index users, to verify that they are unaffected by the processor.
$datasources = \Drupal::getContainer()
->get('search_api.plugin_helper')
->createDatasourcePlugins($this->index, [
'entity:user',
'search_api_test',
], [
'search_api_test' => [
$dependency_key => [
$dependency_name,
],
],
]);
$this->index
->setDatasources($datasources);
$this->index
->save();
// Check the dependencies were calculated correctly.
$dependencies = $this->index
->getDependencies();
$this
->assertContains($dependency_name, $dependencies[$dependency_key], 'Datasource dependency correctly inserted');
// Tell the datasource plugin whether it should successfully remove the
// dependency.
$this
->setReturnValue('datasource', 'onDependencyRemoval', $remove_dependency);
// Delete the datasource's dependency.
$this->dependency
->delete();
// Reload the index and check it's still there.
$this
->reloadIndex();
$this
->assertInstanceOf('Drupal\\search_api\\IndexInterface', $this->index, 'Index not removed');
// Make sure the dependency has been removed, one way or the other.
$dependencies = $this->index
->getDependencies();
$dependencies += [
$dependency_key => [],
];
$this
->assertNotContains($dependency_name, $dependencies[$dependency_key], 'Datasource dependency removed from index');
// Depending on whether the plugin should have removed the dependency or
// not, make sure the right action was taken.
$datasources = $this->index
->getDatasources();
if ($remove_dependency) {
$this
->assertArrayHasKey('search_api_test', $datasources, 'Datasource not removed');
$this
->assertEmpty($datasources['search_api_test']
->getConfiguration(), 'Datasource settings adapted');
}
else {
$this
->assertArrayNotHasKey('search_api_test', $datasources, 'Datasource removed');
}
}
/**
* Tests removing the (hard) dependency of the index's single datasource.
*/
public function testSingleDatasourceDependency() {
// Add the datasource to the index and save it. The datasource configuration
// contains the dependencies it will return – in our case, we use the test
// server.
$dependency_key = $this->dependency
->getConfigDependencyKey();
$dependency_name = $this->dependency
->getConfigDependencyName();
$datasources['search_api_test'] = \Drupal::getContainer()
->get('search_api.plugin_helper')
->createDatasourcePlugin($this->index, 'search_api_test', [
$dependency_key => [
$dependency_name,
],
]);
$this->index
->setDatasources($datasources);
$this->index
->save();
// Since in this test the index will be removed, we need a mock key/value
// store (the index will purge any unsaved configuration of it upon
// deletion, which uses a "user-shared temp store", which in turn uses a
// key/value store).
$mock = $this
->createMock(KeyValueStoreExpirableInterface::class);
$mock_factory = $this
->createMock(KeyValueExpirableFactoryInterface::class);
$mock_factory
->method('get')
->willReturn($mock);
$this->container
->set('keyvalue.expirable', $mock_factory);
// Delete the datasource's dependency.
$this->dependency
->delete();
// Reload the index to ensure it was deleted.
$this
->reloadIndex();
$this
->assertNull($this->index, 'Index was removed');
}
/**
* Tests a processor with a dependency that gets removed.
*
* @param bool $remove_dependency
* Whether to remove the dependency from the processor when the object
* depended on is deleted.
*
* @dataProvider dependencyTestDataProvider
*/
public function testProcessorDependency($remove_dependency) {
// Add the processor to the index and save it. The processor configuration
// contains the dependencies it will return – in our case, we use the test
// server.
$dependency_key = $this->dependency
->getConfigDependencyKey();
$dependency_name = $this->dependency
->getConfigDependencyName();
/** @var \Drupal\search_api\Processor\ProcessorInterface $processor */
$processor = \Drupal::getContainer()
->get('search_api.plugin_helper')
->createProcessorPlugin($this->index, 'search_api_test', [
$dependency_key => [
$dependency_name,
],
]);
$this->index
->addProcessor($processor);
$this->index
->save();
// Check the dependencies were calculated correctly.
$dependencies = $this->index
->getDependencies();
$this
->assertContains($dependency_name, $dependencies[$dependency_key], 'Processor dependency correctly inserted');
// Tell the processor plugin whether it should successfully remove the
// dependency.
$this
->setReturnValue('processor', 'onDependencyRemoval', $remove_dependency);
// Delete the processor's dependency.
$this->dependency
->delete();
// Reload the index and check it's still there.
$this
->reloadIndex();
$this
->assertInstanceOf('Drupal\\search_api\\IndexInterface', $this->index, 'Index not removed');
// Make sure the dependency has been removed, one way or the other.
$dependencies = $this->index
->getDependencies();
$dependencies += [
$dependency_key => [],
];
$this
->assertNotContains($dependency_name, $dependencies[$dependency_key], 'Processor dependency removed from index');
// Depending on whether the plugin should have removed the dependency or
// not, make sure the right action was taken.
$processors = $this->index
->getProcessors();
if ($remove_dependency) {
$this
->assertArrayHasKey('search_api_test', $processors, 'Processor not removed');
$this
->assertEmpty($processors['search_api_test']
->getConfiguration(), 'Processor settings adapted');
}
else {
$this
->assertArrayNotHasKey('search_api_test', $processors, 'Processor removed');
}
}
/**
* Tests a tracker with a dependency that gets removed.
*
* @param bool $remove_dependency
* Whether to remove the dependency from the tracker when the object
* depended on is deleted.
*
* @dataProvider dependencyTestDataProvider
*/
public function testTrackerDependency($remove_dependency) {
// Set the tracker for the index and save it. The tracker configuration
// contains the dependencies it will return – in our case, we use the test
// server.
$dependency_key = $this->dependency
->getConfigDependencyKey();
$dependency_name = $this->dependency
->getConfigDependencyName();
/** @var \Drupal\search_api\Tracker\TrackerInterface $tracker */
$tracker = \Drupal::getContainer()
->get('search_api.plugin_helper')
->createTrackerPlugin($this->index, 'search_api_test', [
'dependencies' => [
$dependency_key => [
$dependency_name,
],
],
]);
$this->index
->setTracker($tracker);
$this->index
->save();
// Check the dependencies were calculated correctly.
$dependencies = $this->index
->getDependencies();
$this
->assertContains($dependency_name, $dependencies[$dependency_key], 'Tracker dependency correctly inserted');
// Tell the datasource plugin whether it should successfully remove the
// dependency.
$this
->setReturnValue('tracker', 'onDependencyRemoval', $remove_dependency);
// Delete the tracker's dependency.
$this->dependency
->delete();
// Reload the index and check it's still there.
$this
->reloadIndex();
$this
->assertInstanceOf('Drupal\\search_api\\IndexInterface', $this->index, 'Index not removed');
// Make sure the dependency has been removed, one way or the other.
$dependencies = $this->index
->getDependencies();
$dependencies += [
$dependency_key => [],
];
$this
->assertNotContains($dependency_name, $dependencies[$dependency_key], 'Tracker dependency removed from index');
// Depending on whether the plugin should have removed the dependency or
// not, make sure the right action was taken.
$tracker_instance = $this->index
->getTrackerInstance();
$tracker_id = $tracker_instance
->getPluginId();
$tracker_config = $tracker_instance
->getConfiguration();
if ($remove_dependency) {
$this
->assertEquals('search_api_test', $tracker_id, 'Tracker not reset');
$this
->assertEmpty($tracker_config['dependencies'], 'Tracker settings adapted');
}
else {
$this
->assertEquals('default', $tracker_id, 'Tracker was reset');
$this
->assertEquals($tracker_instance
->defaultConfiguration(), $tracker_config, 'Tracker settings were cleared');
}
}
/**
* Data provider for this class's test methods.
*
* If $remove_dependency is TRUE, in Plugin::onDependencyRemoval() it clears
* its configuration (and thus its dependency, in those test plugins) and
* returns TRUE, which the index will take as "all OK, dependency removed" and
* leave the plugin where it is, only with updated configuration.
*
* If $remove_dependency is FALSE, Plugin::onDependencyRemoval() will do
* nothing and just return FALSE, the index says "oh, that plugin still has
* that removed dependency, so I should better remove the plugin" and the
* plugin gets removed.
*
* @return array
* An array of argument arrays for this class's test methods.
*/
public function dependencyTestDataProvider() {
return [
'Remove dependency' => [
TRUE,
],
'Keep dependency' => [
FALSE,
],
];
}
/**
* Tests whether module dependencies are handled correctly.
*/
public function testModuleDependency() {
// Test with all types of plugins at once.
/** @var \Drupal\search_api\Datasource\DatasourceInterface $datasource */
$datasource = \Drupal::getContainer()
->get('search_api.plugin_helper')
->createDatasourcePlugin($this->index, 'search_api_test');
$this->index
->addDatasource($datasource);
$datasource = \Drupal::getContainer()
->get('search_api.plugin_helper')
->createDatasourcePlugin($this->index, 'entity:user');
$this->index
->addDatasource($datasource);
/** @var \Drupal\search_api\Processor\ProcessorInterface $processor */
$processor = \Drupal::getContainer()
->get('search_api.plugin_helper')
->createProcessorPlugin($this->index, 'search_api_test');
$this->index
->addProcessor($processor);
/** @var \Drupal\search_api\Tracker\TrackerInterface $tracker */
$tracker = \Drupal::getContainer()
->get('search_api.plugin_helper')
->createTrackerPlugin($this->index, 'search_api_test');
$this->index
->setTracker($tracker);
$this->index
->save();
// Check the dependencies were calculated correctly.
$dependencies = $this->index
->getDependencies();
$this
->assertContains('search_api_test', $dependencies['module'], 'Module dependency correctly inserted');
// When the index resets the tracker, it needs to know the ID of the default
// tracker.
$this
->installConfig('search_api');
// Disabling modules in Kernel tests normally doesn't trigger any kind of
// reaction, just removes it from the list of modules (for example, to avoid
// calling of a hook). Therefore, we have to trigger that behavior
// ourselves.
\Drupal::getContainer()
->get('config.manager')
->uninstall('module', 'search_api_test');
// Reload the index and check it's still there.
$this
->reloadIndex();
$this
->assertInstanceOf('Drupal\\search_api\\IndexInterface', $this->index, 'Index not removed');
// Make sure the dependency has been removed.
$dependencies = $this->index
->getDependencies();
$dependencies += [
'module' => [],
];
$this
->assertNotContains('search_api_test', $dependencies['module'], 'Module dependency removed from index');
// Make sure all the plugins have been removed.
$this
->assertNotContains('search_api_test', $this->index
->getDatasources(), 'Datasource was removed');
$this
->assertArrayNotHasKey('search_api_test', $this->index
->getProcessors(), 'Processor was removed');
$this
->assertEquals('default', $this->index
->getTrackerId(), 'Tracker was reset');
}
/**
* Tests whether dependencies of used data types are handled correctly.
*
* @param string $dependency_type
* The type of dependency that should be set on the data type (and then
* removed): "module" or "config".
*
* @dataProvider dataTypeDependencyTestDataProvider
*/
public function testDataTypeDependency($dependency_type) {
switch ($dependency_type) {
case 'module':
$type = 'search_api_test';
$config_dependency_key = 'module';
$config_dependency_name = 'search_api_test';
break;
case 'config':
$type = 'search_api_test_altering';
$config_dependency_key = $this->dependency
->getConfigDependencyKey();
$config_dependency_name = $this->dependency
->getConfigDependencyName();
\Drupal::state()
->set('search_api_test.data_type.dependencies', [
$config_dependency_key => [
$config_dependency_name,
],
]);
break;
default:
$this
->fail();
return;
}
// Use the "user" datasource (to not get a module dependency via that) and
// add a field with the given data type.
$datasources = \Drupal::getContainer()
->get('search_api.plugin_helper')
->createDatasourcePlugins($this->index, [
'entity:user',
]);
$this->index
->setDatasources($datasources);
$field = \Drupal::getContainer()
->get('search_api.fields_helper')
->createField($this->index, 'uid', [
'label' => 'ID',
'datasource_id' => 'entity:user',
'property_path' => 'uid',
'type' => $type,
]);
$this->index
->addField($field);
// Set the server to NULL to not have a dependency on that by default.
$this->index
->setServer(NULL);
$this->index
->save();
// Check the dependencies were calculated correctly.
$dependencies = $this->index
->getDependencies();
$dependencies += [
$config_dependency_key => [],
];
$this
->assertContains($config_dependency_name, $dependencies[$config_dependency_key], 'Data type dependency correctly inserted');
switch ($dependency_type) {
case 'module':
// Disabling modules in Kernel tests normally doesn't trigger any kind of
// reaction, just removes it from the list of modules (for example, to
// avoid calling any of its hooks). Therefore, we have to trigger that
// behavior ourselves.
\Drupal::getContainer()
->get('config.manager')
->uninstall('module', 'search_api_test');
break;
case 'config':
$this->dependency
->delete();
break;
}
// Reload the index and check it's still there.
$this
->reloadIndex();
$this
->assertInstanceOf('Drupal\\search_api\\IndexInterface', $this->index, 'Index not removed');
// Make sure the dependency has been removed.
$dependencies = $this->index
->getDependencies();
$dependencies += [
$config_dependency_key => [],
];
$this
->assertNotContains($config_dependency_name, $dependencies[$config_dependency_key], 'Data type dependency correctly removed');
// Make sure the field type has changed.
$field = $this->index
->getField('uid');
$this
->assertNotNull($field, 'Field was not removed');
$this
->assertEquals('string', $field
->getType(), 'Field type was changed to fallback type');
}
/**
* Data provider for testDataTypeDependency().
*
* @return array
* An array of argument arrays for
* \Drupal\Tests\search_api\Kernel\DependencyRemovalTest::testDataTypeDependency().
*/
public function dataTypeDependencyTestDataProvider() {
return [
'Module dependency' => [
'module',
],
'Config dependency' => [
'config',
],
];
}
/**
* Reloads the index with the latest copy from storage.
*/
protected function reloadIndex() {
$storage = \Drupal::entityTypeManager()
->getStorage('search_api_index');
$storage
->resetCache();
$this->index = $storage
->load($this->index
->id());
}
}
Members
Name | Modifiers | Type | Description | Overrides |
---|---|---|---|---|
AssertContentTrait:: |
protected | property | The current raw content. | |
AssertContentTrait:: |
protected | property | The drupalSettings value from the current raw $content. | |
AssertContentTrait:: |
protected | property | The XML structure parsed from the current raw $content. | 1 |
AssertContentTrait:: |
protected | property | The plain-text content of raw $content (text nodes). | |
AssertContentTrait:: |
protected | function | Passes if the raw text IS found escaped on the loaded page, fail otherwise. | |
AssertContentTrait:: |
protected | function | Asserts that a field exists with the given name or ID. | |
AssertContentTrait:: |
protected | function | Asserts that a field exists with the given ID and value. | |
AssertContentTrait:: |
protected | function | Asserts that a field exists with the given name and value. | |
AssertContentTrait:: |
protected | function | Asserts that a field exists in the current page by the given XPath. | |
AssertContentTrait:: |
protected | function | Asserts that a checkbox field in the current page is checked. | |
AssertContentTrait:: |
protected | function | Asserts that a field exists in the current page with a given Xpath result. | |
AssertContentTrait:: |
protected | function | Passes if a link with the specified label is found. | |
AssertContentTrait:: |
protected | function | Passes if a link containing a given href (part) is found. | |
AssertContentTrait:: |
protected | function | Asserts that each HTML ID is used for just a single element. | |
AssertContentTrait:: |
protected | function | Passes if the raw text IS NOT found escaped on the loaded page, fail otherwise. | |
AssertContentTrait:: |
protected | function | Asserts that a field does not exist with the given name or ID. | |
AssertContentTrait:: |
protected | function | Asserts that a field does not exist with the given ID and value. | |
AssertContentTrait:: |
protected | function | Asserts that a field does not exist with the given name and value. | |
AssertContentTrait:: |
protected | function | Asserts that a field does not exist or its value does not match, by XPath. | |
AssertContentTrait:: |
protected | function | Asserts that a checkbox field in the current page is not checked. | |
AssertContentTrait:: |
protected | function | Passes if a link with the specified label is not found. | |
AssertContentTrait:: |
protected | function | Passes if a link containing a given href (part) is not found. | |
AssertContentTrait:: |
protected | function | Passes if a link containing a given href is not found in the main region. | |
AssertContentTrait:: |
protected | function | Asserts that a select option in the current page does not exist. | |
AssertContentTrait:: |
protected | function | Asserts that a select option in the current page is not checked. | |
AssertContentTrait:: |
protected | function | Triggers a pass if the perl regex pattern is not found in raw content. | |
AssertContentTrait:: |
protected | function | Passes if the raw text is NOT found on the loaded page, fail otherwise. | |
AssertContentTrait:: |
protected | function | Passes if the page (with HTML stripped) does not contains the text. | |
AssertContentTrait:: |
protected | function | Pass if the page title is not the given string. | |
AssertContentTrait:: |
protected | function | Passes if the text is found MORE THAN ONCE on the text version of the page. | |
AssertContentTrait:: |
protected | function | Asserts that a select option in the current page exists. | |
AssertContentTrait:: |
protected | function | Asserts that a select option with the visible text exists. | |
AssertContentTrait:: |
protected | function | Asserts that a select option in the current page is checked. | |
AssertContentTrait:: |
protected | function | Asserts that a select option in the current page is checked. | |
AssertContentTrait:: |
protected | function | Asserts that a select option in the current page exists. | |
AssertContentTrait:: |
protected | function | Triggers a pass if the Perl regex pattern is found in the raw content. | |
AssertContentTrait:: |
protected | function | Passes if the raw text IS found on the loaded page, fail otherwise. | |
AssertContentTrait:: |
protected | function | Passes if the page (with HTML stripped) contains the text. | |
AssertContentTrait:: |
protected | function | Helper for assertText and assertNoText. | |
AssertContentTrait:: |
protected | function | Asserts that a Perl regex pattern is found in the plain-text content. | |
AssertContentTrait:: |
protected | function | Asserts themed output. | |
AssertContentTrait:: |
protected | function | Pass if the page title is the given string. | |
AssertContentTrait:: |
protected | function | Passes if the text is found ONLY ONCE on the text version of the page. | |
AssertContentTrait:: |
protected | function | Helper for assertUniqueText and assertNoUniqueText. | |
AssertContentTrait:: |
protected | function | Builds an XPath query. | |
AssertContentTrait:: |
protected | function | Helper: Constructs an XPath for the given set of attributes and value. | |
AssertContentTrait:: |
protected | function | Searches elements using a CSS selector in the raw content. | |
AssertContentTrait:: |
protected | function | Get all option elements, including nested options, in a select. | |
AssertContentTrait:: |
protected | function | Gets the value of drupalSettings for the currently-loaded page. | |
AssertContentTrait:: |
protected | function | Gets the current raw content. | |
AssertContentTrait:: |
protected | function | Get the selected value from a select field. | |
AssertContentTrait:: |
protected | function | Retrieves the plain-text content from the current raw content. | |
AssertContentTrait:: |
protected | function | Get the current URL from the cURL handler. | 1 |
AssertContentTrait:: |
protected | function | Parse content returned from curlExec using DOM and SimpleXML. | |
AssertContentTrait:: |
protected | function | Removes all white-space between HTML tags from the raw content. | |
AssertContentTrait:: |
protected | function | Sets the value of drupalSettings for the currently-loaded page. | |
AssertContentTrait:: |
protected | function | Sets the raw content (e.g. HTML). | |
AssertContentTrait:: |
protected | function | Performs an xpath search on the contents of the internal browser. | |
AssertHelperTrait:: |
protected static | function | Casts MarkupInterface objects into strings. | |
AssertLegacyTrait:: |
protected | function | Deprecated Scheduled for removal in Drupal 10.0.0. Use self::assertTrue() instead. | |
AssertLegacyTrait:: |
protected | function | Deprecated Scheduled for removal in Drupal 10.0.0. Use self::assertEquals() instead. | |
AssertLegacyTrait:: |
protected | function | Deprecated Scheduled for removal in Drupal 10.0.0. Use self::assertSame() instead. | |
AssertLegacyTrait:: |
protected | function | Deprecated Scheduled for removal in Drupal 10.0.0. Use self::assertEquals() instead. | |
AssertLegacyTrait:: |
protected | function | Deprecated Scheduled for removal in Drupal 10.0.0. Use self::assertNotEquals() instead. | |
AssertLegacyTrait:: |
protected | function | Deprecated Scheduled for removal in Drupal 10.0.0. Use self::assertNotSame() instead. | |
AssertLegacyTrait:: |
protected | function | Deprecated Scheduled for removal in Drupal 10.0.0. Use self::assertTrue() instead. | |
AssertLegacyTrait:: |
protected | function | ||
ConfigTestTrait:: |
protected | function | Returns a ConfigImporter object to import test configuration. | |
ConfigTestTrait:: |
protected | function | Copies configuration objects from source storage to target storage. | |
DependencyRemovalTest:: |
protected | property | A config entity, to be used as a dependency in the tests. | |
DependencyRemovalTest:: |
protected | property | A search index. | |
DependencyRemovalTest:: |
public static | property |
Modules to enable. Overrides KernelTestBase:: |
|
DependencyRemovalTest:: |
public | function | Data provider for testDataTypeDependency(). | |
DependencyRemovalTest:: |
public | function | Data provider for this class's test methods. | |
DependencyRemovalTest:: |
protected | function | Reloads the index with the latest copy from storage. | |
DependencyRemovalTest:: |
public | function |
Overrides KernelTestBase:: |
|
DependencyRemovalTest:: |
public | function | Tests a backend with a dependency that gets removed. | |
DependencyRemovalTest:: |
public | function | Tests a datasource with a dependency that gets removed. | |
DependencyRemovalTest:: |
public | function | Tests whether dependencies of used data types are handled correctly. | |
DependencyRemovalTest:: |
public | function | Tests index with a field dependency that gets removed. | |
DependencyRemovalTest:: |
public | function | Tests whether module dependencies are handled correctly. | |
DependencyRemovalTest:: |
public | function | Tests a processor with a dependency that gets removed. | |
DependencyRemovalTest:: |
public | function | Tests removing the (hard) dependency of the index's single datasource. | |
DependencyRemovalTest:: |
public | function | Tests a tracker with a dependency that gets removed. | |
EntityReferenceTestTrait:: |
protected | function | Creates a field of an entity reference field storage on the specified bundle. | |
KernelTestBase:: |
protected | property | Back up and restore any global variables that may be changed by tests. | |
KernelTestBase:: |
protected | property | Back up and restore static class properties that may be changed by tests. | |
KernelTestBase:: |
protected | property | Contains a few static class properties for performance. | |
KernelTestBase:: |
protected | property | ||
KernelTestBase:: |
protected | property | @todo Move into Config test base class. | 7 |
KernelTestBase:: |
protected static | property | An array of config object names that are excluded from schema checking. | |
KernelTestBase:: |
protected | property | ||
KernelTestBase:: |
protected | property | ||
KernelTestBase:: |
protected | property | Do not forward any global state from the parent process to the processes that run the actual tests. | |
KernelTestBase:: |
protected | property | The app root. | |
KernelTestBase:: |
protected | property | Kernel tests are run in separate processes because they allow autoloading of code from extensions. Running the test in a separate process isolates this behavior from other tests. Subclasses should not override this property. | |
KernelTestBase:: |
protected | property | ||
KernelTestBase:: |
protected | property | Set to TRUE to strict check all configuration saved. | 6 |
KernelTestBase:: |
protected | property | The virtual filesystem root directory. | |
KernelTestBase:: |
protected | function | 1 | |
KernelTestBase:: |
protected | function | Bootstraps a basic test environment. | |
KernelTestBase:: |
private | function | Bootstraps a kernel for a test. | |
KernelTestBase:: |
protected | function | Configuration accessor for tests. Returns non-overridden configuration. | |
KernelTestBase:: |
protected | function | Disables modules for this test. | |
KernelTestBase:: |
protected | function | Enables modules for this test. | |
KernelTestBase:: |
protected | function | Gets the config schema exclusions for this test. | |
KernelTestBase:: |
protected | function | Returns the Database connection info to be used for this test. | 1 |
KernelTestBase:: |
public | function | ||
KernelTestBase:: |
private | function | Returns Extension objects for $modules to enable. | |
KernelTestBase:: |
private static | function | Returns the modules to enable for this test. | |
KernelTestBase:: |
protected | function | Initializes the FileCache component. | |
KernelTestBase:: |
protected | function | Installs default configuration for a given list of modules. | |
KernelTestBase:: |
protected | function | Installs the storage schema for a specific entity type. | |
KernelTestBase:: |
protected | function | Installs database tables from a module schema definition. | |
KernelTestBase:: |
protected | function | Returns whether the current test method is running in a separate process. | |
KernelTestBase:: |
protected | function | ||
KernelTestBase:: |
public | function |
Registers test-specific services. Overrides ServiceProviderInterface:: |
26 |
KernelTestBase:: |
protected | function | Renders a render array. | 1 |
KernelTestBase:: |
protected | function | Sets the install profile and rebuilds the container to update it. | |
KernelTestBase:: |
protected | function | Sets an in-memory Settings variable. | |
KernelTestBase:: |
public static | function | 1 | |
KernelTestBase:: |
protected | function | Sets up the filesystem, so things like the file directory. | 2 |
KernelTestBase:: |
protected | function | Stops test execution. | |
KernelTestBase:: |
protected | function | 6 | |
KernelTestBase:: |
public | function | @after | |
KernelTestBase:: |
protected | function | Dumps the current state of the virtual filesystem to STDOUT. | |
KernelTestBase:: |
public | function | BC: Automatically resolve former KernelTestBase class properties. | |
KernelTestBase:: |
public | function | Prevents serializing any properties. | |
PhpunitCompatibilityTrait:: |
public | function | Returns a mock object for the specified class using the available method. | |
PhpunitCompatibilityTrait:: |
public | function | Compatibility layer for PHPUnit 6 to support PHPUnit 4 code. | |
PluginTestTrait:: |
protected | function | Retrieves the methods called on a given plugin. | |
PluginTestTrait:: |
protected | function | Retrieves the arguments of a certain method called on the given plugin. | |
PluginTestTrait:: |
protected | function | Sets an exception to be thrown on calls to the given method. | |
PluginTestTrait:: |
protected | function | Overrides a method for a certain plugin. | |
PluginTestTrait:: |
protected | function | Sets the return value for a certain method on a test plugin. | |
RandomGeneratorTrait:: |
protected | property | The random generator. | |
RandomGeneratorTrait:: |
protected | function | Gets the random generator for the utility methods. | |
RandomGeneratorTrait:: |
protected | function | Generates a unique random string containing letters and numbers. | 1 |
RandomGeneratorTrait:: |
public | function | Generates a random PHP object. | |
RandomGeneratorTrait:: |
public | function | Generates a pseudo-random string of ASCII characters of codes 32 to 126. | |
RandomGeneratorTrait:: |
public | function | Callback for random string validation. | |
StorageCopyTrait:: |
protected static | function | Copy the configuration from one storage to another and remove stale items. | |
TestRequirementsTrait:: |
private | function | Checks missing module requirements. | |
TestRequirementsTrait:: |
protected | function | Check module requirements for the Drupal use case. | 1 |
TestRequirementsTrait:: |
protected static | function | Returns the Drupal root directory. |