function FieldTypePluginManagerTest::testGetGroupedDefinitionsInvalid
Same name in other branches
- 10 core/tests/Drupal/Tests/Core/Field/FieldTypePluginManagerTest.php \Drupal\Tests\Core\Field\FieldTypePluginManagerTest::testGetGroupedDefinitionsInvalid()
@covers ::getGroupedDefinitions
File
-
core/
tests/ Drupal/ Tests/ Core/ Field/ FieldTypePluginManagerTest.php, line 135
Class
- FieldTypePluginManagerTest
- @coversDefaultClass \Drupal\Core\Field\FieldTypePluginManager @group Field
Namespace
Drupal\Tests\Core\FieldCode
public function testGetGroupedDefinitionsInvalid() : void {
$this->discovery
->getDefinitions()
->willReturn([
'string' => [
'category' => 'text',
'label' => 'Text (plain)',
'id' => 'string',
],
]);
$this->fieldTypeCategoryManager
->getDefinitions()
->willReturn([
'general' => [
'label' => 'General',
'id' => 'general',
],
]);
$zend_assertions_default = ini_get('zend.assertions');
// Test behavior when assertions are not enabled.
ini_set('zend.assertions', 0);
$grouped_definitions = $this->fieldTypeManager
->getGroupedDefinitions();
$this->assertEquals([
'General',
], array_keys($grouped_definitions));
// Test behavior when assertions are enabled.
ini_set('zend.assertions', 1);
$this->expectException(\AssertionError::class);
try {
$this->fieldTypeManager
->getGroupedDefinitions();
} catch (\Exception $e) {
// Reset the original assert values.
ini_set('zend.assertions', $zend_assertions_default);
throw $e;
}
}
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.