You are here

private function UiTest::assertThatAdminCanAddFrontEndEnvironment 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::assertThatAdminCanAddFrontEndEnvironment()

Asserts admin can create new environment.

Return value

\Drupal\build_hooks\Entity\FrontendEnvironmentInterface Created entity.

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

File

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

Class

UiTest
Defines a class for testing build hooks UI.

Namespace

Drupal\Tests\build_hooks\Functional

Code

private function assertThatAdminCanAddFrontEndEnvironment() : FrontendEnvironmentInterface {
  $random = mb_strtolower($this
    ->randomMachineName());
  $whiz = $this
    ->randomMachineName(2);

  // Try to submit the form with whiz length 2 characters.
  $this
    ->submitForm([
    'id' => $random,
    'label' => $random,
    'url' => 'http://example.com/' . $random,
    'deployment_strategy' => TriggerInterface::DEPLOYMENT_STRATEGY_MANUAL,
    'settings[whiz]' => $whiz,
  ], 'Save');
  $assert = $this
    ->assertSession();
  $assert
    ->pageTextContains('Whiz must contains minimum 3 characters.');
  $this
    ->submitForm([
    'id' => $random,
    'label' => $random,
    'url' => 'http://example.com/' . $random,
    'deployment_strategy' => TriggerInterface::DEPLOYMENT_STRATEGY_MANUAL,
    'settings[whiz]' => $random,
  ], 'Save');
  $assert
    ->pageTextContains('The frontend environment configuration has been saved.');
  $environment = \Drupal::entityTypeManager()
    ->getStorage('frontend_environment')
    ->load($random);
  $this
    ->assertNotEmpty($environment);
  $this
    ->assertEquals($random, $environment
    ->label());

  /** @var \Drupal\build_hooks\Plugin\FrontendEnvironmentInterface $plugin */
  $plugin = $environment
    ->getPlugin();
  $this
    ->assertEquals($random, $plugin
    ->getConfiguration()['whiz']);
  $this
    ->assertEquals('build_hooks_test', $plugin
    ->getPluginId());
  return $environment;
}