Same name and namespace in other branches
  1. 8.9.x core/modules/serialization/tests/src/Unit/Normalizer/InternalTypedDataTestTrait.php \Drupal\Tests\serialization\Unit\Normalizer\InternalTypedDataTestTrait
  2. 9 core/modules/serialization/tests/src/Unit/Normalizer/InternalTypedDataTestTrait.php \Drupal\Tests\serialization\Unit\Normalizer\InternalTypedDataTestTrait

Trait that provides mocked typed data objects.

Hierarchy

File

core/modules/serialization/tests/src/Unit/Normalizer/InternalTypedDataTestTrait.php, line 13

Namespace

Drupal\Tests\serialization\Unit\Normalizer
View source
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();
  }

}

Members