public function testGetResponseForJpeg() { $qrCode = $this->getQrMock(); $qrCode->expects($this->any())->method('get')->will($this->returnValue("hello")); $wrapper = new QrWrapper($qrCode); $wrapper->setImageType('jpeg'); $response = $wrapper->getResponse(); $this->assertInstanceOf('Symfony\\Component\\HttpFoundation\\Response', $response); $this->assertEquals("hello", $response->getContent()); $this->assertEquals("image/jpeg", $response->headers->get('Content-Type')); }
public function register(Application $app) { $app['qrCode'] = $app->protect(function ($text, $size = null) use($app) { $default = $app['qr.defaults']; $qr = new QrWrapper(new QrCode()); $qr->setText($text); $qr->setPadding($default['padding']); $qr->setSize(is_null($size) ? $default['size'] : $size); $qr->setImageType($default['imageType']); return $qr; }); }