The context properties to give depend on the implementation of the context object, for the
Neos\ContentRepository\Domain\Service\Context it should look like this:
array(
'workspaceName' => 'live',
'currentDateTime' => new \Neos\Flow\Utility\Now(),
'dimensions' => array(...),
'targetDimensions' => array('language' => 'de', 'persona' => 'Lisa'),
'invisibleContentShown' => FALSE,
'removedContentShown' => FALSE,
'inaccessibleContentShown' => FALSE
)
This array also shows the defaults that get used if you don't provide a certain property.
/** * @test */ public function setDateTimeAllowsForMockingTheCurrentTime() { $simulatedCurrentTime = new \DateTime(); $simulatedCurrentTime->add(new \DateInterval('P1D')); $context = $this->contextFactory->create(array('currentDateTime' => $simulatedCurrentTime)); $this->assertEquals($simulatedCurrentTime, $context->getCurrentDateTime()); }
/** * Returns a node from the given $nodeIdentifier (disabling authorization checks) * * @param string $nodeIdentifier * @return NodeInterface */ protected function getNodeByIdentifier($nodeIdentifier) { $context = $this->contextFactory->create(); $node = null; $this->securityContext->withoutAuthorizationChecks(function () use($nodeIdentifier, $context, &$node) { $node = $context->getNodeByIdentifier($nodeIdentifier); }); $context->getFirstLevelNodeCache()->setByIdentifier($nodeIdentifier, null); return $node; }