public function HooksTest::setUp in Search API 8
Overrides SearchApiBrowserTestBase::setUp
File
- tests/
src/ Functional/ HooksTest.php, line 39
Class
- HooksTest
- Tests integration of hooks.
Namespace
Drupal\Tests\search_api\FunctionalCode
public function setUp() {
parent::setUp();
// Create some nodes.
$this
->drupalCreateNode([
'type' => 'page',
'title' => 'node - 1',
]);
$this
->drupalCreateNode([
'type' => 'page',
'title' => 'node - 2',
]);
$this
->drupalCreateNode([
'type' => 'page',
'title' => 'node - 3',
]);
$this
->drupalCreateNode([
'type' => 'page',
'title' => 'node - 4',
]);
// Create an index and server to work with.
$this->server = $this
->getTestServer();
$index = $this
->getTestIndex();
// Add the test processor to the index so we can make sure that all expected
// processor methods are called, too.
/** @var \Drupal\search_api\Processor\ProcessorInterface $processor */
$processor = \Drupal::getContainer()
->get('search_api.plugin_helper')
->createProcessorPlugin($index, 'search_api_test');
$index
->addProcessor($processor)
->save();
// Parts of this test actually use the "database_search_index" from the
// search_api_test_db module (via the test view). Set the processor there,
// too.
$index = Index::load('database_search_index');
$processor = \Drupal::getContainer()
->get('search_api.plugin_helper')
->createProcessorPlugin($index, 'search_api_test');
$index
->addProcessor($processor)
->save();
// Reset the called methods on the processor.
$this
->getCalledMethods('processor');
// Log in, so we can test all the things.
$this
->drupalLogin($this->adminUser);
}