/**
  * test that the BC wrapper doesn't interfere with models and components.
  *
  * @return void
  */
 public function testPropertyCompatibilityAndModelsComponents()
 {
     $request = new CakeRequest('controller_posts/index');
     $Controller = new TestController($request);
     $Controller->constructClasses();
     $this->assertInstanceOf('SecurityComponent', $Controller->Security);
     $this->assertInstanceOf('ControllerComment', $Controller->ControllerComment);
 }
Esempio n. 2
0
 /**
  * testRender method
  *
  * @access public
  * @return void
  */
 function testRender()
 {
     Configure::write('viewPaths', array(TEST_CAKE_CORE_INCLUDE_PATH . 'tests' . DS . 'test_app' . DS . 'views' . DS, TEST_CAKE_CORE_INCLUDE_PATH . 'libs' . DS . 'view' . DS));
     $Controller =& new Controller();
     $Controller->viewPath = 'posts';
     $result = $Controller->render('index');
     $this->assertPattern('/posts index/', $result);
     $result = $Controller->render('/elements/test_element');
     $this->assertPattern('/this is the test element/', $result);
     $Controller = new TestController();
     $Controller->constructClasses();
     $Controller->ControllerComment->validationErrors = array('title' => 'tooShort');
     $expected = $Controller->ControllerComment->validationErrors;
     ClassRegistry::flush();
     $Controller->viewPath = 'posts';
     $result = $Controller->render('index');
     $View = ClassRegistry::getObject('view');
     $this->assertTrue(isset($View->validationErrors['ControllerComment']));
     $this->assertEqual($expected, $View->validationErrors['ControllerComment']);
     $Controller->ControllerComment->validationErrors = array();
     ClassRegistry::flush();
 }
Esempio n. 3
0
 /**
  * testValidateErrors method
  *
  * @access public
  * @return void
  */
 function testValidateErrors()
 {
     $TestController = new TestController();
     $TestController->constructClasses();
     $this->assertFalse($TestController->validateErrors());
     $this->assertEqual($TestController->validate(), 0);
     $TestController->ControllerComment->invalidate('some_field', 'error_message');
     $TestController->ControllerComment->invalidate('some_field2', 'error_message2');
     $comment = new ControllerComment();
     $comment->set('someVar', 'data');
     $result = $TestController->validateErrors($comment);
     $expected = array('some_field' => 'error_message', 'some_field2' => 'error_message2');
     $this->assertIdentical($result, $expected);
     $this->assertEqual($TestController->validate($comment), 2);
 }