protected function SavedSearchCrudTest::setUp in Search API Saved Searches 8
Overrides KernelTestBase::setUp
File
- tests/
src/ Kernel/ SavedSearchCrudTest.php, line 52
Class
- SavedSearchCrudTest
- Tests CRUD functionality for saved searches.
Namespace
Drupal\Tests\search_api_saved_searches\KernelCode
protected function setUp() {
parent::setUp();
$this
->installEntitySchema('user');
$this
->installEntitySchema('search_api_saved_search');
$this
->installEntitySchema('search_api_task');
$this
->installConfig('search_api_saved_searches');
$this
->installSchema('system', [
'key_value_expire',
'sequences',
]);
$this
->installSchema('search_api_saved_searches', 'search_api_saved_searches_old_results');
$this->newResultsCheck = $this
->createMock(NewResultsCheck::class);
// Using an object instead of an array gives us automatic pass-by-reference.
$method_log = (object) [];
$this->newResultsCheck
->method('getNewResults')
->willReturnCallback(function (SavedSearchInterface $search) use ($method_log) {
$method_log->getNewResults[] = [
$search
->id(),
];
});
$this->newResultsCheck
->method('saveKnownResults')
->willReturnCallback(function (SavedSearchInterface $search) use ($method_log) {
$method_log->saveKnownResults[] = [
$search
->id(),
];
});
$this->newResultsCheckMethodCalls = $method_log;
$this->container
->set('search_api_saved_searches.new_results_check', $this->newResultsCheck);
}