@coversDefaultClass \Drupal\field_ui\Form\FieldConfigEditForm
@group field_ui
Hierarchy
- class \Drupal\Tests\UnitTestCase extends \PHPUnit\Framework\TestCase uses \Drupal\Tests\PhpUnitCompatibilityTrait, \Prophecy\PhpUnit\ProphecyTrait, \Symfony\Bridge\PhpUnit\ExpectDeprecationTrait, RandomGeneratorTrait, PhpUnitWarnings
- class \Drupal\Tests\field_ui\Unit\FieldConfigEditFormTest
Expanded class hierarchy of FieldConfigEditFormTest
File
- core/
modules/ field_ui/ tests/ src/ Unit/ FieldConfigEditFormTest.php, line 18
Namespace
Drupal\Tests\field_ui\UnitView source
class FieldConfigEditFormTest extends UnitTestCase {
/**
* The field config edit form.
*
* @var \Drupal\field_ui\Form\FieldConfigEditForm|\PHPUnit\Framework\MockObject\MockObject
*/
protected $fieldConfigEditForm;
/**
* {@inheritdoc}
*/
protected function setUp() : void {
parent::setUp();
$entity_type_bundle_info = $this
->createMock('\\Drupal\\Core\\Entity\\EntityTypeBundleInfoInterface');
$typed_data = $this
->createMock('\\Drupal\\Core\\TypedData\\TypedDataManagerInterface');
$temp_store = $this
->createMock(PrivateTempStore::class);
$element_info_manager = $this
->createMock(ElementInfoManagerInterface::class);
$entity_display_repository = $this
->createMock(EntityDisplayRepositoryInterface::class);
$this->fieldConfigEditForm = new FieldConfigEditForm($entity_type_bundle_info, $typed_data, $entity_display_repository, $temp_store, $element_info_manager);
}
/**
* @covers ::hasAnyRequired
*
* @dataProvider providerRequired
*/
public function testHasAnyRequired(array $element, bool $result) {
$reflection = new \ReflectionClass('\\Drupal\\field_ui\\Form\\FieldConfigEditForm');
$method = $reflection
->getMethod('hasAnyRequired');
$this
->assertEquals($result, $method
->invoke($this->fieldConfigEditForm, $element));
}
/**
* Provides test cases with required and optional elements.
*/
public static function providerRequired() : \Generator {
(yield 'required' => [
[
[
'#required' => TRUE,
],
],
TRUE,
]);
(yield 'optional' => [
[
[
'#required' => FALSE,
],
],
FALSE,
]);
(yield 'required and optional' => [
[
[
'#required' => TRUE,
],
[
'#required' => FALSE,
],
],
TRUE,
]);
(yield 'empty' => [
[
[],
[],
],
FALSE,
]);
(yield 'multiple required' => [
[
[
[
'#required' => TRUE,
],
],
[
[
'#required' => TRUE,
],
],
],
TRUE,
]);
(yield 'multiple optional' => [
[
[
[
'#required' => FALSE,
],
],
[
[
'#required' => FALSE,
],
],
],
FALSE,
]);
}
}
Members
Name | Modifiers | Type | Description | Overrides |
---|---|---|---|---|
FieldConfigEditFormTest:: |
protected | property | The field config edit form. | |
FieldConfigEditFormTest:: |
public static | function | Provides test cases with required and optional elements. | |
FieldConfigEditFormTest:: |
protected | function |
Overrides UnitTestCase:: |
|
FieldConfigEditFormTest:: |
public | function | @covers ::hasAnyRequired | |
PhpUnitWarnings:: |
private static | property | Deprecation warnings from PHPUnit to raise with @trigger_error(). | |
PhpUnitWarnings:: |
public | function | Converts PHPUnit deprecation warnings to E_USER_DEPRECATED. | |
RandomGeneratorTrait:: |
protected | function | Gets the random generator for the utility methods. | |
RandomGeneratorTrait:: |
protected | function | Generates a unique random string containing letters and numbers. | |
RandomGeneratorTrait:: |
public | function | Generates a random PHP object. | |
RandomGeneratorTrait:: |
public | function | Generates a pseudo-random string of ASCII characters of codes 32 to 126. | |
RandomGeneratorTrait:: |
public | function | Callback for random string validation. | |
UnitTestCase:: |
protected | property | The app root. | 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:: |
public | function | Returns a stub translation manager that just returns the passed string. | |
UnitTestCase:: |
public static | function | ||
UnitTestCase:: |
public | function |