InternalTypedDataTestTrait.php

Same filename in other branches
  1. 9 core/modules/serialization/tests/src/Unit/Normalizer/InternalTypedDataTestTrait.php
  2. 8.9.x core/modules/serialization/tests/src/Unit/Normalizer/InternalTypedDataTestTrait.php
  3. 10 core/modules/serialization/tests/src/Unit/Normalizer/InternalTypedDataTestTrait.php

Namespace

Drupal\Tests\serialization\Unit\Normalizer

File

core/modules/serialization/tests/src/Unit/Normalizer/InternalTypedDataTestTrait.php

View source
<?php

declare (strict_types=1);
namespace Drupal\Tests\serialization\Unit\Normalizer;

use Drupal\Core\TypedData\DataDefinitionInterface;
use Drupal\Core\TypedData\TypedDataInterface;

/**
 * Trait that provides mocked typed data objects.
 */
trait InternalTypedDataTestTrait {
    
    /**
     * Gets a typed data property.
     *
     * @param bool $internal
     *   Whether the typed data property is internal.
     *
     * @return \Drupal\Core\TypedData\TypedDataInterface
     *   The typed data property.
     */
    protected function getTypedDataProperty($internal = TRUE) {
        $definition = $this->prophesize(DataDefinitionInterface::class);
        $definition->isInternal()
            ->willReturn($internal)
            ->shouldBeCalled();
        $definition = $definition->reveal();
        $property = $this->prophesize(TypedDataInterface::class);
        $property->getDataDefinition()
            ->willReturn($definition)
            ->shouldBeCalled();
        return $property->reveal();
    }

}

Traits

Title Deprecated Summary
InternalTypedDataTestTrait Trait that provides mocked typed data objects.

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