public function testReusingResponse()
 {
     $qrCode = $this->getMockBuilder('Endroid\\QrCode\\QrCode')->disableOriginalConstructor()->getMock();
     $qrCode->expects($this->any())->method('get')->will($this->returnValue("hello"));
     $wrapper = new QrWrapper($qrCode);
     $response = new Response('foo');
     $response->headers->set('xxx', 'gonzalo');
     $response = $wrapper->getResponse($response);
     $this->assertEquals("hello", $response->getContent());
     $this->assertEquals("image/png", $response->headers->get('Content-Type'));
     $this->assertEquals("gonzalo", $response->headers->get('xxx'));
 }
 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;
     });
 }