Updated to Drupal 8.5. Core Media not yet in use.
[yaffs-website] / web / core / modules / serialization / tests / src / Unit / Normalizer / InternalTypedDataTestTrait.php
diff --git a/web/core/modules/serialization/tests/src/Unit/Normalizer/InternalTypedDataTestTrait.php b/web/core/modules/serialization/tests/src/Unit/Normalizer/InternalTypedDataTestTrait.php
new file mode 100644 (file)
index 0000000..3829934
--- /dev/null
@@ -0,0 +1,36 @@
+<?php
+
+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();
+  }
+
+}