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