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