function ContentEntityNormalizerTest::createMockForContentEntity

Same name in other branches
  1. 9 core/modules/serialization/tests/src/Unit/Normalizer/ContentEntityNormalizerTest.php \Drupal\Tests\serialization\Unit\Normalizer\ContentEntityNormalizerTest::createMockForContentEntity()
  2. 8.9.x core/modules/serialization/tests/src/Unit/Normalizer/ContentEntityNormalizerTest.php \Drupal\Tests\serialization\Unit\Normalizer\ContentEntityNormalizerTest::createMockForContentEntity()
  3. 11.x core/modules/serialization/tests/src/Unit/Normalizer/ContentEntityNormalizerTest.php \Drupal\Tests\serialization\Unit\Normalizer\ContentEntityNormalizerTest::createMockForContentEntity()

Creates a mock content entity.

Parameters

$definitions: The properties the will be returned.

Return value

\PHPUnit\Framework\MockObject\MockObject

2 calls to ContentEntityNormalizerTest::createMockForContentEntity()
ContentEntityNormalizerTest::testNormalize in core/modules/serialization/tests/src/Unit/Normalizer/ContentEntityNormalizerTest.php
Tests the normalize() method.
ContentEntityNormalizerTest::testNormalizeWithAccountContext in core/modules/serialization/tests/src/Unit/Normalizer/ContentEntityNormalizerTest.php
Tests the normalize() method with account context passed.

File

core/modules/serialization/tests/src/Unit/Normalizer/ContentEntityNormalizerTest.php, line 130

Class

ContentEntityNormalizerTest
@coversDefaultClass \Drupal\serialization\Normalizer\ContentEntityNormalizer @group serialization

Namespace

Drupal\Tests\serialization\Unit\Normalizer

Code

public function createMockForContentEntity($definitions) {
    $content_entity_mock = $this->getMockBuilder(ContentEntityBaseMockableClass::class)
        ->disableOriginalConstructor()
        ->onlyMethods([
        'getTypedData',
    ])
        ->getMock();
    $typed_data = $this->prophesize(ComplexDataInterface::class);
    $typed_data->getProperties(TRUE)
        ->willReturn($definitions)
        ->shouldBeCalled();
    $content_entity_mock->expects($this->any())
        ->method('getTypedData')
        ->willReturn($typed_data->reveal());
    return $content_entity_mock;
}

Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.