Elgg\EntityIconServiceTest::testCanReplaceIconFile PHP Метод

testCanReplaceIconFile() публичный Метод

    public function testCanReplaceIconFile()
    {
        $callback = function ($hook, $type, $icon, $params) {
            $size = elgg_extract('size', $params);
            $type = elgg_extract('type', $params);
            $entity = elgg_extract('entity', $params);
            if ($entity->getSubtype() == 'foo') {
                $icon->owner_guid = $entity->owner_guid;
                $icon->setFilename("foo/bar/{$type}/{$size}.jpg");
            }
            return $icon;
        };
        $this->hooks->registerHandler('entity:icon:file', 'object', $callback);
        $this->hooks->registerHandler('entity:cover:file', 'object', $callback);
        $service = $this->createService();
        $icon = $service->getIcon($this->entity, 'small');
        $this->assertEquals($this->owner_dir_path . 'foo/bar/icon/small.jpg', $icon->getFilenameOnFilestore());
        $cover = $service->getIcon($this->entity, 'large', 'cover');
        $this->assertEquals($this->owner_dir_path . 'foo/bar/cover/large.jpg', $cover->getFilenameOnFilestore());
    }