protected function setUp() { $this->moduleHandler = $this->getMock('Drupal\\Core\\Extension\\ModuleHandlerInterface'); $this->formCache = $this->getMock('Drupal\\Core\\Form\\FormCacheInterface'); $this->urlGenerator = $this->getMock('Drupal\\Core\\Routing\\UrlGeneratorInterface'); $this->classResolver = $this->getClassResolverStub(); $this->csrfToken = $this->getMockBuilder('Drupal\\Core\\Access\\CsrfTokenGenerator')->disableOriginalConstructor()->getMock(); $this->kernel = $this->getMockBuilder('\\Drupal\\Core\\DrupalKernel')->disableOriginalConstructor()->getMock(); $this->account = $this->getMock('Drupal\\Core\\Session\\AccountInterface'); $this->themeManager = $this->getMock('Drupal\\Core\\Theme\\ThemeManagerInterface'); $this->request = new Request(); $this->eventDispatcher = $this->getMock('Symfony\\Component\\EventDispatcher\\EventDispatcherInterface'); $this->requestStack = new RequestStack(); $this->requestStack->push($this->request); $this->logger = $this->getMock('Drupal\\Core\\Logger\\LoggerChannelInterface'); $this->formValidator = $this->getMockBuilder('Drupal\\Core\\Form\\FormValidator')->setConstructorArgs(array($this->requestStack, $this->getStringTranslationStub(), $this->csrfToken, $this->logger))->setMethods(array('drupalSetMessage'))->getMock(); $this->formSubmitter = $this->getMockBuilder('Drupal\\Core\\Form\\FormSubmitter')->setConstructorArgs(array($this->requestStack, $this->urlGenerator))->setMethods(array('batchGet', 'drupalInstallationAttempted'))->getMock(); $this->formBuilder = new TestFormBuilder($this->formValidator, $this->formSubmitter, $this->formCache, $this->moduleHandler, $this->eventDispatcher, $this->requestStack, $this->classResolver, $this->themeManager, $this->csrfToken, $this->kernel); $this->formBuilder->setCurrentUser($this->account); }
public function setUp() { $this->moduleHandler = $this->getMock('Drupal\\Core\\Extension\\ModuleHandlerInterface'); $this->formCache = $this->getMock('Drupal\\Core\\KeyValueStore\\KeyValueStoreExpirableInterface'); $this->formStateCache = $this->getMock('Drupal\\Core\\KeyValueStore\\KeyValueStoreExpirableInterface'); $this->keyValueExpirableFactory = $this->getMockBuilder('Drupal\\Core\\KeyValueStore\\KeyValueExpirableFactory')->disableOriginalConstructor()->getMock(); $this->keyValueExpirableFactory->expects($this->any())->method('get')->will($this->returnValueMap(array(array('form', $this->formCache), array('form_state', $this->formStateCache)))); $this->urlGenerator = $this->getMock('Drupal\\Core\\Routing\\UrlGeneratorInterface'); $this->classResolver = $this->getClassResolverStub(); $this->csrfToken = $this->getMockBuilder('Drupal\\Core\\Access\\CsrfTokenGenerator')->disableOriginalConstructor()->getMock(); $this->httpKernel = $this->getMockBuilder('Symfony\\Component\\HttpKernel\\HttpKernel')->disableOriginalConstructor()->getMock(); $this->account = $this->getMock('Drupal\\Core\\Session\\AccountInterface'); $this->request = new Request(); $this->eventDispatcher = $this->getMock('Symfony\\Component\\EventDispatcher\\EventDispatcherInterface'); $this->requestStack = new RequestStack(); $this->requestStack->push($this->request); $this->formValidator = $this->getMockBuilder('Drupal\\Core\\Form\\FormValidator')->setConstructorArgs(array($this->requestStack, $this->getStringTranslationStub(), $this->csrfToken))->setMethods(array('drupalSetMessage'))->getMock(); $this->formSubmitter = $this->getMockBuilder('Drupal\\Core\\Form\\FormSubmitter')->setConstructorArgs(array($this->requestStack, $this->urlGenerator))->setMethods(array('batchGet', 'drupalInstallationAttempted'))->getMock(); $this->formBuilder = new TestFormBuilder($this->formValidator, $this->formSubmitter, $this->moduleHandler, $this->keyValueExpirableFactory, $this->eventDispatcher, $this->requestStack, $this->classResolver, $this->csrfToken, $this->httpKernel); $this->formBuilder->setCurrentUser($this->account); }