public function ExistenceCheckingTest::testBuildEntityCallsCreateEntity in YAML Content 8
Tests `buildEntity()` always calls `createEntity()`.
@dataProvider contentDataProvider
@covers ::buildEntity @covers ::createEntity
Parameters
string $entity_type: The entity type machine name for the content being tested.
array $test_content: Import content for this test scenario.
File
- tests/
src/ Unit/ ContentLoader/ ExistenceCheckingTest.php, line 116
Class
- ExistenceCheckingTest
- Test the existence checking functionality of the ContentLoader class.
Namespace
Drupal\Tests\yaml_content\Unit\ContentLoaderCode
public function testBuildEntityCallsCreateEntity($entity_type, array $test_content) {
$this
->markTestSkipped('Enable this test once event dispatching is consolidated.');
// Stub methods used in the buildEntity() method.
$this->contentLoader = $this
->getContentLoaderMock([
'dispatchEvent',
'getEntityTypeDefinition',
'getContentAttributes',
'getEntityStorage',
'getEntityHandler',
'populateEntityFields',
'createEntity',
]);
// Confirm `createEntity()` gets called as expected.
$this->contentLoader
->expects($this
->once())
->method('createEntity')
->with($this
->equalTo($entity_type), $this
->equalTo($test_content));
$this->contentLoader
->buildEntity($entity_type, $test_content);
}