You are here

protected function CheckoutPaneTest::assertOptions in Commerce Shipping 8.2

Asserts that a select field has all of the provided options.

Core only has assertOption(), this helper decreases the number of needed assertions.

Parameters

string $id: ID of select field to assert.

array $options: Options to assert.

string $message: (optional) A message to display with the assertion. Do not translate messages: use \Drupal\Component\Utility\SafeMarkup::format() to embed variables in the message text, not t(). If left blank, a default message will be displayed.

2 calls to CheckoutPaneTest::assertOptions()
CheckoutPaneTest::testCustomShippingProfileType in tests/src/FunctionalJavascript/CheckoutPaneTest.php
Test checkout with a custom shipping profile type.
CheckoutPaneTest::testNoRequiredShippingProfile in tests/src/FunctionalJavascript/CheckoutPaneTest.php
Tests checkout when the shipping profile is not required for showing rates.

File

tests/src/FunctionalJavascript/CheckoutPaneTest.php, line 1043

Class

CheckoutPaneTest
Tests the "Shipping information" checkout pane.

Namespace

Drupal\Tests\commerce_shipping\FunctionalJavascript

Code

protected function assertOptions($id, array $options, $message = '') {
  $elements = $this
    ->xpath('//select[@name="' . $id . '"]/option');
  $found_options = [];
  foreach ($elements as $element) {
    if ($option = $element
      ->getValue()) {
      $found_options[] = $option;
    }
  }
  $this
    ->assertFieldValues($found_options, $options, $message);
}