X-Git-Url: http://www.aleph1.co.uk/gitweb/?a=blobdiff_plain;f=web%2Fmodules%2Fcontrib%2Fdiff%2Fsrc%2FTests%2FDiffPluginEntityTest.php;fp=web%2Fmodules%2Fcontrib%2Fdiff%2Fsrc%2FTests%2FDiffPluginEntityTest.php;h=c9eb4ec9da7bdb4e47f6a154d4ec8cab545f3625;hb=a2bd1bf0c2c1f1a17d188f4dc0726a45494cefae;hp=0000000000000000000000000000000000000000;hpb=57c063afa3f66b07c4bbddc2d6129a96d90f0aad;p=yaffs-website diff --git a/web/modules/contrib/diff/src/Tests/DiffPluginEntityTest.php b/web/modules/contrib/diff/src/Tests/DiffPluginEntityTest.php new file mode 100644 index 000000000..c9eb4ec9d --- /dev/null +++ b/web/modules/contrib/diff/src/Tests/DiffPluginEntityTest.php @@ -0,0 +1,97 @@ +fileSystem = \Drupal::service('file_system'); + + // FieldUiTestTrait checks the breadcrumb when adding a field, so we need + // to show the breadcrumb block. + $this->drupalPlaceBlock('system_breadcrumb_block'); + } + + /** + * Tests the EntityReference plugin. + * + * @see \Drupal\diff\Plugin\diff\Field\EntityReferenceFieldBuilder + */ + public function testEntityReferencePlugin() { + // Add an entity reference field to the article content type. + $bundle_path = 'admin/structure/types/manage/article'; + $field_name = 'reference'; + $storage_edit = $field_edit = array(); + $storage_edit['settings[target_type]'] = 'node'; + $field_edit['settings[handler_settings][target_bundles][article]'] = TRUE; + $this->fieldUIAddNewField($bundle_path, $field_name, 'Reference', 'entity_reference', $storage_edit, $field_edit); + + // Create three article nodes. + $node1 = $this->drupalCreateNode([ + 'type' => 'article', + 'title' => 'Article A', + ]); + $node2 = $this->drupalCreateNode([ + 'type' => 'article', + 'title' => 'Article B', + ]); + $node3 = $this->drupalCreateNode([ + 'type' => 'article', + 'title' => 'Article C', + ]); + + // Reference article B in article A. + $edit = array( + 'field_reference[0][target_id]' => 'Article B (' . $node2->id() . ')', + 'revision' => TRUE, + ); + $this->drupalPostForm('node/' . $node1->id() . '/edit', $edit, t('Save and keep published')); + + // Update article A so it points to article C instead of B. + $edit = array( + 'field_reference[0][target_id]' => 'Article C (' . $node3->id() . ')', + 'revision' => TRUE, + ); + $this->drupalPostForm('node/' . $node1->id() . '/edit', $edit, t('Save and keep published')); + + // Check differences between revisions. + $this->clickLink(t('Revisions')); + $this->drupalPostForm(NULL, NULL, t('Compare selected revisions')); + $this->assertText('Reference'); + $this->assertText('Article B'); + $this->assertText('Article C'); + } + +}