class ComponentSectionFormHandlerTest in Module Builder 8.3
Tests the ComponentSectionFormHandler entity handler.
@group module_builder
Hierarchy
- class \Drupal\Tests\UnitTestCase extends \PHPUnit\Framework\TestCase uses PhpunitCompatibilityTrait
- class \Drupal\Tests\module_builder\Unit\ComponentSectionFormHandlerTest
Expanded class hierarchy of ComponentSectionFormHandlerTest
File
- tests/
src/ Unit/ ComponentSectionFormHandlerTest.php, line 12
Namespace
Drupal\Tests\module_builder\UnitView source
class ComponentSectionFormHandlerTest extends UnitTestCase {
/**
* The modules to enable.
*
* @var array
*/
public static $modules = [
'system',
'module_builder',
];
/**
* Tests the ComponentSectionFormHandler entity handler.
*/
public function testComponentSectionFormHandler() {
$entity_code_builder_annotation_data = [
"section_forms" => [
"name" => [
"title" => "Edit basic properties",
"tab_title" => "Name",
"properties" => [
"name_1",
"name_2",
"name_3",
],
],
"hooks" => [
"title" => "Edit hooks",
"tab_title" => "Hooks",
"properties" => [
"hooks_1",
],
],
],
];
$entity_type = $this
->prophesize(\Drupal\Core\Entity\EntityTypeInterface::class);
$entity_type
->id()
->willReturn('test');
$entity_type
->get('code_builder')
->willReturn($entity_code_builder_annotation_data);
// Create the handler, with mock passed in.
$component_sections_handler = new \Drupal\module_builder\EntityHandler\ComponentSectionFormHandler($entity_type
->reveal());
$form_operations_expected = [
'hooks',
'misc',
'generate',
];
$this
->assertEquals($form_operations_expected, $component_sections_handler
->getFormOperations());
$form_tab_routes_expected = [
'hooks' => "Edit hooks",
'misc' => "Edit %label miscellaneous components",
'generate' => 'Generate code for %label',
];
$this
->assertEquals($form_tab_routes_expected, $component_sections_handler
->getFormTabRoutePaths());
$form_tab_tasks_expected = [
'hooks' => "Hooks",
'misc' => "Misc",
'generate' => 'Generate code',
];
$this
->assertEquals($form_tab_tasks_expected, $component_sections_handler
->getFormTabLocalTasksData());
$this
->assertEquals([
"name_1",
"name_2",
"name_3",
], $component_sections_handler
->getSectionFormComponentProperties('name'));
$this
->assertEquals([
"hooks_1",
], $component_sections_handler
->getSectionFormComponentProperties('hooks'));
$this
->assertEquals([
"name_1",
"name_2",
"name_3",
"hooks_1",
], $component_sections_handler
->getUsedComponentProperties());
}
}
Members
Name | Modifiers | Type | Description | Overrides |
---|---|---|---|---|
ComponentSectionFormHandlerTest:: |
public static | property | The modules to enable. | |
ComponentSectionFormHandlerTest:: |
public | function | Tests the ComponentSectionFormHandler entity handler. | |
PhpunitCompatibilityTrait:: |
public | function | Returns a mock object for the specified class using the available method. | |
PhpunitCompatibilityTrait:: |
public | function | Compatibility layer for PHPUnit 6 to support PHPUnit 4 code. | |
UnitTestCase:: |
protected | property | The random generator. | |
UnitTestCase:: |
protected | property | The app root. | 1 |
UnitTestCase:: |
protected | function | Asserts if two arrays are equal by sorting them first. | |
UnitTestCase:: |
protected | function | Mocks a block with a block plugin. | 1 |
UnitTestCase:: |
protected | function | Returns a stub class resolver. | |
UnitTestCase:: |
public | function | Returns a stub config factory that behaves according to the passed 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. | |
UnitTestCase:: |
protected | function | 340 |