Example #1
0
 /**
  * @expectedException \Cake\View\Exception\MissingTemplateException
  */
 public function testMissingViewFile()
 {
     $request = new Request(['params' => ['plugin' => 'TestPlugin', 'controller' => 'Display', 'action' => 'add', 'pass' => []]]);
     $controller = new DisplayController($request);
     $view = $controller->createView('Union\\Core\\View\\AppView');
     $view->render('View/no/exists');
 }
Example #2
0
 /**
  * Test controller hooks.
  *
  * @return void
  */
 public function testControllerHooks()
 {
     Hook::helper('TestPlugin.Entity', '*');
     Hook::helper('TestPlugin.Good', 'Pages');
     Hook::helper('TestPlugin.String', ['Display']);
     Hook::helper('TestPlugin.Simple', ['Common', 'Pages']);
     Hook::component('TestPlugin.Good', '*');
     Hook::component('TestPlugin.Image', 'Pages');
     Hook::component('TestPlugin.Resize', ['Display']);
     Hook::component('TestPlugin.Simple', ['Common', 'Pages']);
     ////////////////////////////////////////////////////////////////////////////////////////////////////////////////
     //  Pages controller hooks.
     $request = new Request(['params' => ['plugin' => 'TestPlugin', 'controller' => 'Pages', 'action' => 'index', 'pass' => []]]);
     $controller = new PagesController($request);
     $view = $controller->createView('Union\\Core\\View\\AjaxView');
     $components = $controller->components();
     $helpers = $view->helpers();
     /** Test hook helpers */
     $this->assertTrue(in_array('Entity', $helpers->loaded()));
     $this->assertTrue(in_array('Simple', $helpers->loaded()));
     $this->assertNotTrue(in_array('String', $helpers->loaded()));
     $this->assertInstanceOf('Union\\Core\\View\\Helper\\UrlHelper', $helpers->get('Url'));
     $this->assertInstanceOf('Union\\Core\\View\\Helper\\HtmlHelper', $helpers->get('Html'));
     /** Test hook components */
     $this->assertTrue(in_array('Csrf', $components->loaded()));
     $this->assertTrue(in_array('Flash', $components->loaded()));
     $this->assertTrue(in_array('Cookie', $components->loaded()));
     $this->assertTrue(in_array('Security', $components->loaded()));
     $this->assertTrue(in_array('Paginator', $components->loaded()));
     $this->assertTrue(in_array('RequestHandler', $components->loaded()));
     $this->assertTrue(in_array('Good', $components->loaded()));
     $this->assertTrue(in_array('Simple', $components->loaded()));
     $this->assertNotTrue(in_array('String', $components->loaded()));
     ////////////////////////////////////////////////////////////////////////////////////////////////////////////////
     //  Display controller hooks.
     $request = new Request(['params' => ['plugin' => 'TestPlugin', 'controller' => 'Display', 'action' => 'index', 'pass' => []]]);
     $controller = new DisplayController($request);
     $view = $controller->createView('Union\\Core\\View\\AjaxView');
     $components = $controller->components();
     $helpers = $view->helpers();
     /** Test hook helpers */
     $this->assertTrue(in_array('Url', $helpers->loaded()));
     $this->assertTrue(in_array('Html', $helpers->loaded()));
     $this->assertTrue(in_array('String', $helpers->loaded()));
     $this->assertNotTrue(in_array('Good', $helpers->loaded()));
     $this->assertNotTrue(in_array('Simple', $helpers->loaded()));
     /** Test hook components */
     $this->assertTrue(in_array('Good', $components->loaded()));
     $this->assertTrue(in_array('Resize', $components->loaded()));
     $this->assertNotTrue(in_array('Image', $components->loaded()));
     $this->assertNotTrue(in_array('Simple', $components->loaded()));
     ////////////////////////////////////////////////////////////////////////////////////////////////////////////////
     //  Common controller hooks.
     $request = new Request(['params' => ['plugin' => 'TestPlugin', 'controller' => 'Common', 'action' => 'index', 'pass' => []]]);
     $controller = new CommonController($request);
     $view = $controller->createView('Union\\Core\\View\\AjaxView');
     $components = $controller->components();
     $helpers = $view->helpers();
     /** Test hook helpers */
     $this->assertTrue(in_array('Url', $helpers->loaded()));
     $this->assertTrue(in_array('Html', $helpers->loaded()));
     $this->assertTrue(in_array('Simple', $helpers->loaded()));
     $this->assertNotTrue(in_array('Good', $helpers->loaded()));
     $this->assertNotTrue(in_array('String', $helpers->loaded()));
     /** Test hook components */
     $this->assertTrue(in_array('Good', $components->loaded()));
     $this->assertTrue(in_array('Simple', $components->loaded()));
     $this->assertNotTrue(in_array('Image', $components->loaded()));
     $this->assertNotTrue(in_array('Resize', $components->loaded()));
 }