function FormCacheTest::setUp

Same name in this branch
  1. 9 core/tests/Drupal/KernelTests/Core/Form/FormCacheTest.php \Drupal\KernelTests\Core\Form\FormCacheTest::setUp()
Same name in other branches
  1. 8.9.x core/tests/Drupal/KernelTests/Core/Form/FormCacheTest.php \Drupal\KernelTests\Core\Form\FormCacheTest::setUp()
  2. 8.9.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. 11.x core/tests/Drupal/KernelTests/Core/Form/FormCacheTest.php \Drupal\KernelTests\Core\Form\FormCacheTest::setUp()
  6. 11.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 98

Class

FormCacheTest
@coversDefaultClass \Drupal\Core\Form\FormCache @group Form

Namespace

Drupal\Tests\Core\Form

Code

protected function setUp() : void {
    parent::setUp();
    $this->moduleHandler = $this->createMock('Drupal\\Core\\Extension\\ModuleHandlerInterface');
    $this->formCacheStore = $this->createMock('Drupal\\Core\\KeyValueStore\\KeyValueStoreExpirableInterface');
    $this->formStateCacheStore = $this->createMock('Drupal\\Core\\KeyValueStore\\KeyValueStoreExpirableInterface');
    $this->keyValueExpirableFactory = $this->createMock('Drupal\\Core\\KeyValueStore\\KeyValueExpirableFactoryInterface');
    $this->keyValueExpirableFactory
        ->expects($this->any())
        ->method('get')
        ->willReturnMap([
        [
            'form',
            $this->formCacheStore,
        ],
        [
            'form_state',
            $this->formStateCacheStore,
        ],
    ]);
    $this->csrfToken = $this->getMockBuilder('Drupal\\Core\\Access\\CsrfTokenGenerator')
        ->disableOriginalConstructor()
        ->getMock();
    $this->account = $this->createMock('Drupal\\Core\\Session\\AccountInterface');
    $this->logger = $this->createMock('Psr\\Log\\LoggerInterface');
    $this->requestStack = $this->createMock('\\Symfony\\Component\\HttpFoundation\\RequestStack');
    $this->requestPolicy = $this->createMock('\\Drupal\\Core\\PageCache\\RequestPolicyInterface');
    $this->formCache = new FormCache($this->root, $this->keyValueExpirableFactory, $this->moduleHandler, $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.