X-Git-Url: http://www.aleph1.co.uk/gitweb/?p=yaffs-website;a=blobdiff_plain;f=web%2Fcore%2Fmodules%2Fsearch%2Fsrc%2FTests%2FSearchNodeUpdateAndDeletionTest.php;fp=web%2Fcore%2Fmodules%2Fsearch%2Fsrc%2FTests%2FSearchNodeUpdateAndDeletionTest.php;h=0000000000000000000000000000000000000000;hp=c19814e0263b63b962dace16895b857bae46b29f;hb=0bf8d09d2542548982e81a441b1f16e75873a04f;hpb=74df008bdbb3a11eeea356744f39b802369bda3c diff --git a/web/core/modules/search/src/Tests/SearchNodeUpdateAndDeletionTest.php b/web/core/modules/search/src/Tests/SearchNodeUpdateAndDeletionTest.php deleted file mode 100644 index c19814e02..000000000 --- a/web/core/modules/search/src/Tests/SearchNodeUpdateAndDeletionTest.php +++ /dev/null @@ -1,108 +0,0 @@ -testUser = $this->drupalCreateUser(['access content', 'search content']); - $this->drupalLogin($this->testUser); - } - - /** - * Tests that the search index info is properly updated when a node changes. - */ - public function testSearchIndexUpdateOnNodeChange() { - // Create a node. - $node = $this->drupalCreateNode([ - 'title' => 'Someone who says Ni!', - 'body' => [['value' => "We are the knights who say Ni!"]], - 'type' => 'page', - ]); - - $node_search_plugin = $this->container->get('plugin.manager.search')->createInstance('node_search'); - // Update the search index. - $node_search_plugin->updateIndex(); - search_update_totals(); - - // Search the node to verify it appears in search results - $edit = ['keys' => 'knights']; - $this->drupalPostForm('search/node', $edit, t('Search')); - $this->assertText($node->label()); - - // Update the node - $node->body->value = "We want a shrubbery!"; - $node->save(); - - // Run indexer again - $node_search_plugin->updateIndex(); - search_update_totals(); - - // Search again to verify the new text appears in test results. - $edit = ['keys' => 'shrubbery']; - $this->drupalPostForm('search/node', $edit, t('Search')); - $this->assertText($node->label()); - } - - /** - * Tests that the search index info is updated when a node is deleted. - */ - public function testSearchIndexUpdateOnNodeDeletion() { - // Create a node. - $node = $this->drupalCreateNode([ - 'title' => 'No dragons here', - 'body' => [['value' => 'Again: No dragons here']], - 'type' => 'page', - ]); - - $node_search_plugin = $this->container->get('plugin.manager.search')->createInstance('node_search'); - // Update the search index. - $node_search_plugin->updateIndex(); - search_update_totals(); - - // Search the node to verify it appears in search results - $edit = ['keys' => 'dragons']; - $this->drupalPostForm('search/node', $edit, t('Search')); - $this->assertText($node->label()); - - // Get the node info from the search index tables. - $search_index_dataset = db_query("SELECT sid FROM {search_index} WHERE type = 'node_search' AND word = :word", [':word' => 'dragons']) - ->fetchField(); - $this->assertNotEqual($search_index_dataset, FALSE, t('Node info found on the search_index')); - - // Delete the node. - $node->delete(); - - // Check if the node info is gone from the search table. - $search_index_dataset = db_query("SELECT sid FROM {search_index} WHERE type = 'node_search' AND word = :word", [':word' => 'dragons']) - ->fetchField(); - $this->assertFalse($search_index_dataset, t('Node info successfully removed from search_index')); - - // Search again to verify the node doesn't appear anymore. - $this->drupalPostForm('search/node', $edit, t('Search')); - $this->assertNoText($node->label()); - } - -}