You are here

protected function FormTestBase::setUp in Zircon Profile 8

Same name and namespace in other branches
  1. 8.0 core/tests/Drupal/Tests/Core/Form/FormTestBase.php \Drupal\Tests\Core\Form\FormTestBase::setUp()

Overrides UnitTestCase::setUp

1 call to FormTestBase::setUp()
FormBuilderTest::setUp in core/tests/Drupal/Tests/Core/Form/FormBuilderTest.php
1 method overrides FormTestBase::setUp()
FormBuilderTest::setUp in core/tests/Drupal/Tests/Core/Form/FormBuilderTest.php

File

core/tests/Drupal/Tests/Core/Form/FormTestBase.php, line 153
Contains \Drupal\Tests\Core\Form\FormTestBase.

Class

FormTestBase
Provides a base class for testing form functionality.

Namespace

Drupal\Tests\Core\Form

Code

protected function setUp() {
  parent::setUp();
  $this->moduleHandler = $this
    ->getMock('Drupal\\Core\\Extension\\ModuleHandlerInterface');
  $this->formCache = $this
    ->getMock('Drupal\\Core\\Form\\FormCacheInterface');
  $this->cache = $this
    ->getMock('Drupal\\Core\\Cache\\CacheBackendInterface');
  $this->urlGenerator = $this
    ->getMock('Drupal\\Core\\Routing\\UrlGeneratorInterface');
  $this->classResolver = $this
    ->getClassResolverStub();
  $this->elementInfo = $this
    ->getMockBuilder('\\Drupal\\Core\\Render\\ElementInfoManagerInterface')
    ->disableOriginalConstructor()
    ->getMock();
  $this->elementInfo
    ->expects($this
    ->any())
    ->method('getInfo')
    ->will($this
    ->returnCallback(array(
    $this,
    'getInfo',
  )));
  $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');
  $form_error_handler = $this
    ->getMock('Drupal\\Core\\Form\\FormErrorHandlerInterface');
  $this->formValidator = $this
    ->getMockBuilder('Drupal\\Core\\Form\\FormValidator')
    ->setConstructorArgs([
    $this->requestStack,
    $this
      ->getStringTranslationStub(),
    $this->csrfToken,
    $this->logger,
    $form_error_handler,
  ])
    ->setMethods(NULL)
    ->getMock();
  $this->formSubmitter = $this
    ->getMockBuilder('Drupal\\Core\\Form\\FormSubmitter')
    ->setConstructorArgs(array(
    $this->requestStack,
    $this->urlGenerator,
  ))
    ->setMethods(array(
    'batchGet',
    'drupalInstallationAttempted',
  ))
    ->getMock();
  $this->root = dirname(dirname(substr(__DIR__, 0, -strlen(__NAMESPACE__))));
  $this->formBuilder = new FormBuilder($this->formValidator, $this->formSubmitter, $this->formCache, $this->moduleHandler, $this->eventDispatcher, $this->requestStack, $this->classResolver, $this->elementInfo, $this->themeManager, $this->csrfToken);
}