public function AuthcacheP13nTestFragmentAssemblyBuilder::testFragmentAssemblyBuilderAccessChecker in Authenticated User Page Caching (Authcache) 7.2
Test request with access checker.
File
- modules/
authcache_p13n/ tests/ authcache_p13n.request-handler.test, line 593 - Define unit tests for request handler.
Class
- AuthcacheP13nTestFragmentAssemblyBuilder
- Tests update functionality unrelated to the database.
Code
public function testFragmentAssemblyBuilderAccessChecker() {
global $user;
$orig_user = $user;
$fake_user = (object) array(
'uid' => 42,
'mail' => 'fake@example.com',
'name' => 'fake',
);
$partials = array(
'param_1' => array(
'renderer' => new AuthcacheP13nTestEchoPartial(),
'access' => new AuthcacheP13nTestEchoFragmentAccess(),
),
'inaccessible_param' => array(
'renderer' => new AuthcacheP13nTestEchoPartial(),
'access' => new AuthcacheP13nTestEchoFragmentAccess(),
),
);
$builder = new AuthcacheP13nFragmentAssemblyBuilder($partials);
$expected = array(
'param_1' => array(
'account' => array(
'key' => 'account',
'subject' => $fake_user,
),
),
);
$user = $fake_user;
$input = array(
'a' => array(
'param_1' => array(
'account' => $fake_user,
),
'inaccessible_param' => array(
'account' => NULL,
),
),
);
$result = $builder
->build($input, array());
$this
->assertEqual($result, $expected);
$user = $orig_user;
$user = $fake_user;
$input = array(
'a' => array(
'param_1' => array(
'account' => FALSE,
),
),
);
$result = $builder
->build($input, array());
$this
->assertFalse($result);
$user = $orig_user;
}