public function OgContextTest::getRuntimeContextsProvider in Organic groups 8
Data provider for ::testGetRuntimeContexts().
Return value
array An array of test data.
File
- tests/
src/ Unit/ OgContextTest.php, line 227
Class
- OgContextTest
- Tests the OgContext context provider.
Namespace
Drupal\Tests\og\UnitCode
public function getRuntimeContextsProvider() {
return [
// When 'og' is not present in the list of requested context IDs, then it
// should not return any context.
[
// A list of context IDs that does not include 'og'.
[
'node',
'current_user',
],
// It is irrelevant which group resolvers are configured when we are not
// requesting the OG context.
[],
// Nothing should be returned.
FALSE,
// Cache contexts are not relevant for this test.
[],
],
// "Normal" test case: a single group was found in context. For this test
// we simulate that a single group of type 'node' was found.
[
// The list of context IDs that are requested contains 'og'.
[
'node',
'og',
],
// Simulate 1 group resolver that returns 1 result.
[
'route_group' => [
'candidates' => [
[
'entity' => 'node-0',
'cache_contexts' => [
'route',
],
],
],
],
],
// It is expected that the group of type 'node' will be returned as
// group context.
'node-0',
// The cache context of the group will be returned as cacheability
// metadata.
[
'route',
],
],
// Two group resolver plugins which each return a single result. The
// result and cache contexts from the first plugin should be taken because
// it has higher priority.
[
[
'og',
'user',
],
[
'route_group' => [
'candidates' => [
[
'entity' => 'block_content-0',
'cache_contexts' => [
'route',
],
],
],
],
'user_access' => [
'candidates' => [
[
'entity' => 'entity_test-0',
'cache_contexts' => [
'user',
],
],
],
],
],
'block_content-0',
[
'route',
],
],
// Three group resolver plugins which all return different groups, but one
// of them is returned by two plugins. This should win and have its cache
// tags merged.
[
[
'domain',
'user',
'og',
],
[
'route_group' => [
'candidates' => [
[
'entity' => 'node-1',
'cache_contexts' => [
'route',
],
],
],
],
'request_query_argument' => [
'candidates' => [
[
'entity' => 'entity_test-1',
'cache_contexts' => [
'route',
],
],
[
'entity' => 'node-0',
'cache_contexts' => [
'url',
],
],
[
'entity' => 'block_content-1',
'cache_contexts' => [
'url',
],
],
],
],
'user_access' => [
'candidates' => [
[
'entity' => 'block_content-0',
'cache_contexts' => [
'user',
],
],
[
'entity' => 'block_content-1',
'cache_contexts' => [
'user',
],
],
],
],
],
'block_content-1',
[
'url',
'user',
],
],
// The same test case as the previous one, but now the first plugin
// stops propagation. The results from the other plugins should be
// ignored.
[
[
'domain',
'user',
'og',
],
[
'route_group' => [
'candidates' => [
[
'entity' => 'node-1',
'cache_contexts' => [
'route',
],
],
],
'stop_propagation' => TRUE,
],
'request_query_argument' => [
'candidates' => [
[
'entity' => 'entity_test-1',
'cache_contexts' => [
'route',
],
],
[
'entity' => 'node-0',
'cache_contexts' => [
'url',
],
],
[
'entity' => 'block_content-1',
'cache_contexts' => [
'url',
],
],
],
],
'user_access' => [
'candidates' => [
[
'entity' => 'block_content-0',
'cache_contexts' => [
'user',
],
],
[
'entity' => 'block_content-1',
'cache_contexts' => [
'user',
],
],
],
],
],
'node-1',
[
'route',
],
],
];
}