You are here

public function RabbitHoleBehaviorSettingsEntityMethodsTest::testCreateEntity 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::testCreateEntity()

Test creating a BehaviorSettings entity and loading it as config.

File

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

Class

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

Namespace

Drupal\Tests\rabbit_hole\Functional

Code

public function testCreateEntity() {
  $action = 'page_not_found';
  $redirect_code = BehaviorSettings::REDIRECT_NOT_APPLICABLE;
  $redirect = '/';
  $allow_override = BehaviorSettings::OVERRIDE_ALLOW;
  $entity = BehaviorSettings::create([
    'id' => 'test_behavior_settings',
    'action' => $action,
    'allow_override' => $allow_override,
    'redirect_code' => $redirect_code,
    'redirect' => $redirect,
  ]);
  $entity
    ->save();
  $config_entity = $this->configFactory
    ->get('rabbit_hole.behavior_settings.test_behavior_settings');
  $this
    ->assertEquals($action, $config_entity
    ->get('action'));
  $this
    ->assertEquals($redirect_code, $config_entity
    ->get('redirect_code'));
  $this
    ->assertEquals($redirect, $config_entity
    ->get('redirect'));
  $this
    ->assertEquals($allow_override, $config_entity
    ->get('allow_override'));
}