$this->
assertEquals($user->
label(),
$plugin->
getTitle());
// Test Optional context handling.
$plugin =
$manager->
createInstance('user_name_optional'
);
$this->
assertNull($plugin->
getContextValue('user'
), 'Requesting a non-set value of a valid context should return NULL.'
);
// Test Complex compound context handling.
$complex_plugin =
$manager->
createInstance('complex_context'
);
$complex_plugin->
setContextValue('user',
$user);
// With only the user context set, try to get the context values.
$values =
$complex_plugin->
getContextValues();
$this->
assertNull($values['node'
], 'The node context is not yet set.'
);
$this->
assertNotNull($values['user'
], 'The user context is set'
);
$complex_plugin->
setContextValue('node',
$node);
$context_wrappers =
$complex_plugin->
getContexts();
// Make sure what came out of the wrappers is good.
$this->
assertEquals($user->
label(),
$context_wrappers['user'
]->
getContextValue()->
label());
$this->
assertEquals($node->
label(),
$context_wrappers['node'
]->
getContextValue()->
label());
// Make sure what comes out of the context values is good.
$contexts =
$complex_plugin->
getContextValues();