You are here

private function UiTest::assertThatAnonymousUsersCannotAccessEnviromentSettingsPages in Build Hooks 8.2

Same name and namespace in other branches
  1. 3.x tests/src/Functional/UiTest.php \Drupal\Tests\build_hooks\Functional\UiTest::assertThatAnonymousUsersCannotAccessEnviromentSettingsPages()

Assert that anonymous users can't access privileged pages.

1 call to UiTest::assertThatAnonymousUsersCannotAccessEnviromentSettingsPages()
UiTest::testBuildHooksUi in tests/src/Functional/UiTest.php
Test build hooks UI.

File

tests/src/Functional/UiTest.php, line 89

Class

UiTest
Defines a class for testing build hooks UI.

Namespace

Drupal\Tests\build_hooks\Functional

Code

private function assertThatAnonymousUsersCannotAccessEnviromentSettingsPages() {
  $assert = $this
    ->assertSession();
  $this
    ->drupalGet(Url::fromRoute('entity.frontend_environment.collection'));
  $assert
    ->statusCodeEquals(403);
  $title = $this
    ->randomMachineName();
  $environment = FrontendEnvironment::create([
    'id' => 'foo',
    'label' => $title,
    'settings' => [],
    'plugin' => 'build_hooks_test',
    'deployment_strategy' => TriggerInterface::DEPLOYMENT_STRATEGY_ENTITYSAVE,
  ]);
  $environment
    ->save();
  $this
    ->drupalGet($environment
    ->toUrl());
  $assert
    ->statusCodeEquals(403);
  $this
    ->drupalGet($environment
    ->toUrl('edit-form'));
  $assert
    ->statusCodeEquals(403);
  $this
    ->drupalGet($environment
    ->toUrl('delete-form'));
  $assert
    ->statusCodeEquals(403);
  $environment
    ->delete();
}