src/DrupalExtension/Context/SelectFieldContext.php
public function assertSelectOptions($select, TableNode $options) {
    // Retrieve the specified field.
    if (!$field = $this->getSession()->getPage()->findField($select)) {
      throw new ExpectationException("Field '$select' not found.", $this->getSession());
    }

    /* @var \Behat\Mink\Element\NodeElement $field */

    // Check that the specified field is a <select> field.
    $this->assertElementType($field, 'select');

    // Retrieve the options table from the test scenario and flatten it.
    $expected_options = $options->getColumnsHash();
    array_walk($expected_options, function (&$value) {
      $value = reset($value);
    });

    // Retrieve the actual options that are shown in the page.
    $actual_options = $field->findAll('css', 'option');

    // Convert into a flat list of option text strings.
    array_walk($actual_options, function (NodeElement &$value) {
      $value = $value->getText();
    });

    // Check that all expected options are present.
    foreach ($expected_options as $expected_option) {
      if (!in_array($expected_option, $actual_options)) {
        throw new ExpectationException("Option '$expected_option' is missing from select list '$select'.", $this->getSession());
      }
    }
  }
public function assertSelectOptions($select, TableNode $options) {
    // Retrieve the specified field.
    if (!$field = $this->getSession()->getPage()->findField($select)) {
      throw new ExpectationException("Field '$select' not found.", $this->getSession());
    }

    /* @var \Behat\Mink\Element\NodeElement $field */

    // Check that the specified field is a <select> field.
    $this->assertElementType($field, 'select');

    // Retrieve the options table from the test scenario and flatten it.
    $expected_options = $options->getColumnsHash();
    array_walk($expected_options, function (&$value) {
      $value = reset($value);
    });

    // Retrieve the actual options that are shown in the page.
    $actual_options = $field->findAll('css', 'option');

    // Convert into a flat list of option text strings.
    array_walk($actual_options, function (NodeElement &$value) {
      $value = $value->getText();
    });

    // Check that all expected options are present.
    foreach ($expected_options as $expected_option) {
      if (!in_array($expected_option, $actual_options)) {
        throw new ExpectationException("Option '$expected_option' is missing from select list '$select'.", $this->getSession());
      }
    }
  }
public function assertSelectOptions ( $ select , TableNode $ options ) { // Retrieve the specified field. if ( ! $ field = $ this -> getSession ( ) -> getPage ( ) -> findField ( $ select ) ) { throw new ExpectationException ( "Field '$select' not found." , $ this -> getSession ( ) ) ; } /* @var \Behat\Mink\Element\NodeElement $field */ // Check that the specified field is a <select> field. $ this -> assertElementType ( $ field , 'select' ) ; // Retrieve the options table from the test scenario and flatten it. $ expected_options = $ options -> getColumnsHash ( ) ; array_walk ( $ expected_options , function ( & $ value ) { $ value = reset ( $ value ) ; } ) ; // Retrieve the actual options that are shown in the page. $ actual_options = $ field -> findAll ( 'css' , 'option' ) ; // Convert into a flat list of option text strings. array_walk ( $ actual_options , function ( NodeElement & $ value ) { $ value = $ value -> getText ( ) ; } ) ; // Check that all expected options are present. foreach ( $ expected_options as $ expected_option ) { if ( ! in_array ( $ expected_option , $ actual_options ) ) { throw new ExpectationException ( "Option '$expected_option' is missing from select list '$select'." , $ this -> getSession ( ) ) ; } } }
Checks that the given select field has the options listed in the table.

@Then I should have the following options for :select:
Checks that the given select field has the options listed in the table .