X-Git-Url: http://www.aleph1.co.uk/gitweb/?p=yaffs-website;a=blobdiff_plain;f=web%2Fcore%2Fmodules%2Ftaxonomy%2Ftests%2Fsrc%2FKernel%2FForwardRevisionTest.php;fp=web%2Fcore%2Fmodules%2Ftaxonomy%2Ftests%2Fsrc%2FKernel%2FForwardRevisionTest.php;h=0000000000000000000000000000000000000000;hp=abc0846fc507030b71ec55dfd15337bf08eba57e;hb=9917807b03b64faf00f6a1f29dcb6eafc454efa5;hpb=aea91e65e895364e460983b890e295aa5d5540a5 diff --git a/web/core/modules/taxonomy/tests/src/Kernel/ForwardRevisionTest.php b/web/core/modules/taxonomy/tests/src/Kernel/ForwardRevisionTest.php deleted file mode 100644 index abc0846fc..000000000 --- a/web/core/modules/taxonomy/tests/src/Kernel/ForwardRevisionTest.php +++ /dev/null @@ -1,121 +0,0 @@ -installEntitySchema('user'); - $this->installEntitySchema('node'); - $this->installEntitySchema('taxonomy_term'); - $this->installSchema('node', 'node_access'); - } - - /** - * Tests that the taxonomy index work correctly with forward revisions. - */ - public function testTaxonomyIndexWithForwardRevision() { - \Drupal::configFactory()->getEditable('taxonomy.settings')->set('maintain_index_table', TRUE)->save(); - - Vocabulary::create([ - 'name' => 'test', - 'vid' => 'test', - ])->save(); - $term = Term::create([ - 'name' => 'term1', - 'vid' => 'test', - ]); - $term->save(); - $term2 = Term::create([ - 'name' => 'term2', - 'vid' => 'test', - ]); - $term2->save(); - - NodeType::create([ - 'type' => 'page', - ])->save(); - - FieldStorageConfig::create([ - 'entity_type' => 'node', - 'field_name' => 'field_tags', - 'type' => 'entity_reference', - 'settings' => [ - 'target_type' => 'taxonomy_term', - ], - ])->save(); - - FieldConfig::create([ - 'field_name' => 'field_tags', - 'entity_type' => 'node', - 'bundle' => 'page', - ])->save(); - $node = Node::create([ - 'type' => 'page', - 'title' => 'test_title', - 'field_tags' => [$term->id()], - ]); - $node->save(); - - $taxonomy_index = $this->getTaxonomyIndex(); - $this->assertEquals($term->id(), $taxonomy_index[$node->id()]->tid); - - // Normal new revision. - $node->setNewRevision(TRUE); - $node->isDefaultRevision(TRUE); - $node->field_tags->target_id = $term2->id(); - $node->save(); - - $taxonomy_index = $this->getTaxonomyIndex(); - $this->assertEquals($term2->id(), $taxonomy_index[$node->id()]->tid); - - // Check that saving a forward (non-default) revision does not affect the - // taxonomy index. - $node->setNewRevision(TRUE); - $node->isDefaultRevision(FALSE); - $node->field_tags->target_id = $term->id(); - $node->save(); - - $taxonomy_index = $this->getTaxonomyIndex(); - $this->assertEquals($term2->id(), $taxonomy_index[$node->id()]->tid); - - // Check that making the previously created forward-revision the default - // revision updates the taxonomy index correctly. - $node->isDefaultRevision(TRUE); - $node->save(); - - $taxonomy_index = $this->getTaxonomyIndex(); - $this->assertEquals($term->id(), $taxonomy_index[$node->id()]->tid); - } - - protected function getTaxonomyIndex() { - return \Drupal::database()->select('taxonomy_index') - ->fields('taxonomy_index') - ->execute() - ->fetchAllAssoc('nid'); - } - -}