function FormCacheTest::setUp

Same name in this branch
  1. main core/tests/Drupal/KernelTests/Core/Form/FormCacheTest.php \Drupal\KernelTests\Core\Form\FormCacheTest::setUp()
Same name and namespace in other branches
  1. 11.x core/tests/Drupal/KernelTests/Core/Form/FormCacheTest.php \Drupal\KernelTests\Core\Form\FormCacheTest::setUp()
  2. 11.x core/tests/Drupal/Tests/Core/Form/FormCacheTest.php \Drupal\Tests\Core\Form\FormCacheTest::setUp()
  3. 10 core/tests/Drupal/KernelTests/Core/Form/FormCacheTest.php \Drupal\KernelTests\Core\Form\FormCacheTest::setUp()
  4. 10 core/tests/Drupal/Tests/Core/Form/FormCacheTest.php \Drupal\Tests\Core\Form\FormCacheTest::setUp()
  5. 9 core/tests/Drupal/KernelTests/Core/Form/FormCacheTest.php \Drupal\KernelTests\Core\Form\FormCacheTest::setUp()
  6. 9 core/tests/Drupal/Tests/Core/Form/FormCacheTest.php \Drupal\Tests\Core\Form\FormCacheTest::setUp()
  7. 8.9.x core/tests/Drupal/KernelTests/Core/Form/FormCacheTest.php \Drupal\KernelTests\Core\Form\FormCacheTest::setUp()
  8. 8.9.x core/tests/Drupal/Tests/Core/Form/FormCacheTest.php \Drupal\Tests\Core\Form\FormCacheTest::setUp()

Overrides UnitTestCase::setUp

File

core/tests/Drupal/Tests/Core/Form/FormCacheTest.php, line 101

Class

FormCacheTest
Tests Drupal\Core\Form\FormCache.

Namespace

Drupal\Tests\Core\Form

Code

protected function setUp() : void {
  parent::setUp();
  $this->moduleHandler = $this->prophesize('Drupal\\Core\\Extension\\ModuleHandlerInterface');
  $this->formCacheStore = $this->createStub(KeyValueStoreExpirableInterface::class);
  $this->formStateCacheStore = $this->createStub(KeyValueStoreExpirableInterface::class);
  $this->keyValueExpirableFactory = new KeyValueExpirableFactory(new ContainerBuilder());
  // Use reflection to set the factory stores so we avoid dealing with using a
  // container.
  $reflection = new \ReflectionProperty($this->keyValueExpirableFactory, 'stores');
  $reflection->setValue($this->keyValueExpirableFactory, [
    'form' => $this->formCacheStore,
    'form_state' => $this->formStateCacheStore,
  ]);
  $this->csrfToken = $this->createStub(CsrfTokenGenerator::class);
  $this->account = $this->createStub(AccountInterface::class);
  $this->logger = $this->createStub(LoggerInterface::class);
  $this->requestStack = $this->createStub(RequestStack::class);
  $this->requestPolicy = $this->createStub(RequestPolicyInterface::class);
  $this->formCache = new FormCache($this->root, $this->keyValueExpirableFactory, $this->moduleHandler
    ->reveal(), $this->account, $this->csrfToken, $this->logger, $this->requestStack, $this->requestPolicy);
}

Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.