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