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.
Comments
Comment #2
cburschkaThere 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).
Comment #3
cburschkaPatch for the first option.
Comment #4
cburschka- Or, for compatibility with previous versions, just use willReturn(1) instead of shouldBeCalled().
Comment #5
tim.plunkettI went with the other fix, since Pages should always have a UUID.