The PageAccessTest unit test fails on 8.3.7 because of an unexpected call to a mocked entity:

1) Drupal\Tests\page_manager\Unit\PageAccessTest::testAccessView
Prophecy\Exception\Call\UnexpectedCallException: Method call:
  - id()
on Double\PageInterface\P19 was not expected, expected calls were:
  - getContexts()
  - getAccessConditions()
  - getAccessLogic()
  - status()
  - language()
  - uuid()
  - getEntityTypeId()

This was introduced by a patch for SA-CORE-2017-04, which added a fallback the cache ID to TYPE:ID if the entity does not have a UUID.

-    if (($return = $this->getCache($entity->uuid(), $operation, $langcode, $account)) !== NULL) {
+    // If an entity does not have a UUID, either from not being set or from not
+    // having them, use the 'entity type:ID' pattern as the cache $cid.
+    $cid = $entity->uuid() ?: $entity->getEntityTypeId() . ':' . $entity->id();

I believe the correct fix for this is to add id() to the expected methods for the mock.

CommentFileSizeAuthor
#3 page_manager-2903786-unit-test.patch1.25 KBcburschka

Comments

cburschka created an issue. See original summary.

cburschka’s picture

There are two solutions: Use ->id()->shouldBeCalled(), or let uuid() return a fixed random UUID value to avoid calling it in the first place.

The first option will break the unit test on any version prior to 8.3.7 (though technically, those older versions are not supported anymore).

cburschka’s picture

Status: Active » Needs review
StatusFileSize
new1.25 KB

Patch for the first option.

cburschka’s picture

- Or, for compatibility with previous versions, just use willReturn(1) instead of shouldBeCalled().

tim.plunkett’s picture

Status: Needs review » Fixed

I went with the other fix, since Pages should always have a UUID.

  • tim.plunkett committed 26cbad4 on 8.x-4.x
    Issue #2903786 by tim.plunkett, cburschka: Update PageAccessTest for...

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.