function FormCacheTest::setUp

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

Class

FormCacheTest
@coversDefaultClass <a href="/api/drupal/core%21lib%21Drupal%21Core%21Form%21FormCache.php/class/FormCache/11.x" title="Encapsulates the caching of a form and its form state." class="local">\Drupal\Core\Form\FormCache</a> @group Form

Namespace

Drupal\Tests\Core\Form

Code

protected function setUp() : void {
    parent::setUp();
    $this->moduleHandler = $this->prophesize('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
        ->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.