function FormTestBase::getMockForm
Same name in other branches
- 9 core/tests/Drupal/Tests/Core/Form/FormTestBase.php \Drupal\Tests\Core\Form\FormTestBase::getMockForm()
- 10 core/tests/Drupal/Tests/Core/Form/FormTestBase.php \Drupal\Tests\Core\Form\FormTestBase::getMockForm()
- 11.x core/tests/Drupal/Tests/Core/Form/FormTestBase.php \Drupal\Tests\Core\Form\FormTestBase::getMockForm()
Provides a mocked form object.
Parameters
string $form_id: The form ID to be used.
mixed $expected_form: (optional) If provided, the expected form response for buildForm() to return. Defaults to NULL.
int $count: (optional) The number of times the form is expected to be built. Defaults to 1.
Return value
\PHPUnit\Framework\MockObject\MockObject|\Drupal\Core\Form\FormInterface The mocked form object.
10 calls to FormTestBase::getMockForm()
- FormBuilderTest::testBuildFormWithObject in core/
tests/ Drupal/ Tests/ Core/ Form/ FormBuilderTest.php - Tests the buildForm() method with a form object.
- FormBuilderTest::testBuildFormWithTriggeringElement in core/
tests/ Drupal/ Tests/ Core/ Form/ FormBuilderTest.php - Tests whether the triggering element is properly identified.
- FormBuilderTest::testExceededFileSize in core/
tests/ Drupal/ Tests/ Core/ Form/ FormBuilderTest.php - @covers ::buildForm
- FormBuilderTest::testFormCacheDeletionCached in core/
tests/ Drupal/ Tests/ Core/ Form/ FormBuilderTest.php - Tests that a cached form is deleted after submit.
- FormBuilderTest::testFormCacheDeletionUncached in core/
tests/ Drupal/ Tests/ Core/ Form/ FormBuilderTest.php - Tests that an uncached form does not trigger cache set or delete.
File
-
core/
tests/ Drupal/ Tests/ Core/ Form/ FormTestBase.php, line 218
Class
- FormTestBase
- Provides a base class for testing form functionality.
Namespace
Drupal\Tests\Core\FormCode
protected function getMockForm($form_id, $expected_form = NULL, $count = 1) {
$form = $this->createMock('Drupal\\Core\\Form\\FormInterface');
$form->expects($this->once())
->method('getFormId')
->will($this->returnValue($form_id));
if ($expected_form) {
$form->expects($this->exactly($count))
->method('buildForm')
->will($this->returnValue($expected_form));
}
return $form;
}
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.