Chris@0: testUser = $this->drupalCreateUser(['search content', 'access content', 'administer nodes', 'access site reports']); Chris@0: $this->drupalLogin($this->testUser); Chris@0: Chris@0: foreach ($this->numbers as $num) { Chris@0: $info = [ Chris@0: 'body' => [['value' => $num]], Chris@0: 'type' => 'page', Chris@0: 'language' => LanguageInterface::LANGCODE_NOT_SPECIFIED, Chris@0: ]; Chris@0: $this->nodes[] = $this->drupalCreateNode($info); Chris@0: } Chris@0: Chris@0: // Run cron to ensure the content is indexed. Chris@0: $this->cronRun(); Chris@0: $this->drupalGet('admin/reports/dblog'); Chris@0: $this->assertText(t('Cron run completed'), 'Log shows cron run completed'); Chris@0: } Chris@0: Chris@0: /** Chris@0: * Tests that all the numbers can be searched. Chris@0: */ Chris@0: public function testNumberSearching() { Chris@0: for ($i = 0; $i < count($this->numbers); $i++) { Chris@0: $node = $this->nodes[$i]; Chris@0: Chris@0: // Verify that the node title does not appear on the search page Chris@0: // with a dummy search. Chris@0: $this->drupalPostForm('search/node', Chris@0: ['keys' => 'foo'], Chris@0: t('Search')); Chris@0: $this->assertNoText($node->label(), format_string('%number: node title not shown in dummy search', ['%number' => $i])); Chris@0: Chris@0: // Now verify that we can find node i by searching for any of the Chris@0: // numbers. Chris@0: for ($j = 0; $j < count($this->numbers); $j++) { Chris@0: $number = $this->numbers[$j]; Chris@0: // If the number is negative, remove the - sign, because - indicates Chris@0: // "not keyword" when searching. Chris@0: $number = ltrim($number, '-'); Chris@0: Chris@0: $this->drupalPostForm('search/node', Chris@0: ['keys' => $number], Chris@0: t('Search')); Chris@0: $this->assertText($node->label(), format_string('%i: node title shown (search found the node) in search for number %number', ['%i' => $i, '%number' => $number])); Chris@0: } Chris@0: } Chris@0: Chris@0: } Chris@0: Chris@0: }