/** * @covers MemePuush\Image::__construct * @expectedException \Exception */ public function testInvalidImage() { $image = $this->getMock('Imagick', array('getImageGeometry', 'getImageSignature')); $image->expects($this->any())->method('getImageGeometry')->will($this->throwException(new \Exception())); $object = new Image('not a real url'); $object->setImage($image); $object->setBottomCaption('test'); $object->setTopCaption('test'); $object->output(); }
throw new \Exception('Puu.sh api key must be provided'); } if (!$t1 && !$t2) { throw new \Exception('No caption provided'); } if (!$img) { throw new \Exception('No image url provided'); } $image = new Image($img); //if the image doesn't exist, cannot continue //if( !$image ) // throw new \Exception( 'Could not load image: ' . $img ); $image->setOutputFormat($output, $apiKey); $image->setTopCaption($t1); $image->setBottomCaption($t2); $outputContent = $image->output(); switch ($output) { case 'screen': header('Content-type: image/jpg'); echo file_get_contents($outputContent); break; case 'file': echo $outputContent; break; case 'puush': echo json_encode(array('url' => $outputContent)); break; } } catch (\Exception $e) { echo 'Error: ' . $e->getMessage(); }