public function AuthcacheP13nTestObjectFactoryCase::testRequireDefaultProcessors in Authenticated User Page Caching (Authcache) 7.2
Cover AuthcacheP13nObjectFactory::defaultProcessors().
File
- modules/
authcache_p13n/ tests/ authcache_p13n.object-factory.test, line 317 - Define test cases for object factory.
Class
- AuthcacheP13nTestObjectFactoryCase
- Tests for object factory.
Code
public function testRequireDefaultProcessors() {
$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' => array(
'#type' => 'class',
'#class' => 'AuthcacheP13nTestObjectFactoryDummySubClass',
),
'require_null' => array(
'#type' => 'value',
'#value' => '@null[required]',
),
'require_zero' => array(
'#type' => 'value',
'#value' => '@zero[required]',
),
'require_non_zero' => array(
'#type' => 'value',
'#value' => '@non_zero[required]',
),
'require_object' => array(
'#type' => 'value',
'#value' => '@object[required]',
),
);
$factory = new AuthcacheP13nObjectFactory($resources, $processors);
try {
$factory
->get('require_null');
$this
->fail(t('Should throw an exception when required resource evaluates to null'));
} catch (AuthcacheP13nObjectFactoryException $e) {
unset($e);
$this
->pass(t('Should throw an exception when required resource evaluates to null'));
}
try {
$factory
->get('require_zero');
$this
->pass(t('Should not throw an exception when required resource evaluates to 0'));
} catch (AuthcacheP13nObjectFactoryException $e) {
unset($e);
$this
->fail(t('Should not throw an exception when required resource evaluates to 0'));
}
try {
$factory
->get('require_non_zero');
$this
->pass(t('Should not throw an exception when required resource evaluates to non-zero integer'));
} catch (AuthcacheP13nObjectFactoryException $e) {
unset($e);
$this
->fail(t('Should not throw an exception when required resource evaluates to non-zero integer'));
}
try {
$factory
->get('require_object');
$this
->pass(t('Should not throw an exception when required resource evaluates to an object'));
} catch (AuthcacheP13nObjectFactoryException $e) {
unset($e);
$this
->fail(t('Should not throw an exception when required resource evaluates to an object'));
}
}