Chris@0: drupalCreateUser(['administer nodes', 'administer content types', 'administer languages', 'administer content translation', 'access content', 'search content']); Chris@0: $this->drupalLogin($user); Chris@0: Chris@0: // Add Spanish language programmatically. Chris@0: ConfigurableLanguage::createFromLangcode('es')->save(); Chris@0: Chris@0: // Create a content type and make it translatable. Chris@0: $type = $this->drupalCreateContentType(); Chris@0: $edit = [ Chris@0: 'language_configuration[language_alterable]' => TRUE, Chris@0: ]; Chris@0: $this->drupalPostForm('admin/structure/types/manage/' . $type->id(), $edit, t('Save content type')); Chris@0: $edit = [ Chris@0: 'entity_types[node]' => TRUE, Chris@0: 'settings[node][' . $type->id() . '][translatable]' => TRUE, Chris@0: 'settings[node][' . $type->id() . '][fields][title]' => TRUE, Chris@0: 'settings[node][' . $type->id() . '][fields][body]' => TRUE, Chris@0: ]; Chris@0: $this->drupalPostForm('admin/config/regional/content-language', $edit, t('Save configuration')); Chris@0: Chris@0: // Add a node in English, with title "sandwich". Chris@0: $values = [ Chris@0: 'title' => 'sandwich', Chris@0: 'type' => $type->id(), Chris@0: ]; Chris@0: $node = $this->drupalCreateNode($values); Chris@0: Chris@0: // "Translate" this node into Spanish, with title "pizza". Chris@0: $node->addTranslation('es', ['title' => 'pizza', 'status' => NodeInterface::PUBLISHED]); Chris@0: $node->save(); Chris@0: Chris@0: // Run cron so that the search index tables are updated. Chris@0: $this->cronRun(); Chris@0: Chris@0: // Test the keyword filter by visiting the page. Chris@0: // The views are in the test view 'test_search', and they just display the Chris@0: // titles of the nodes in the result, as links. Chris@0: Chris@0: // Page with a keyword filter of 'pizza'. This should find the Spanish Chris@0: // translated node, which has 'pizza' in the title, but not the English Chris@0: // one, which does not have the word 'pizza' in it. Chris@0: $this->drupalGet('test-filter'); Chris@0: $this->assertLink('pizza', 0, 'Found translation with matching title'); Chris@0: $this->assertNoLink('sandwich', 'Did not find translation with non-matching title'); Chris@0: } Chris@0: Chris@0: }