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