DiffPluginEntityTest.php in Diff 8
File
tests/src/Functional/DiffPluginEntityTest.php
View source
<?php
namespace Drupal\Tests\diff\Functional;
use Drupal\Tests\field_ui\Traits\FieldUiTestTrait;
class DiffPluginEntityTest extends DiffPluginTestBase {
use FieldUiTestTrait;
use CoreVersionUiTestTrait;
protected static $modules = [
'file',
'image',
'field_ui',
];
protected $fileSystem;
protected function setUp() {
parent::setUp();
$this->fileSystem = \Drupal::service('file_system');
$this
->drupalPlaceBlock('system_breadcrumb_block');
}
public function testEntityReferencePlugin() {
$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);
$node1 = $this
->drupalCreateNode([
'type' => 'article',
'title' => 'Article A',
]);
$node2 = $this
->drupalCreateNode([
'type' => 'article',
'title' => 'Article B',
]);
$node3 = $this
->drupalCreateNode([
'type' => 'article',
'title' => 'Article C',
]);
$edit = array(
'field_reference[0][target_id]' => 'Article B (' . $node2
->id() . ')',
'revision' => TRUE,
);
$this
->drupalPostNodeForm('node/' . $node1
->id() . '/edit', $edit, t('Save and keep published'));
$edit = array(
'field_reference[0][target_id]' => 'Article C (' . $node3
->id() . ')',
'revision' => TRUE,
);
$this
->drupalPostNodeForm('node/' . $node1
->id() . '/edit', $edit, t('Save and keep published'));
$this
->clickLink(t('Revisions'));
$this
->drupalPostForm(NULL, NULL, t('Compare selected revisions'));
$this
->assertText('Reference');
$this
->assertText('Article B');
$this
->assertText('Article C');
}
}