You are here

public function CckSelectOtherMultipleFieldTest::testMultipleFields in CCK Select Other 8

Asserts that field one and field two have unique values.

File

tests/src/Functional/CckSelectOtherMultipleFieldTest.php, line 70

Class

CckSelectOtherMultipleFieldTest
Tests that two select other fields work on the same node.

Namespace

Drupal\Tests\cck_select_other\Functional

Code

public function testMultipleFields() {
  $field_one = $this->firstField
    ->getName();
  $field_two = $this->secondField
    ->getName();

  // Login as content creator.
  $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);
}