Updated Drupal to 8.6. This goes with the following updates because it's possible...
[yaffs-website] / web / core / modules / block_content / tests / src / Unit / Access / AccessibleTestingTrait.php
diff --git a/web/core/modules/block_content/tests/src/Unit/Access/AccessibleTestingTrait.php b/web/core/modules/block_content/tests/src/Unit/Access/AccessibleTestingTrait.php
new file mode 100644 (file)
index 0000000..8aab227
--- /dev/null
@@ -0,0 +1,36 @@
+<?php
+
+namespace Drupal\Tests\block_content\Unit\Access;
+
+use Drupal\Core\Access\AccessibleInterface;
+use Drupal\Core\Access\AccessResultInterface;
+
+/**
+ * Helper methods testing accessible interfaces.
+ */
+trait AccessibleTestingTrait {
+
+  /**
+   * The test account.
+   *
+   * @var \Drupal\Core\Session\AccountInterface
+   */
+  protected $account;
+
+  /**
+   * Creates AccessibleInterface object from access result object for testing.
+   *
+   * @param \Drupal\Core\Access\AccessResultInterface $accessResult
+   *   The accessible result to return.
+   *
+   * @return \Drupal\Core\Access\AccessibleInterface
+   *   The AccessibleInterface object.
+   */
+  private function createAccessibleDouble(AccessResultInterface $accessResult) {
+    $accessible = $this->prophesize(AccessibleInterface::class);
+    $accessible->access('view', $this->account, TRUE)
+      ->willReturn($accessResult);
+    return $accessible->reveal();
+  }
+
+}