public function EntityLoadHelperTest::testExtractContentPropertiesOnlyReturnsProperties in YAML Content 8
Test extractContentProperties returns property attributes.
@covers ::extractContentProperties
File
- tests/
src/ Unit/ EntityLoadHelper/ EntityLoadHelperTest.php, line 425
Class
- EntityLoadHelperTest
- Test functionality of the EntityLoadHelper class.
Namespace
Drupal\Tests\yaml_content\Unit\EntityLoadHelperCode
public function testExtractContentPropertiesOnlyReturnsProperties() {
$this->loadHelper = $this
->getEntityLoadHelperMock([
'categorizeAttributes',
]);
// Prepare the parameters.
$entity_type = 'test_entity';
// Do not include a UUID property.
$content_data = [
'entity' => 'test_entity',
'type' => 'test_bundle',
'status' => '1',
'field_title' => 'Test Title',
];
// Mock the categorizeAttributes return value.
$results = [
'property' => [
'entity' => 'test_entity',
'type' => 'test_bundle',
'status' => '1',
],
'field' => [
'field_title' => 'Test Title',
],
'other' => [],
];
$this->loadHelper
->method('categorizeAttributes')
->willReturn($results);
// Execute the method.
$actual = $this->loadHelper
->extractContentProperties($entity_type, $content_data);
// Confirm the return value.
$this
->assertSame($results['property'], $actual);
}