Namespace
Drupal\Tests\field_example\Functional
File
-
modules/field_example/tests/src/Functional/Text3WidgetTest.php
View source
<?php
namespace Drupal\Tests\field_example\Functional;
class Text3WidgetTest extends FieldExampleBrowserTestBase {
public function testSingleValueField() {
$assert = $this->assertSession();
$this->drupalLogin($this->administratorAccount);
$this->fieldName = $this->createField('field_example_rgb', 'field_example_3text', '1');
$this->drupalLogin($this->authorAccount);
$this->drupalGet('node/add/' . $this->contentTypeName);
$title = 'test_title';
$edit = [
'title[0][value]' => $title,
'field_' . $this->fieldName . '[0][value][r]' => '00',
'field_' . $this->fieldName . '[0][value][g]' => '0a',
'field_' . $this->fieldName . '[0][value][b]' => '01',
];
$this->submitForm($edit, 'Save');
$assert->pageTextContains("{$this->contentTypeName} {$title} has been created");
$assert->pageTextContains("The color code in this field is #000a01");
}
public function testMultiValueField() {
$assert = $this->assertSession();
$this->drupalLogin($this->administratorAccount);
$this->fieldName = $this->createField('field_example_rgb', 'field_example_3text', '-1');
$this->drupalLogin($this->authorAccount);
$this->drupalGet('node/add/' . $this->contentTypeName);
$title = $this->randomMachineName(20);
$edit = [
'title[0][value]' => $title,
'field_' . $this->fieldName . '[0][value][r]' => '00',
'field_' . $this->fieldName . '[0][value][g]' => 'ff',
'field_' . $this->fieldName . '[0][value][b]' => '00',
];
$this->submitForm($edit, 'Add another item');
$edit = [
'field_' . $this->fieldName . '[1][value][r]' => 'ff',
'field_' . $this->fieldName . '[1][value][g]' => 'ff',
'field_' . $this->fieldName . '[1][value][b]' => 'ff',
];
$this->submitForm($edit, 'Save');
$assert->pageTextContains("{$this->contentTypeName} {$title} has been created");
$assert->pageTextContains('The color code in this field is #00ff00');
$assert->pageTextContains('The color code in this field is #ffffff');
}
}
Classes
| Title |
Deprecated |
Summary |
| Text3WidgetTest |
|
Functional tests of the 3text widget. |