public function setUp() { if (!extension_loaded('mongo')) { $this->markTestSkipped('The mongo extension is not available.'); return; } $this->image = new RightImage(__DIR__ . '/../../../Image/img/test.jpg'); $mongoCollection = $this->getMockBuilder('MongoCollection')->disableOriginalConstructor()->getMock(); $mongoCollection->expects($this->any())->method('save')->will($this->returnValue(true)); $mongoCollection->expects($this->any())->method('remove')->will($this->returnValue(true)); $mongoCollection->expects($this->any())->method('update')->will($this->returnValue(true)); $mongoCollection->expects($this->any())->method('findOne')->will($this->returnValue(['id' => 'fdsfdsfsdf', 'blob' => new \MongoBinData($this->image->getBlob(), \MongoBinData::CUSTOM)])); $this->adapter = new MongoAdapter(); /** @var $mongoCollection \MongoCollection */ $this->adapter->setMongoCollection($mongoCollection); }
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])); }