class EntityFormBuilderTest in Zircon Profile 8
Same name and namespace in other branches
- 8.0 core/tests/Drupal/Tests/Core/Entity/EntityFormBuilderTest.php \Drupal\Tests\Core\Entity\EntityFormBuilderTest
@coversDefaultClass \Drupal\Core\Entity\EntityFormBuilder @group Entity
Hierarchy
- class \Drupal\Tests\UnitTestCase extends \Drupal\Tests\PHPUnit_Framework_TestCase
- class \Drupal\Tests\Core\Entity\EntityFormBuilderTest
Expanded class hierarchy of EntityFormBuilderTest
File
- core/
tests/ Drupal/ Tests/ Core/ Entity/ EntityFormBuilderTest.php, line 17 - Contains \Drupal\Tests\Core\Entity\EntityFormBuilderTest.
Namespace
Drupal\Tests\Core\EntityView source
class EntityFormBuilderTest extends UnitTestCase {
/**
* The entity manager.
*
* @var \Drupal\Core\Entity\EntityManagerInterface|\PHPUnit_Framework_MockObject_MockObject
*/
protected $entityManager;
/**
* The form builder.
*
* @var \Drupal\Core\Form\FormBuilderInterface|\PHPUnit_Framework_MockObject_MockObject
*/
protected $formBuilder;
/**
* The entity form builder.
*
* @var \Drupal\Core\Entity\EntityFormBuilderInterface
*/
protected $entityFormBuilder;
/**
* {@inheritdoc}
*/
protected function setUp() {
parent::setUp();
$this->formBuilder = $this
->getMock('Drupal\\Core\\Form\\FormBuilderInterface');
$this->entityManager = $this
->getMock('Drupal\\Core\\Entity\\EntityManagerInterface');
$this->entityFormBuilder = new EntityFormBuilder($this->entityManager, $this->formBuilder);
}
/**
* Tests the getForm() method.
*
* @covers ::getForm
*/
public function testGetForm() {
$form_controller = $this
->getMock('Drupal\\Core\\Entity\\EntityFormInterface');
$form_controller
->expects($this
->any())
->method('getFormId')
->will($this
->returnValue('the_form_id'));
$this->entityManager
->expects($this
->any())
->method('getFormObject')
->with('the_entity_type', 'default')
->will($this
->returnValue($form_controller));
$this->formBuilder
->expects($this
->once())
->method('buildForm')
->with($form_controller, $this
->isInstanceOf('Drupal\\Core\\Form\\FormStateInterface'))
->will($this
->returnValue('the form contents'));
$entity = $this
->getMock('Drupal\\Core\\Entity\\EntityInterface');
$entity
->expects($this
->once())
->method('getEntityTypeId')
->will($this
->returnValue('the_entity_type'));
$this
->assertSame('the form contents', $this->entityFormBuilder
->getForm($entity));
}
}
Members
Name | Modifiers | Type | Description | Overrides |
---|---|---|---|---|
EntityFormBuilderTest:: |
protected | property | The entity form builder. | |
EntityFormBuilderTest:: |
protected | property | The entity manager. | |
EntityFormBuilderTest:: |
protected | property | The form builder. | |
EntityFormBuilderTest:: |
protected | function |
Overrides UnitTestCase:: |
|
EntityFormBuilderTest:: |
public | function | Tests the getForm() method. | |
UnitTestCase:: |
protected | property | The random generator. | |
UnitTestCase:: |
protected | property | The app root. | |
UnitTestCase:: |
protected | function | Asserts if two arrays are equal by sorting them first. | |
UnitTestCase:: |
protected | function | Mocks a block with a block plugin. | |
UnitTestCase:: |
protected | function | Returns a stub class resolver. | |
UnitTestCase:: |
public | function | Returns a stub config factory that behaves according to the passed in array. | |
UnitTestCase:: |
public | function | Returns a stub config storage that returns the supplied configuration. | |
UnitTestCase:: |
protected | function | Sets up a container with a cache tags invalidator. | |
UnitTestCase:: |
protected | function | Gets the random generator for the utility methods. | |
UnitTestCase:: |
public | function | Returns a stub translation manager that just returns the passed string. | |
UnitTestCase:: |
public | function | Generates a unique random string containing letters and numbers. |