public function testCanDeleteIconsWithAHookHandler()
{
$file = new \ElggFile();
$file->owner_guid = 1;
$file->setFilename('600x300.jpg');
$this->hooks->registerHandler('entity:icon:delete', 'object', function ($hook, $type, $return, $params) {
if ($return === false) {
return;
}
// make sure we passed in documented params
if (!$params['entity'] instanceof \ElggEntity) {
return;
}
return false;
});
$this->assertTrue($this->hooks->hasHandler('entity:icon:delete', 'object'));
$service = $this->createService();
$service->saveIconFromElggFile($this->entity, $file);
// original file should stay where it is
$this->assertTrue($file->exists());
// hook returned false without deleting icons
$this->assertTrue($service->hasIcon($this->entity, 'master'));
$this->assertTrue($service->hasIcon($this->entity, 'large'));
$this->assertTrue($service->hasIcon($this->entity, 'medium'));
$this->assertTrue($service->hasIcon($this->entity, 'small'));
$this->assertTrue($service->hasIcon($this->entity, 'tiny'));
$this->assertTrue($service->hasIcon($this->entity, 'topbar'));
}