function ContentEntityNormalizerTest::createMockForContentEntity

Same name and namespace in other branches
  1. 9 core/modules/serialization/tests/src/Unit/Normalizer/ContentEntityNormalizerTest.php \Drupal\Tests\serialization\Unit\Normalizer\ContentEntityNormalizerTest::createMockForContentEntity()
  2. 10 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:

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 128

Class

ContentEntityNormalizerTest
@coversDefaultClass <a href="/api/drupal/core%21modules%21serialization%21src%21Normalizer%21ContentEntityNormalizer.php/class/ContentEntityNormalizer/8.9.x" title="Normalizes/denormalizes Drupal content entities into an array structure." class="local">\Drupal\serialization\Normalizer\ContentEntityNormalizer</a> @group serialization

Namespace

Drupal\Tests\serialization\Unit\Normalizer

Code

public function createMockForContentEntity($definitions) {
    $content_entity_mock = $this->getMockBuilder('Drupal\\Core\\Entity\\ContentEntityBase')
        ->disableOriginalConstructor()
        ->setMethods([
        'getTypedData',
    ])
        ->getMockForAbstractClass();
    $typed_data = $this->prophesize(ComplexDataInterface::class);
    $typed_data->getProperties(TRUE)
        ->willReturn($definitions)
        ->shouldBeCalled();
    $content_entity_mock->expects($this->any())
        ->method('getTypedData')
        ->will($this->returnValue($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.