public function testCanGetTheImageExtension() { $this->assertNull($this->url->getExtension(), 'extension should initialy be null'); $this->url->jpg(); $this->assertSame('jpg', $this->url->getExtension(), 'Could not fetch extension after setting it to jpg'); $this->url->png(); $this->assertSame('png', $this->url->getExtension(), 'Could not fetch extension after setting it to png'); $this->url->gif(); $this->assertSame('gif', $this->url->getExtension(), 'Could not fetch extension after setting it to gif'); }
/** * Generate a short URL * * @param Http\ImageUrl $imageUrl An instance of an imageUrl * @return Model */ public function generateShortUrl(Http\ImageUrl $imageUrl) { $transformations = $imageUrl->getTransformations(); if ($transformations) { $transformations = '?t[]=' . implode('&t[]=', $transformations); } else { $transformations = null; } $params = array('user' => $this->getUser(), 'imageIdentifier' => $imageUrl->getImageIdentifier(), 'extension' => $imageUrl->getExtension(), 'query' => $transformations); return $this->getCommand('GenerateShortUrl', array('user' => $this->getUser(), 'imageIdentifier' => $imageUrl->getImageIdentifier(), 'params' => json_encode($params)))->execute(); }