CckSelectOtherMultipleFieldTest.php in CCK Select Other 8
File
tests/src/Functional/CckSelectOtherMultipleFieldTest.php
View source
<?php
namespace Drupal\Tests\cck_select_other\Functional;
class CckSelectOtherMultipleFieldTest extends CckSelectOtherTestBase {
protected $firstField;
protected $secondField;
protected $firstOptions;
protected $secondOptions;
public function setUp() {
parent::setUp();
$this->firstOptions = $this
->createOptions();
$field_info = [
'settings' => [
'allowed_values' => $this->firstOptions,
],
'cardinality' => 1,
];
$config_info = [
'required' => 0,
];
$this->firstField = $this
->createSelectOtherListField('list_string', $field_info, $config_info);
$this->secondOptions = $this
->createOptions();
$field_info['settings']['allowed_values'] = $this->secondOptions;
$this->secondField = $this
->createSelectOtherListField('list_string', $field_info, $config_info);
}
public function testMultipleFields() {
$field_one = $this->firstField
->getName();
$field_two = $this->secondField
->getName();
$this
->drupalLogin($this->webUser);
list($value_one, $label) = $this
->getRandomOption($this->firstOptions);
$value_two = $this
->getRandomGenerator()
->word(15);
$edit = [
'title[0][value]' => $this
->randomString(25),
$field_one . '[0][select_other_list]' => $value_one,
$field_two . '[0][select_other_list]' => 'other',
$field_two . '[0][select_other_text_input]' => $value_two,
];
$this
->drupalPostForm('/node/add/' . $this->contentType
->id(), $edit, 'Save');
$this
->assertSession()
->elementTextContains('css', 'div', $this->firstOptions[$value_one]);
$this
->assertSession()
->elementTextContains('css', 'div', $value_two);
}
}