You are here

public function RabbitHoleBehaviorSettingsFormTestBase::testBundleFormSave in Rabbit Hole 8

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

Test new changes to bundle with existing rabbit hole settings changes key.

Test that saving changes to a bundle form which already has configured rabbit hole behavior settings changes the existing key.

File

tests/src/Functional/RabbitHoleBehaviorSettingsFormTestBase.php, line 171

Class

RabbitHoleBehaviorSettingsFormTestBase
Base class for the Rabbit Hole form additions tests.

Namespace

Drupal\Tests\rabbit_hole\Functional

Code

public function testBundleFormSave() {
  $test_bundle_id = $this
    ->createEntityBundle();
  $this->behaviorSettingsManager
    ->saveBehaviorSettings([
    'action' => 'access_denied',
    'allow_override' => BehaviorSettings::OVERRIDE_DISALLOW,
    'redirect_code' => BehaviorSettings::REDIRECT_NOT_APPLICABLE,
  ], $this->bundleEntityTypeName, $test_bundle_id);
  $this
    ->loadEntityBundleForm($test_bundle_id);
  $action = 'page_not_found';
  $override = BehaviorSettings::OVERRIDE_ALLOW;
  $this
    ->submitForm([
    'rh_override' => $override,
    'rh_action' => $action,
  ], 'edit-submit');
  $saved_config = $this->behaviorSettingsManager
    ->loadBehaviorSettingsAsConfig($this->bundleEntityTypeName, $test_bundle_id);
  $this
    ->assertEquals($action, $saved_config
    ->get('action'));
  $this
    ->assertEquals($override, $saved_config
    ->get('allow_override'));
}