public function AuthcacheP13nTestObjectFactoryCase::testRequireAcceptClassProcessors in Authenticated User Page Caching (Authcache) 7.2
Cover AuthcacheP13nObjectFactory::defaultProcessors().
File
- modules/
authcache_p13n/ tests/ authcache_p13n.object-factory.test, line 396 - Define test cases for object factory.
Class
- AuthcacheP13nTestObjectFactoryCase
- Tests for object factory.
Code
public function testRequireAcceptClassProcessors() {
$processors = AuthcacheP13nObjectFactory::defaultProcessors();
$resources = array(
'null' => array(
'#type' => 'value',
'#value' => NULL,
),
'zero' => array(
'#type' => 'value',
'#value' => 0,
),
'non_zero' => array(
'#type' => 'value',
'#value' => 42,
),
'object_class' => array(
'#type' => 'class',
'#class' => 'AuthcacheP13nTestObjectFactoryDummyClass',
),
'object_subclass' => array(
'#type' => 'class',
'#class' => 'AuthcacheP13nTestObjectFactoryDummySubClass',
),
'object_other_class' => array(
'#type' => 'class',
'#class' => 'AuthcacheP13nTestObjectFactoryDisconnectedDummyClass',
),
'accept_object_null' => array(
'#type' => 'value',
'#value' => '@null[accept_instance(AuthcacheP13nTestObjectFactoryDummyClass)]',
),
'accept_object_zero' => array(
'#type' => 'value',
'#value' => '@zero[accept_instance(AuthcacheP13nTestObjectFactoryDummyClass)]',
),
'accept_object_non_zero' => array(
'#type' => 'value',
'#value' => '@non_zero[accept_instance(AuthcacheP13nTestObjectFactoryDummyClass)]',
),
'accept_object_object_interface' => array(
'#type' => 'value',
'#value' => '@object_class[accept_instance(AuthcacheP13nTestObjectFactoryDummySubInterface)]',
),
'accept_object_object_subinterface' => array(
'#type' => 'value',
'#value' => '@object_subclass[accept_instance(AuthcacheP13nTestObjectFactoryDummySubInterface)]',
),
'accept_object_object_class' => array(
'#type' => 'value',
'#value' => '@object_class[accept_instance(AuthcacheP13nTestObjectFactoryDummyClass)]',
),
'accept_object_object_subclass' => array(
'#type' => 'value',
'#value' => '@object_subclass[accept_instance(AuthcacheP13nTestObjectFactoryDummyClass)]',
),
'accept_object_object_other_class' => array(
'#type' => 'value',
'#value' => '@object_other_class[accept_instance(AuthcacheP13nTestObjectFactoryDummyClass)]',
),
);
$factory = new AuthcacheP13nObjectFactory($resources, $processors);
$expectations = array(
'accept_object_null' => NULL,
'accept_object_zero' => NULL,
'accept_object_non_zero' => NULL,
'accept_object_object_interface' => NULL,
'accept_object_object_subinterface' => new AuthcacheP13nTestObjectFactoryDummySubClass(),
'accept_object_object_class' => new AuthcacheP13nTestObjectFactoryDummyClass(),
'accept_object_object_subclass' => new AuthcacheP13nTestObjectFactoryDummySubClass(),
'accept_object_object_other_class' => NULL,
);
foreach ($expectations as $resource_name => $expect) {
$result = $factory
->get($resource_name);
$this
->assertEqual($expect, $result, $resource_name);
}
}