diff -u b/tests/search_api_test_excerpt/config/install/views.view.search_api_test_search_excerpt.yml b/tests/search_api_test_excerpt/config/install/views.view.search_api_test_search_excerpt.yml --- b/tests/search_api_test_excerpt/config/install/views.view.search_api_test_search_excerpt.yml +++ b/tests/search_api_test_excerpt/config/install/views.view.search_api_test_search_excerpt.yml @@ -1,17 +1,9 @@ -status: true -dependencies: - config: - - search_api.index.database_search_index - module: - - search_api id: search_api_test_search_excerpt -label: 'Search API Test search excerpt' -module: views -description: '' -tag: '' -base_table: search_api_index_database_search_index base_field: search_api_id +base_table: search_api_index_database_search_index core: 8.x +description: '' +status: true display: default: display_plugin: default @@ -23,14 +15,16 @@ type: none options: { } cache: - type: tag + type: none options: { } query: - type: views_query + type: search_api_query + options: + skip_access: true exposed_form: type: basic options: - submit_button: Apply + submit_button: Search reset_button: false reset_button_label: Reset exposed_sorts_label: 'Sort by' @@ -38,16 +32,28 @@ sort_asc_label: Asc sort_desc_label: Desc pager: - type: none + type: full options: - items_per_page: null + items_per_page: 10 offset: 0 + id: 0 + total_pages: null + expose: + items_per_page: false + items_per_page_label: 'Items per page' + items_per_page_options: '5, 10, 20, 40, 60' + items_per_page_options_all: false + items_per_page_options_all_label: '- All -' + offset: false + offset_label: Offset + tags: + previous: '‹ previous' + next: 'next ›' + first: '« first' + last: 'last »' + quantity: 9 style: type: default - options: - grouping: { } - row_class: '' - default_row_class: true row: type: fields options: @@ -214,8 +220,2 @@ - display_extenders: { } path: search-api-test-search-excerpt - cache_metadata: - max-age: -1 - contexts: - - 'languages:language_content' - - 'languages:language_interface' - tags: { } + diff -u b/tests/src/Functional/EmptyQueryStringExcerptTest.php b/tests/src/Functional/EmptyQueryStringExcerptTest.php --- b/tests/src/Functional/EmptyQueryStringExcerptTest.php +++ b/tests/src/Functional/EmptyQueryStringExcerptTest.php @@ -24,29 +24,16 @@ use ExampleContentTrait; /** - * The test server. - * - * @var \Drupal\search_api\ServerInterface - */ - protected $server; - - /** - * The index mock used for the tests. - * - * @var \Drupal\search_api\IndexInterface - */ - protected $index; - - /** * Modules to enable for this test. * * @var string[] */ public static $modules = [ + 'block', 'language', - 'search_api_test_views', - 'search_api_test_example_content', 'search_api_test_excerpt', + 'search_api_test_views', + 'views_ui', ]; /** @@ -54,15 +41,14 @@ */ public function setUp() { parent::setUp(); - + $this->drupalLogin($this->adminUser); - $this->server = $this->getTestServer(); - $this->index = $this->getTestIndex(); \Drupal::getContainer() ->get('search_api.index_task_manager') - ->addItemsAll($this->index); + ->addItemsAll(Index::load($this->indexId)); $this->insertExampleContent(); + $this->indexItems($this->indexId); // Do not use a batch for tracking the initial items after creating an // index when running the tests via the GUI. Otherwise, it seems Drupal's @@ -76,17 +62,16 @@ * Tests the functionality with excerpt_always disabled. */ public function testExcerptAlwaysDisabled() { - // Ensure that 'excerpt_always' is off and highlight is on. - $this->drupalGet('admin/config/search/search-api/index/' . $this->index->id() . '/processors'); - $editForm = 'admin/config/search/search-api/index/' . $this->index->id() . '/processors'; + // Set the 'excerpt_always' setting. + $this->drupalGet('admin/config/search/search-api/index/' . $this->indexId . '/processors'); + $editForm = 'admin/config/search/search-api/index/' . $this->indexId . '/processors'; $form = [ 'status[highlight]' => 1, 'processors[highlight][settings][excerpt_always]' => 0, ]; $this->drupalPostForm($editForm, $form, 'Save'); - $this->index->indexItems(); - $this->drupalGet('admin/config/search/search-api/index/' . $this->index->id()); + $this->drupalGet('admin/config/search/search-api/index/' . $this->indexId); // Get the output of the view created in search_api_test_excerpt module. $this->drupalGet('search-api-test-search-excerpt'); @@ -103,16 +88,15 @@ public function testExcerptAlwaysEnabled() { // Set the 'excerpt_always' setting. - $this->drupalGet('admin/config/search/search-api/index/' . $this->index->id() . '/processors'); - $editForm = 'admin/config/search/search-api/index/' . $this->index->id() . '/processors'; + $this->drupalGet('admin/config/search/search-api/index/' . $this->indexId . '/processors'); + $editForm = 'admin/config/search/search-api/index/' . $this->indexId . '/processors'; $form = [ 'status[highlight]' => 1, 'processors[highlight][settings][excerpt_always]' => 1, ]; $this->drupalPostForm($editForm, $form, 'Save'); - $this->index->indexItems(); - $this->drupalGet('admin/config/search/search-api/index/' . $this->index->id()); + $this->drupalGet('admin/config/search/search-api/index/' . $this->indexId); // Get the output of the view created in search_api_test_excerpt module. $this->drupalGet('search-api-test-search-excerpt'); @@ -125,2 +109,19 @@ + /** + * {@inheritdoc} + */ + protected function initConfig(ContainerInterface $container) { + parent::initConfig($container); + + // This will just set the Drupal state to include the necessary bundles for + // our test entity type. Otherwise, fields from those bundles won't be found + // and thus removed from the test index. (We can't do it in setUp(), before + // calling the parent method, since the container isn't set up at that + // point.) + $bundles = [ + 'entity_test_mulrev_changed' => ['label' => 'Entity Test Bundle'], + 'item' => ['label' => 'item'], + 'article' => ['label' => 'article'], ]; + \Drupal::state()->set('entity_test_mulrev_changed.bundles', $bundles); + } }