You are here

public function IntegrationTest::testFilterWorks in Views Entity Reference Filter 8

Tests that the Views Entity Reference Filter works.

File

tests/src/Functional/IntegrationTest.php, line 68

Class

IntegrationTest
Tests the integration between Views Entity Reference Filter and Views.

Namespace

Drupal\Tests\verf\Functional

Code

public function testFilterWorks() {
  $referencedNode = $this
    ->drupalCreateNode([
    'type' => $this->nodeType
      ->id(),
  ]);
  $referencingNode = $this
    ->drupalCreateNode([
    'type' => $this->nodeType
      ->id(),
    'field_refs' => [
      [
        'target_id' => $referencedNode
          ->id(),
      ],
    ],
  ]);
  $this
    ->drupalGet('verftest');
  $this
    ->assertSession()
    ->statusCodeEquals(200);
  $this
    ->assertPageContainsNodeTeaserWithText($referencedNode
    ->getTitle());
  $this
    ->assertPageContainsNodeTeaserWithText($referencingNode
    ->getTitle());
  $this
    ->assertSelectOptionCanBeSelected('Refs (VERF selector)', $referencedNode
    ->getTitle());
  $this
    ->getSession()
    ->getPage()
    ->pressButton('Apply');
  $this
    ->assertPageContainsNodeTeaserWithText($referencingNode
    ->getTitle());
  $this
    ->assertPageNotContainsNodeTeaserWithText($referencedNode
    ->getTitle());
}