You are here

protected function BambooTwigSecurityTest::setUp in Bamboo Twig 8.5

Same name in this branch
  1. 8.5 tests/src/Functional/BambooTwigSecurityTest.php \Drupal\Tests\bamboo_twig\Functional\BambooTwigSecurityTest::setUp()
  2. 8.5 tests/src/Kernel/BambooTwigSecurityTest.php \Drupal\Tests\bamboo_twig\Kernel\BambooTwigSecurityTest::setUp()
Same name and namespace in other branches
  1. 8.4 tests/src/Kernel/BambooTwigSecurityTest.php \Drupal\Tests\bamboo_twig\Kernel\BambooTwigSecurityTest::setUp()

Overrides KernelTestBase::setUp

File

tests/src/Kernel/BambooTwigSecurityTest.php, line 37

Class

BambooTwigSecurityTest
Tests Security twig filters and functions.

Namespace

Drupal\Tests\bamboo_twig\Kernel

Code

protected function setUp() : void {
  parent::setUp();
  $this
    ->installEntitySchema('user');
  $this
    ->installSchema('system', [
    'sequences',
  ]);

  /** @var \Drupal\Core\Entity\EntityTypeManager $entityTypeManager */
  $this->entityTypeManager = $this->container
    ->get('entity_type.manager');

  /** @var \Drupal\bamboo_twig_security\TwigExtension\Security $securityExtension */
  $this->securityExtension = $this->container
    ->get('bamboo_twig_security.twig.security');

  // Create admin user.
  $adminUser = $this->entityTypeManager
    ->getStorage('user')
    ->create([
    'uid' => 1,
    'mail' => 'admin',
    'name' => 'admin',
    'status' => 1,
  ]);
  $adminUser
    ->addRole('administrator');
  $adminUser
    ->save();

  // Create anonymous user.
  $adminUser = $this->entityTypeManager
    ->getStorage('user')
    ->create([
    'uid' => 2,
    'mail' => 'anonymous',
    'name' => 'anonymous',
    'status' => 1,
  ]);
  $adminUser
    ->save();
}