Ejemplo n.º 1
0
 public function testHelperFitOut()
 {
     $mockAdapter = $this->getMock('ImgMan\\Core\\Adapter\\ImagickAdapter');
     $image = new RightImage(__DIR__ . '/../../Image/img/test.jpg');
     $mockBlob = new Blob();
     $mockBlob->setBlob($image->getBlob());
     $mockAdapter->expects($this->any())->method('resize')->will($this->returnValue(true));
     $mockAdapter->expects($this->any())->method('getRatio')->will($this->returnValue(5));
     $mockAdapter->expects($this->any())->method('getHeight')->will($this->returnValue(30));
     $mockAdapter->expects($this->any())->method('getWidth')->will($this->returnValue(30));
     $mockAdapter->expects($this->any())->method('compose')->will($this->returnValue(true));
     $mockAdapter->expects($this->any())->method('create')->will($this->returnValue($mockBlob));
     $helper = new FitOut();
     $helper->setAdapter($mockAdapter);
     $this->assertTrue($helper->execute(['width' => 50, 'height' => 50]));
     $this->assertTrue($helper->execute(['width' => 100, 'height' => 50]));
 }
Ejemplo n.º 2
0
 /**
  * @param $width
  * @param $height
  * @param null $backgroundColor
  * @param null $format
  * @return Blob
  */
 public function create($width, $height, $format, $backgroundColor = null)
 {
     $adapter = new Imagick();
     $adapter->newimage($width, $height, $this->getImagePixel($backgroundColor), $format);
     $wrapper = new Blob();
     return $wrapper->setBlob($adapter->getimageblob());
 }