/**
  * testLoadModel method from a plugin controller
  *
  * @return void
  */
 public function testLoadModelInPlugins()
 {
     App::build(array('Plugin' => array(CAKE . 'Test' . DS . 'test_app' . DS . 'Plugin' . DS), 'Controller' => array(CAKE . 'Test' . DS . 'test_app' . DS . 'Controller' . DS), 'Model' => array(CAKE . 'Test' . DS . 'test_app' . DS . 'Model' . DS)));
     CakePlugin::load('TestPlugin');
     App::uses('TestPluginAppController', 'TestPlugin.Controller');
     App::uses('TestPluginController', 'TestPlugin.Controller');
     $Controller = new TestPluginController();
     $Controller->plugin = 'TestPlugin';
     $Controller->uses = false;
     $this->assertFalse(isset($Controller->Comment));
     $result = $Controller->loadModel('Comment');
     $this->assertTrue($result);
     $this->assertInstanceOf('Comment', $Controller->Comment);
     $this->assertTrue(in_array('Comment', $Controller->uses));
     ClassRegistry::flush();
     unset($Controller);
 }
示例#2
0
 /**
  * testLoadModel method from a plugin controller
  *
  * @access public
  * @return void
  */
 function testLoadModelInPlugins()
 {
     App::build(array('plugins' => array(TEST_CAKE_CORE_INCLUDE_PATH . 'tests' . DS . 'test_app' . DS . 'plugins' . DS), 'controllers' => array(TEST_CAKE_CORE_INCLUDE_PATH . 'tests' . DS . 'test_app' . DS . 'controllers' . DS), 'models' => array(TEST_CAKE_CORE_INCLUDE_PATH . 'tests' . DS . 'test_app' . DS . 'models' . DS)));
     App::import('Controller', 'TestPlugin.TestPlugin');
     $Controller = new TestPluginController();
     $Controller->plugin = 'TestPlugin';
     $Controller->uses = false;
     $this->assertFalse(isset($Controller->Comment));
     $result = $Controller->loadModel('Comment');
     $this->assertTrue($result);
     $this->assertInstanceOf('Comment', $Controller->Comment);
     $this->assertTrue(in_array('Comment', $Controller->modelNames));
     ClassRegistry::flush();
     unset($Controller);
 }