/** * @group IconService */ 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')); }
public function setUp() { if (!isset($this->test_object_class)) { throw new Exception(get_class($this) . ' must set \\$object_test_class before calling ' . __METHOD__); } $this->setupMockServices(); $this->events = _elgg_services()->events; $this->events->backup(); $this->hooks = _elgg_services()->hooks; $this->hooks->backup(); $this->queue = new DatabaseQueueMock(); $this->entities = _elgg_services()->entityTable; $this->time = $this->entities->getCurrentTime()->getTimestamp(); $this->subscriptions = new SubscriptionsService(_elgg_services()->db); $this->session = _elgg_services()->session; $this->logger = _elgg_services()->logger; $this->logger->disable(); $this->translator = _elgg_services()->translator; $this->setupServices(); $this->actor = $this->mocks()->getUser(); }