assertEquals($permDesc, $permDesc2); $this->assertNotEquals($permDesc, $permDesc3); } public function testFromStandalonePermission() { // Create a stub for global function t() $t = $this->getFunctionMock('Zotlabs\Lib', 't'); $t->expects($this->atLeastOnce())->willReturnCallback( function ($string) { return $string; } ); // Create a mock for global function logger() $this->getFunctionMock('Zotlabs\Lib', 'logger'); $permDescUnknown = PermissionDescription::fromStandalonePermission(-1); $permDescSelf = PermissionDescription::fromStandalonePermission(0); $this->assertNull($permDescUnknown); $this->assertNotNull($permDescSelf); } public function testFromGlobalPermission() { //$permDesc = PermissionDescription::fromGlobalPermission('view_profile'); $this->markTestIncomplete( 'The method fromGlobalPermission() is not yet testable ...' ); } public function testGetPermissionDescription() { // Create a stub for global function t() $t = $this->getFunctionMock('Zotlabs\Lib', 't'); $t->expects($this->atLeastOnce())->willReturnCallback( function ($string) { return $string; } ); // Create a mock for global function logger() $this->getFunctionMock('Zotlabs\Lib', 'logger'); // Create a stub for the PermissionDescription class $stub = $this->createMock(PermissionDescription::class); $stub->method('get_permission_description') ->will($this->returnArgument(0)); $permDescSelf = PermissionDescription::fromStandalonePermission(0); $this->assertInstanceOf(PermissionDescription::class, $permDescSelf); $this->assertEquals($permDescSelf->get_permission_description(), 'Only me'); $permDescPublic = PermissionDescription::fromStandalonePermission(PERMS_PUBLIC); $this->assertEquals($permDescPublic->get_permission_description(), 'Public'); } }