You are here

public function SelectTest::testMultiselect in Zircon Profile 8

Same name and namespace in other branches
  1. 8.0 vendor/behat/mink/driver-testsuite/tests/Form/SelectTest.php \Behat\Mink\Tests\Driver\Form\SelectTest::testMultiselect()

File

vendor/behat/mink/driver-testsuite/tests/Form/SelectTest.php, line 9

Class

SelectTest

Namespace

Behat\Mink\Tests\Driver\Form

Code

public function testMultiselect() {
  $this
    ->getSession()
    ->visit($this
    ->pathTo('/multiselect_form.html'));
  $webAssert = $this
    ->getAssertSession();
  $page = $this
    ->getSession()
    ->getPage();
  $this
    ->assertEquals('Multiselect Test', $webAssert
    ->elementExists('css', 'h1')
    ->getText());
  $select = $webAssert
    ->fieldExists('select_number');
  $multiSelect = $webAssert
    ->fieldExists('select_multiple_numbers[]');
  $secondMultiSelect = $webAssert
    ->fieldExists('select_multiple_values[]');
  $this
    ->assertEquals('20', $select
    ->getValue());
  $this
    ->assertSame(array(), $multiSelect
    ->getValue());
  $this
    ->assertSame(array(
    '2',
    '3',
  ), $secondMultiSelect
    ->getValue());
  $select
    ->selectOption('thirty');
  $this
    ->assertEquals('30', $select
    ->getValue());
  $multiSelect
    ->selectOption('one', true);
  $this
    ->assertSame(array(
    '1',
  ), $multiSelect
    ->getValue());
  $multiSelect
    ->selectOption('three', true);
  $this
    ->assertEquals(array(
    '1',
    '3',
  ), $multiSelect
    ->getValue());
  $secondMultiSelect
    ->selectOption('two');
  $this
    ->assertSame(array(
    '2',
  ), $secondMultiSelect
    ->getValue());
  $button = $page
    ->findButton('Register');
  $this
    ->assertNotNull($button);
  $button
    ->press();
  $space = ' ';
  $out = <<<OUT
  'agreement' = 'off',
  'select_multiple_numbers' ={<span class="php-variable">$space</span>}
  array (
    0 = '1',
    1 = '3',
  ),
  'select_multiple_values' ={<span class="php-variable">$space</span>}
  array (
    0 = '2',
  ),
  'select_number' = '30',
OUT;
  $this
    ->assertContains($out, $page
    ->getContent());
}