Example #1
0
 public function testRenderView()
 {
     $blockMock = $this->getMock(\Magelight\Block::class, [], [], '', false);
     \Magelight\Block::forgeMock($blockMock);
     $this->controller->setView(\Magelight\Block::class);
     $this->controller->init();
     $blockMock->expects($this->once())->method('toHtml')->will($this->returnValue('HTML OUTPUT'));
     $this->responseMock->expects($this->once())->method('setContent')->will($this->returnSelf());
     $this->responseMock->expects($this->once())->method('send');
     $this->assertEquals($this->controller, $this->controller->renderView());
 }
Example #2
0
 /**
  * Constructor
  * 
  * @param array $routeAction
  *
  */
 public function init(array $routeAction = [])
 {
     $this->request = \Magelight\Http\Request::getInstance();
     $this->routeAction = $routeAction;
     $this->app = \Magelight\App::getInstance();
     $this->response = \Magelight\Http\Response::forge();
 }
Example #3
0
 /**
  * Sender image to response
  *
  * @param \Magelight\Http\Response $response
  */
 public function render(\Magelight\Http\Response $response)
 {
     $ts = gmdate("D, d M Y H:i:s", time() + $this->clientCacheTtl) . " GMT";
     $response->addHeader('Content-Type', $this->type);
     $response->addHeader('Expires', $ts);
     $response->addHeader('Pragma', 'cache');
     $response->addHeader('Cache-Control', 'max-age=' . $this->clientCacheTtl);
     ob_start();
     switch ($this->type) {
         case self::TYPE_GIF:
             imagegif($this->image);
             break;
         case self::TYPE_JPEG:
             imagejpeg($this->image);
             break;
         case self::TYPE_PNG:
             imagepng($this->image);
             break;
         default:
             break;
     }
     $response->setContent(ob_get_clean());
     $response->send();
 }