From 5e1addc75e73e84254e820fc67dba057a8728db6 Mon Sep 17 00:00:00 2001 From: Mario Date: Thu, 26 Nov 2020 11:14:40 +0000 Subject: revert folder renaming --- tests/unit/Access/PermissionRolesTest.php | 101 ++++++++++++++++++++++++++++++ 1 file changed, 101 insertions(+) create mode 100644 tests/unit/Access/PermissionRolesTest.php (limited to 'tests/unit/Access/PermissionRolesTest.php') diff --git a/tests/unit/Access/PermissionRolesTest.php b/tests/unit/Access/PermissionRolesTest.php new file mode 100644 index 000000000..58fd88bb1 --- /dev/null +++ b/tests/unit/Access/PermissionRolesTest.php @@ -0,0 +1,101 @@ +assertEquals($expectedVersion, PermissionRoles::version()); + + $pr = new PermissionRoles(); + $this->assertEquals($expectedVersion, $pr->version()); + } + + + public function testRoles() { + // Create a stub for global function t() with expectation + $t = $this->getFunctionMock('Zotlabs\Access', 't'); + $t->expects($this->atLeastOnce())->willReturnCallback( + function ($string) { + return $string; + } + ); + + $roles = PermissionRoles::roles(); + $r = new PermissionRoles(); + $this->assertEquals($roles, $r->roles()); + + $socialNetworking = [ + 'social_federation' => 'Social - Federation', + 'social' => 'Social - Mostly Public', + 'social_restricted' => 'Social - Restricted', + 'social_private' => 'Social - Private' + ]; + + $this->assertArraySubset(['Social Networking' => $socialNetworking], $roles); + $this->assertEquals($socialNetworking, $roles['Social Networking']); + + $this->assertCount(5, $roles, 'There should be 5 permission groups.'); + + $this->assertCount(1, $roles['Other'], "In the 'Other' group should be just one permission role"); + } + + + /** + * @uses ::call_hooks + * @uses Zotlabs\Access\PermissionLimits::Std_Limits + * @uses Zotlabs\Access\Permissions::Perms + */ + public function testRole_perms() { + // Create a stub for global function t() + $t = $this->getFunctionMock('Zotlabs\Access', 't'); + $t = $this->getFunctionMock('Zotlabs\Access', 'get_config'); + + $rp_social = PermissionRoles::role_perms('social'); + $this->assertEquals('social', $rp_social['role']); + + + $rp_custom = PermissionRoles::role_perms('custom'); + $this->assertEquals(['role' => 'custom'], $rp_custom); + + $rp_nonexistent = PermissionRoles::role_perms('nonexistent'); + $this->assertEquals(['role' => 'nonexistent'], $rp_nonexistent); + } + +} -- cgit v1.2.3