You are here

public function RabbitHoleBehaviorSettingsEntityMethodsTest::testSetRedirectCode in Rabbit Hole 8

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

Test that setRedirectCode works as expected.

Test that setRedirectCode works as expected (including throwing an exception for invalid codes and settings codes when action type is wrong).

File

tests/src/Functional/RabbitHoleBehaviorSettingsEntityMethodsTest.php, line 109

Class

RabbitHoleBehaviorSettingsEntityMethodsTest
Test the functionality of the rabbit hole form additions to the node form.

Namespace

Drupal\Tests\rabbit_hole\Functional

Code

public function testSetRedirectCode() {
  $entity = $this
    ->createGenericTestEntity();
  $entity
    ->setAction('display_page');
  $this
    ->behaviorSettingExceptionThrown($entity, 'setRedirectCode', [
    BehaviorSettings::REDIRECT_FOUND,
  ], __METHOD__);
  $entity
    ->setAction('redirect');
  $this
    ->behaviorSettingExceptionThrown($entity, 'setRedirectCode', [
    209458253,
  ], __METHOD__);
  $entity
    ->setRedirectCode(BehaviorSettings::REDIRECT_FOUND);
  $this
    ->assertEquals(BehaviorSettings::REDIRECT_FOUND, $entity
    ->getRedirectCode());
  $entity
    ->setRedirectCode(BehaviorSettings::REDIRECT_MOVED_PERMANENTLY);
  $this
    ->assertEquals(BehaviorSettings::REDIRECT_MOVED_PERMANENTLY, $entity
    ->getRedirectCode());
}