Chris@4: drupalCreateContentType(['type' => 'page', 'name' => 'Basic page']); Chris@4: $this->drupalCreateContentType(['type' => 'article', 'name' => 'Article']); Chris@4: Chris@4: // Log in with sufficient privileges. Chris@4: $this->drupalLogin($this->drupalCreateUser(['create page content', 'search content'])); Chris@4: Chris@4: // Create a node and an article with the same keyword. The query alter Chris@4: // test module will alter the query so only articles should be returned. Chris@4: $data = [ Chris@4: 'type' => 'page', Chris@4: 'title' => 'test page', Chris@4: 'body' => [['value' => 'pizza']], Chris@4: ]; Chris@4: $this->drupalCreateNode($data); Chris@4: Chris@4: $data['type'] = 'article'; Chris@4: $data['title'] = 'test article'; Chris@4: $this->drupalCreateNode($data); Chris@4: Chris@4: // Update the search index. Chris@4: $this->container->get('plugin.manager.search')->createInstance('node_search')->updateIndex(); Chris@4: search_update_totals(); Chris@4: Chris@4: // Search for the body keyword 'pizza'. Chris@4: $this->drupalPostForm('search/node', ['keys' => 'pizza'], t('Search')); Chris@4: // The article should be there but not the page. Chris@4: $this->assertText('article', 'Article is in search results'); Chris@4: $this->assertNoText('page', 'Page is not in search results'); Chris@4: } Chris@4: Chris@4: }