function FormTestBase::setUp
Same name and namespace in other branches
- 11.x core/tests/Drupal/Tests/Core/Form/FormTestBase.php \Drupal\Tests\Core\Form\FormTestBase::setUp()
- 10 core/tests/Drupal/Tests/Core/Form/FormTestBase.php \Drupal\Tests\Core\Form\FormTestBase::setUp()
- 9 core/tests/Drupal/Tests/Core/Form/FormTestBase.php \Drupal\Tests\Core\Form\FormTestBase::setUp()
- 8.9.x 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 177
Class
- FormTestBase
- Provides a base class for testing form functionality.
Namespace
Drupal\Tests\Core\FormCode
protected function setUp() : void {
parent::setUp();
$this->moduleHandler = $this->createStub(ModuleHandlerInterface::class);
$this->formCache = $this->createStub(FormCacheInterface::class);
$this->cache = $this->createStub(CacheBackendInterface::class);
$this->urlGenerator = $this->createStub(UrlGeneratorInterface::class);
$this->redirectResponseSubscriber = $this->createStub(RedirectResponseSubscriber::class);
$this->classResolver = $this->getClassResolverStub();
$this->elementInfo = $this->createStub(ElementInfoManagerInterface::class);
$this->elementInfo
->method('getInfo')
->willReturnCallback([
$this,
'getInfo',
]);
$this->csrfToken = $this->createStub(CsrfTokenGenerator::class);
$this->kernel = $this->createStub(DrupalKernel::class);
$this->account = $this->createStub(AccountInterface::class);
$this->themeManager = $this->createStub(ThemeManagerInterface::class);
$this->request = Request::createFromGlobals();
$this->request
->setSession(new Session(new MockArraySessionStorage()));
$this->eventDispatcher = $this->createStub(EventDispatcherInterface::class);
$this->requestStack = new RequestStack();
$this->requestStack
->push($this->request);
$this->logger = $this->createStub(LoggerChannelInterface::class);
$form_error_handler = $this->createStub(FormErrorHandlerInterface::class);
$this->callableResolver = $this->createStub(CallableResolver::class);
$this->formValidator = new FormValidator($this->requestStack, $this->getStringTranslationStub(), $this->csrfToken, $this->logger, $form_error_handler, $this->callableResolver);
$this->formSubmitter = new StubFormSubmitter($this->requestStack, $this->urlGenerator, $this->redirectResponseSubscriber, $this->callableResolver);
$this->root = dirname(substr(__DIR__, 0, -strlen(__NAMESPACE__)), 2);
$this->formBuilder = new FormBuilder($this->formValidator, $this->formSubmitter, $this->formCache, $this->moduleHandler, $this->eventDispatcher, $this->requestStack, $this->classResolver, $this->elementInfo, $this->themeManager, $this->csrfToken, $this->callableResolver);
}
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.