You are here

public function RabbitHoleBehaviorInvocationTestBase::testPageRedirect in Rabbit Hole 8

Same name and namespace in other branches
  1. 2.x tests/src/Functional/RabbitHoleBehaviorInvocationTestBase.php \Drupal\Tests\rabbit_hole\Functional\RabbitHoleBehaviorInvocationTestBase::testPageRedirect()

Test that entity set to page_redirect actually redirects.

File

tests/src/Functional/RabbitHoleBehaviorInvocationTestBase.php, line 96

Class

RabbitHoleBehaviorInvocationTestBase
Base class for the rabbit hole behaviors invocation tests.

Namespace

Drupal\Tests\rabbit_hole\Functional

Code

public function testPageRedirect() {
  $this
    ->createEntityBundle();
  $destination_path = $this
    ->createEntity('display_page')
    ->toUrl('canonical', [
    'absolute' => TRUE,
  ])
    ->toString();
  $entity = $this
    ->createEntity('page_redirect');
  $entity
    ->set('rh_redirect', $destination_path);
  $entity
    ->set('rh_redirect_response', 301);
  $entity
    ->save();
  $this
    ->drupalGet($entity
    ->toUrl()
    ->toString());
  $this
    ->assertSession()
    ->addressEquals($destination_path);
}