->
onlyMethods(['getContextDefinition'
]) ->
getMock();
// If the context value exists, getContextValue() behaves like a normal
// getter.
if ($context_value) { // Set visibility of contextValue.
$ref_context_value =
new \
ReflectionProperty($mock_context, 'contextValue'
);
// Set contextValue to a testable state.
$ref_context_value->
setValue($mock_context,
$context_value);
// Exercise getContextValue().
$this->
assertEquals($context_value,
$mock_context->
getContextValue());
} // If no context value exists, we have to cover either returning NULL or
// throwing an exception if the definition requires it.
else { // Create a mock definition.
$mock_definition =
$this->
getMockBuilder('Drupal\Component\Plugin\Context\ContextDefinitionInterface'
) ->
onlyMethods(['isRequired', 'getDataType'
]) ->
getMockForAbstractClass();
// Set expectation for isRequired().
$mock_definition->
expects($this->
once())