diff --git a/core/modules/taxonomy/src/Tests/TermAutocompleteTest.php b/core/modules/taxonomy/src/Tests/TermAutocompleteTest.php index 78bb80e..645971b 100644 --- a/core/modules/taxonomy/src/Tests/TermAutocompleteTest.php +++ b/core/modules/taxonomy/src/Tests/TermAutocompleteTest.php @@ -47,21 +47,23 @@ protected function setUp() { // Create a vocabulary. $this->vocabulary = $this->createVocabulary(); - // Create 11 terms, which have some string in common, in a non-alphabetical - // order, so that we will have more than 10 matches later when we test - // the correct number of results is returned, and we can test the ordering - // of results. - $this->createTerm($this->vocabulary, ['name' => 'aaa 20']); - $this->createTerm($this->vocabulary, ['name' => 'aaa 70']); - $this->createTerm($this->vocabulary, ['name' => 'aaa 10']); - $this->createTerm($this->vocabulary, ['name' => 'aaa 12']); - $this->createTerm($this->vocabulary, ['name' => 'aaa 40']); - $this->createTerm($this->vocabulary, ['name' => 'aaa 11']); - $this->createTerm($this->vocabulary, ['name' => 'aaa 30']); - $this->createTerm($this->vocabulary, ['name' => 'aaa 50']); + // Create 11 terms, which have some sub-string in common, in a + // non-alphabetical order, so that we will have more than 10 matches later + // when we test the correct number of results is returned, and we can test + // the order of the results. The location of the sub-string to match varies + // also, since it should not be necessary to start with the sub-string to + // match it. + $this->createTerm($this->vocabulary, ['name' => 'aaa 20 bbb']); + $this->createTerm($this->vocabulary, ['name' => 'aaa 70 bbb']); + $this->createTerm($this->vocabulary, ['name' => 'aaa 10 bbb']); + $this->createTerm($this->vocabulary, ['name' => 'aaa 12 bbb']); + $this->createTerm($this->vocabulary, ['name' => 'aaa 40 bbb']); + $this->createTerm($this->vocabulary, ['name' => 'aaa 11 bbb']); + $this->createTerm($this->vocabulary, ['name' => 'aaa 30 bbb']); + $this->createTerm($this->vocabulary, ['name' => 'aaa 50 bbb']); $this->createTerm($this->vocabulary, ['name' => 'aaa 80']); $this->createTerm($this->vocabulary, ['name' => 'aaa 90']); - $this->createTerm($this->vocabulary, ['name' => 'aaa 60']); + $this->createTerm($this->vocabulary, ['name' => 'bbb 60 aaa']); // Create a taxonomy_term_reference field on the article Content Type that // uses a taxonomy_autocomplete widget. @@ -144,21 +146,20 @@ public function testAutocompleteCountResults() { */ public function testAutocompleteOrderedResults() { $expected = array( - ['label' => 'aaa 10'], - ['label' => 'aaa 11'], - ['label' => 'aaa 12'], - ['label' => 'aaa 20'], - ['label' => 'aaa 30'], - ['label' => 'aaa 40'], - ['label' => 'aaa 50'], - ['label' => 'aaa 60'], - ['label' => 'aaa 70'], - ['label' => 'aaa 80'], + ['label' => 'aaa 10 bbb'], + ['label' => 'aaa 11 bbb'], + ['label' => 'aaa 12 bbb'], + ['label' => 'aaa 20 bbb'], + ['label' => 'aaa 30 bbb'], + ['label' => 'aaa 40 bbb'], + ['label' => 'aaa 50 bbb'], + ['label' => 'aaa 70 bbb'], + ['label' => 'bbb 60 aaa'], ); $data = $this->drupalGetJSON( 'taxonomy/autocomplete/node/' . $this->fieldName, - ['query' => ['q' => 'aaa']] + ['query' => ['q' => 'bbb']] ); $this->assertIdentical($expected, $data);