public function DiffPluginVariousTest::testListPlugin in Diff 8
Tests the List plugin.
@covers \Drupal\diff\Plugin\diff\Field\ListFieldBuilder
File
- tests/
src/ Functional/ DiffPluginVariousTest.php, line 279
Class
- DiffPluginVariousTest
- Tests the Diff module plugins.
Namespace
Drupal\Tests\diff\FunctionalCode
public function testListPlugin() {
// Add a list field to the article content type.
$field_name = 'field_list';
$field_storage = FieldStorageConfig::create([
'field_name' => $field_name,
'entity_type' => 'node',
'type' => 'list_string',
'cardinality' => 1,
'settings' => [
'allowed_values' => [
'value_a' => 'Value A',
'value_b' => 'Value B',
],
],
]);
$field_storage
->save();
FieldConfig::create([
'field_name' => $field_name,
'entity_type' => 'node',
'bundle' => 'article',
'required' => FALSE,
'label' => 'List',
])
->save();
$this->formDisplay
->load('node.article.default')
->setComponent($field_name, [
'type' => 'options_select',
])
->save();
$this->viewDisplay
->load('node.article.default')
->setComponent($field_name, [
'type' => 'list_default',
])
->save();
// Create an article, setting values on the lit field.
$node = $this
->drupalCreateNode([
'type' => 'article',
'title' => 'Test article',
'field_list' => 'value_a',
]);
// Update the list field.
$edit = [
'field_list' => 'value_b',
'revision' => TRUE,
];
$this
->drupalPostNodeForm('node/' . $node
->id() . '/edit', $edit, t('Save and keep published'));
// Check differences between revisions.
$this
->clickLink(t('Revisions'));
$this
->drupalPostForm(NULL, [], t('Compare selected revisions'));
$this
->assertText('List');
$this
->assertText('value_a');
$this
->assertText('value_b');
}