Chris@17: '978-0446365383', Chris@17: 'UPC' => '036000 291452', Chris@17: 'EAN bar code' => '5901234123457', Chris@17: 'negative' => '-123456.7890', Chris@17: 'quoted negative' => '"-123456.7890"', Chris@17: 'leading zero' => '0777777777', Chris@17: 'tiny' => '111', Chris@17: 'small' => '22222222222222', Chris@17: 'medium' => '333333333333333333333333333', Chris@17: 'large' => '444444444444444444444444444444444444444', Chris@17: 'gigantic' => '5555555555555555555555555555555555555555555555555', Chris@17: 'over fifty characters' => '666666666666666666666666666666666666666666666666666666666666', Chris@17: 'date' => '01/02/2009', Chris@17: 'commas' => '987,654,321', Chris@17: ]; Chris@17: Chris@17: /** Chris@17: * An array of nodes created for testing purposes. Chris@17: * Chris@17: * @var \Drupal\node\NodeInterface[] Chris@17: */ Chris@17: protected $nodes; Chris@17: Chris@17: protected function setUp() { Chris@17: parent::setUp(); Chris@17: Chris@17: $this->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 $doc => $num) { Chris@17: $info = [ Chris@17: 'body' => [['value' => $num]], Chris@17: 'type' => 'page', Chris@17: 'language' => LanguageInterface::LANGCODE_NOT_SPECIFIED, Chris@17: 'title' => $doc . ' number', Chris@17: ]; Chris@17: $this->nodes[$doc] = $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: $types = array_keys($this->numbers); Chris@17: Chris@17: foreach ($types as $type) { Chris@17: $number = $this->numbers[$type]; 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: $node = $this->nodes[$type]; 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(), $type . ': node title not shown in dummy search'); Chris@17: Chris@17: // Verify that the node title does appear as a link on the search page Chris@17: // when searching for the number. Chris@17: $this->drupalPostForm('search/node', Chris@17: ['keys' => $number], Chris@17: t('Search')); Chris@17: $this->assertText($node->label(), format_string('%type: node title shown (search found the node) in search for number %number.', ['%type' => $type, '%number' => $number])); Chris@17: } Chris@17: } Chris@17: Chris@17: }