Beispiel #1
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()));
 }
Beispiel #2
0
 /**
  * @expectedException \InvalidArgumentException
  */
 public function testProcessBehaviorDisableAction()
 {
     ////////////////////////////////////////////////////////////////////////////////////////////////////////////////
     //  Invalid action to perform.
     $Request = new Request(['params' => $this->dataParam, 'post' => ['Pages' => [1 => ['id' => 1]], 'action' => 'pages.disabled']]);
     $Controller = new PagesController($Request);
     $Controller->process();
 }
Beispiel #3
0
 /**
  * Test invalid data for toggle field.
  *
  * @expectedException \Cake\Network\Exception\BadRequestException
  * @return void
  */
 public function testFieldToggleBadRequest()
 {
     $request = new Request(['params' => ['plugin' => 'TestPlugin', 'controller' => 'Pages', 'action' => 'toggle', 'pass' => []], 'environment' => ['HTTP_X_REQUESTED_WITH' => 'XMLHttpRequest']]);
     $controller = new PagesController($request);
     $controller->toggle('', '');
 }