Elgg\UserCapabilitiesTest::testCanOverrideAnnotationPermissionsWithAHook PHP Method

testCanOverrideAnnotationPermissionsWithAHook() public method

    public function testCanOverrideAnnotationPermissionsWithAHook()
    {
        $owner = $this->mocks()->getUser();
        $entity = $this->mocks()->getObject(['owner_guid' => $owner->guid]);
        $annotation = new ElggAnnotation((object) ['owner_guid' => $owner->guid, 'entity_guid' => $entity->guid]);
        $this->assertTrue($annotation->canEdit($owner->guid));
        $this->hooks->registerHandler('permissions_check', 'annotation', function ($hook, $type, $return, $params) use($entity, $owner, $annotation) {
            $this->assertInstanceOf(ElggEntity::class, $params['entity']);
            $this->assertInstanceOf(ElggUser::class, $params['user']);
            $this->assertInstanceOf(ElggAnnotation::class, $params['annotation']);
            $this->assertEquals($entity, $params['entity']);
            $this->assertEquals($owner, $params['user']);
            $this->assertEquals($annotation, $params['annotation']);
            $this->assertTrue($return);
            return false;
        });
        $this->assertFalse($annotation->canEdit($owner->guid));
    }