CckSelectOtherDefaultValueTest.php in CCK Select Other 8
File
tests/src/Functional/CckSelectOtherDefaultValueTest.php
View source
<?php
namespace Drupal\Tests\cck_select_other\Functional;
class CckSelectOtherDefaultValueTest extends CckSelectOtherTestBase {
public function testDefaultValue() {
$options = $this
->createOptions();
list($default_value, $label) = $this
->getRandomOption($options);
$storage_values = [
'settings' => [
'allowed_values' => $options,
],
'cardinality' => 1,
];
$config_values = [
'required' => 0,
'default_value' => [
[
'value' => $default_value,
],
],
];
$field = $this
->createSelectOtherListField('list_string', $storage_values, $config_values);
$field_name = $field
->getName();
$this
->drupalLogin($this->webUser);
$field_id = 'edit-' . $field_name . '-0-select-other-list';
$this
->drupalGet('/node/add/' . $this->contentType
->id());
$this
->assertOptionSelected($field_id, $default_value, 'Default value selected is ' . $default_value);
}
}