Skip to content

Commit

Permalink
fix(tests): testAccessCaching now makes more sense
Browse files Browse the repository at this point in the history
  • Loading branch information
jdalsem committed Aug 19, 2020
1 parent 0f70ce2 commit 466ce22
Showing 1 changed file with 22 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -177,24 +177,39 @@ public function testCanEditACLHook() {
}

public function testAccessCaching() {
// @todo what is being tested here, makes no sense currently
// create a new user to check against
$access_cache = _elgg_services()->accessCache;

$user = $this->createOne('user');

$hash = $user->guid . 'get_access_array';

$this->assertEmpty($access_cache[$hash]);

$id = create_access_collection('custom', $user->guid);

_elgg_services()->accessCache->clear();

$expected = [
ACCESS_PUBLIC,
ACCESS_LOGGED_IN,
$id,
];

$actual = get_access_array($user->getGUID());

$this->assertEquals($expected, $actual);
$this->assertEquals($expected, get_access_array($user->guid));

// check if exists in cache
$this->assertEquals($expected, $access_cache[$hash]);

$manipulated_access = $expected;
$manipulated_access[] = 'foo';
$access_cache[$hash] = $manipulated_access;
$this->assertEquals($manipulated_access, $access_cache[$hash]);

$this->assertEquals($manipulated_access, get_access_array($user->guid));

// check flush logic
$flushed_access = _elgg_services()->accessCollections->getAccessArray($user->guid, true);
$this->assertNotEquals($manipulated_access, $flushed_access);
$this->assertEquals($expected, $flushed_access);

$user->delete();
}

Expand Down

0 comments on commit 466ce22

Please sign in to comment.