public function testCanCleanUpOnFailure()
{
$service = $this->createService();
$file = new \ElggFile();
$file->owner_guid = 1;
$file->setFilename('400x300.gif');
$file->mimetype = 'image/gif';
$service->saveIconFromElggFile($this->entity, $file);
$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'));
$this->logger->disable();
// This will fail for square icons because cropping coordinates are not square
$service->saveIconFromElggFile($this->entity, $file, 'icon', ['x1' => 0, 'y1' => 0, 'x2' => 10, 'y2' => 20]);
$this->logger->enable();
$this->assertFalse($service->hasIcon($this->entity, 'master'));
$this->assertFalse($service->hasIcon($this->entity, 'large'));
$this->assertFalse($service->hasIcon($this->entity, 'medium'));
$this->assertFalse($service->hasIcon($this->entity, 'small'));
$this->assertFalse($service->hasIcon($this->entity, 'tiny'));
$this->assertFalse($service->hasIcon($this->entity, 'topbar'));
}