Chris@0: drupalCreateContentType(['type' => 'page', 'name' => 'Basic page']); Chris@17: Chris@0: node_access_rebuild(); Chris@0: // Create a test user and log in. Chris@0: $this->testUser = $this->drupalCreateUser(['access content', 'search content', 'use advanced search', 'access user profiles']); Chris@0: $this->drupalLogin($this->testUser); Chris@0: } Chris@0: Chris@0: /** Chris@0: * Tests that search works with punctuation and HTML entities. Chris@0: */ Chris@0: public function testPhraseSearchPunctuation() { Chris@0: $node = $this->drupalCreateNode(['body' => [['value' => "The bunny's ears were fluffy."]]]); Chris@0: $node2 = $this->drupalCreateNode(['body' => [['value' => 'Dignissim Aliquam & Quieligo meus natu quae quia te. Damnum© erat— neo pneum. Facilisi feugiat ibidem ratis.']]]); 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: // Refresh variables after the treatment. Chris@0: $this->refreshVariables(); Chris@0: Chris@0: // Submit a phrase wrapped in double quotes to include the punctuation. Chris@0: $edit = ['keys' => '"bunny\'s"']; Chris@0: $this->drupalPostForm('search/node', $edit, t('Search')); Chris@0: $this->assertText($node->label()); Chris@0: Chris@0: // Check if the author is linked correctly to the user profile page. Chris@18: $username = $node->getOwner()->getAccountName(); Chris@0: $this->assertLink($username); Chris@0: Chris@0: // Search for "&" and verify entities are not broken up in the output. Chris@0: $edit = ['keys' => '&']; Chris@0: $this->drupalPostForm('search/node', $edit, t('Search')); Chris@0: $this->assertNoRaw('&'); Chris@0: $this->assertText('You must include at least one keyword'); Chris@0: Chris@0: $edit = ['keys' => '&']; Chris@0: $this->drupalPostForm('search/node', $edit, t('Search')); Chris@0: $this->assertNoRaw('&'); Chris@0: $this->assertText('You must include at least one keyword'); Chris@0: } Chris@0: Chris@0: }