diff --git a/src/Tests/LanguageIntegrationTest.php b/src/Tests/LanguageIntegrationTest.php index 3709f08..0202163 100644 --- a/src/Tests/LanguageIntegrationTest.php +++ b/src/Tests/LanguageIntegrationTest.php @@ -32,48 +32,49 @@ class LanguageIntegrationTest extends WebTestBase { public static $modules = array('node', 'search_api', 'search_api_test_backend', 'language'); /** - * Tests language specific operations trough the UI. + * Make sure multilingual content entities are tracked correctly. */ - public function testFramework() { + public function testMultilingualContentEntityTracking() { $this->drupalLogin($this->adminUser); $this->getTestServer(); $index = $this->getTestIndex(); $this->indexId = $index->id(); - $this->checkMultilingualContentEntityTracking(); - } - - /** - * Make sure multilingual content entities are tracked correctly. - */ - protected function checkMultilingualContentEntityTracking() { ConfigurableLanguage::createFromLangcode('nl')->save(); - // Create 2 articles + // Create 2 articles. $article1 = $this->drupalCreateNode(array('type' => 'article')); - $this->drupalCreateNode(array('type' => 'article')); + $article2 = $this->drupalCreateNode(array('type' => 'article')); // Those 2 new nodes should be added to the tracking table immediately. $tracked_items = $this->countTrackedItems(); $this->assertEqual($tracked_items, 2, 'Two items are tracked.'); - // Add a translation - $article1->addTranslation('nl', array('title' => 'test NL', 'body' => 'Dutch body')) - ->save(); + // Add a dutch translation for both articles. + $article1->addTranslation('nl', array('title' => 'test NL'))->save(); + $article2->addTranslation('nl', array('title' => 'test2 NL'))->save(); - // The translation should be tracked as well + // The translations should be tracked as well. $tracked_items = $this->countTrackedItems(); - $this->assertEqual($tracked_items, 3, 'Two items are tracked.'); + $this->assertEqual($tracked_items, 4, 'Four items are tracked.'); + // Check that all items are indexed correctly. $this->drupalGet($this->getIndexPath()); - $this->assertText('3/3 indexed'); + $this->assertText('4/4 indexed'); - $this->drupalPostForm(NULL, array(), $this->t('Queue all items for reindexing')); + // Clear the index. + $this->drupalPostForm(NULL, array(), $this->t('Clear all indexed data')); $this->drupalPostForm(NULL, array(), $this->t('Confirm')); - $this->drupalPostForm(NULL, array(), $this->t('Index now')); - $this->assertText('Successfully indexed 3 items.'); + // All 4 items should still be in the tracker. + $tracked_items = $this->countTrackedItems(); + $this->assertEqual($tracked_items, 4, 'Four items are tracked.'); + + // After indexing all items again, 4 items should be in the index. + $this->drupalPostForm(NULL, array(), $this->t('Index now')); + $this->assertText('Successfully indexed 4 items.'); + $this->assertText('4/4 indexed'); } /**