You are here

public function EntityReferenceFilterViewsResultTest::dynamicFilterOptionsWithArgumentsTest in Views Reference Filter 8

Common test method.

Parameters

string $url_1: URL 1 to visit.

string $url_2: URL 2 to visit.

Throws

\Behat\Mink\Exception\ElementNotFoundException

\Behat\Mink\Exception\ExpectationException

2 calls to EntityReferenceFilterViewsResultTest::dynamicFilterOptionsWithArgumentsTest()
EntityReferenceFilterViewsResultTest::testFilterOptionsWithContextualArguments in tests/src/Functional/Views/EntityReferenceFilterViewsResultTest.php
Tests filter options with context arguments.
EntityReferenceFilterViewsResultTest::testFilterOptionsWithUrlArguments in tests/src/Functional/Views/EntityReferenceFilterViewsResultTest.php
Tests filter options with url arguments.

File

tests/src/Functional/Views/EntityReferenceFilterViewsResultTest.php, line 65

Class

EntityReferenceFilterViewsResultTest
Tests entityreference filter behavior in views.

Namespace

Drupal\Tests\entityreference_filter\Functional\Views

Code

public function dynamicFilterOptionsWithArgumentsTest($url_1, $url_2) {
  $web_assert = $this
    ->assertSession();
  $this
    ->drupalGet($url_1);
  $web_assert
    ->statusCodeEquals('200');

  // 2 options are presented: `1` and `All`.
  $field_id = 'edit-field-taxonomy-reference-target-id-entityreference-filter';
  $web_assert = $this
    ->assertSession();
  $web_assert
    ->selectExists($field_id);
  $web_assert
    ->optionExists($field_id, 'All');
  $web_assert
    ->optionExists($field_id, '1');
  $options = $this
    ->getOptions($field_id);
  $this
    ->assertCount(2, $options);

  // 1 option is presented: `All` and the form field is hidden.
  $web_assert = $this
    ->assertSession();
  $this
    ->drupalGet($url_2);
  $web_assert
    ->statusCodeEquals('200');
  $field_id = 'edit-field-taxonomy-reference-target-id-entityreference-filter';
  $web_assert
    ->selectExists($field_id);
  $elements = $this
    ->cssSelect('.hidden select#edit-field-taxonomy-reference-target-id-entityreference-filter');
  $this
    ->assertEqual(1, count($elements));
  $web_assert
    ->optionExists($field_id, 'All');
}