Exemplo n.º 1
0
  /**
   * {@inheritdoc}
   */
  protected function setUp() {
    parent::setUp();

    $this->moduleHandler = $this->getMock('Drupal\Core\Extension\ModuleHandlerInterface');

    $this->formCacheStore = $this->getMock('Drupal\Core\KeyValueStore\KeyValueStoreExpirableInterface');
    $this->formStateCacheStore = $this->getMock('Drupal\Core\KeyValueStore\KeyValueStoreExpirableInterface');
    $this->keyValueExpirableFactory = $this->getMock('Drupal\Core\KeyValueStore\KeyValueExpirableFactoryInterface');
    $this->keyValueExpirableFactory->expects($this->any())
      ->method('get')
      ->will($this->returnValueMap([
        ['form', $this->formCacheStore],
        ['form_state', $this->formStateCacheStore],
      ]));

    $this->csrfToken = $this->getMockBuilder('Drupal\Core\Access\CsrfTokenGenerator')
      ->disableOriginalConstructor()
      ->getMock();
    $this->account = $this->getMock('Drupal\Core\Session\AccountInterface');

    $this->logger = $this->getMock('Psr\Log\LoggerInterface');
    $this->requestStack = $this->getMock('\Symfony\Component\HttpFoundation\RequestStack');
    $this->requestPolicy = $this->getMock('\Drupal\Core\PageCache\RequestPolicyInterface');

    $this->formCache = new FormCache($this->root, $this->keyValueExpirableFactory, $this->moduleHandler, $this->account, $this->csrfToken, $this->logger, $this->requestStack, $this->requestPolicy);
  }
 /**
  * {@inheritdoc}
  */
 protected function setUp()
 {
     parent::setUp();
     $this->resetSafeMarkup();
     $this->moduleHandler = $this->getMock('Drupal\\Core\\Extension\\ModuleHandlerInterface');
     $this->formCacheStore = $this->getMock('Drupal\\Core\\KeyValueStore\\KeyValueStoreExpirableInterface');
     $this->formStateCacheStore = $this->getMock('Drupal\\Core\\KeyValueStore\\KeyValueStoreExpirableInterface');
     $this->keyValueExpirableFactory = $this->getMock('Drupal\\Core\\KeyValueStore\\KeyValueExpirableFactoryInterface');
     $this->keyValueExpirableFactory->expects($this->any())->method('get')->will($this->returnValueMap([['form', $this->formCacheStore], ['form_state', $this->formStateCacheStore]]));
     $this->csrfToken = $this->getMockBuilder('Drupal\\Core\\Access\\CsrfTokenGenerator')->disableOriginalConstructor()->getMock();
     $this->account = $this->getMock('Drupal\\Core\\Session\\AccountInterface');
     $this->logger = $this->getMock('Psr\\Log\\LoggerInterface');
     $this->configFactory = $this->getConfigFactoryStub(['system.performance' => ['cache.page.use_internal' => FALSE]]);
     $this->requestStack = $this->getMock('\\Symfony\\Component\\HttpFoundation\\RequestStack');
     $this->requestPolicy = $this->getMock('\\Drupal\\Core\\PageCache\\RequestPolicyInterface');
     $this->formCache = new FormCache($this->keyValueExpirableFactory, $this->moduleHandler, $this->account, $this->csrfToken, $this->logger, $this->configFactory, $this->requestStack, $this->requestPolicy);
 }