public function FieldConfigEntityUnitTest::testToArray in Zircon Profile 8
Same name and namespace in other branches
- 8.0 core/modules/field/tests/src/Unit/FieldConfigEntityUnitTest.php \Drupal\Tests\field\Unit\FieldConfigEntityUnitTest::testToArray()
@covers ::toArray
File
- core/
modules/ field/ tests/ src/ Unit/ FieldConfigEntityUnitTest.php, line 247 - Contains \Drupal\Tests\field\Unit\FieldConfigEntityUnitTest.
Class
- FieldConfigEntityUnitTest
- @coversDefaultClass \Drupal\field\Entity\FieldConfig @group field
Namespace
Drupal\Tests\field\UnitCode
public function testToArray() {
$field = new FieldConfig(array(
'field_name' => $this->fieldStorage
->getName(),
'entity_type' => 'test_entity_type',
'bundle' => 'test_bundle',
'field_type' => 'test_field',
), $this->entityTypeId);
$expected = array(
'id' => 'test_entity_type.test_bundle.field_test',
'uuid' => NULL,
'status' => TRUE,
'langcode' => 'en',
'field_name' => 'field_test',
'entity_type' => 'test_entity_type',
'bundle' => 'test_bundle',
'label' => '',
'description' => '',
'required' => FALSE,
'default_value' => array(),
'default_value_callback' => '',
'settings' => array(),
'dependencies' => array(),
'field_type' => 'test_field',
);
$this->entityManager
->expects($this
->any())
->method('getDefinition')
->with($this->entityTypeId)
->will($this
->returnValue($this->entityType));
$this->entityType
->expects($this
->once())
->method('getKey')
->with('id')
->will($this
->returnValue('id'));
$this->typedConfigManager
->expects($this
->once())
->method('getDefinition')
->will($this
->returnValue(array(
'mapping' => array_fill_keys(array_keys($expected), ''),
)));
$export = $field
->toArray();
$this
->assertEquals($expected, $export);
}