Пример #1
0
 public function setUp()
 {
     parent::setUp();
     $this->Request = $this->getMockBuilder('Cake\\Network\\Request')->getMock();
     $this->Controller = $this->getMockBuilder('Cake\\Controller\\Controller')->setMethods(['set'])->setConstructorArgs([$this->Request, new \Cake\Network\Response(), 'CrudExamples', \Cake\Event\EventManager::instance()])->getMock();
     $this->Registry = $this->Controller->components();
     $this->Crud = $this->getMockBuilder('Crud\\Controller\\Component\\CrudComponent')->setConstructorArgs([$this->Registry])->setMethods(['foobar'])->getMock();
     $this->Controller->Crud = $this->Crud;
     $this->Controller->modelClass = 'CrudExamples';
     $this->Controller->CrudExamples = \Cake\ORM\TableRegistry::get('Crud.CrudExamples');
     $this->Controller->CrudExamples->alias('MyModel');
     $this->actionClassName = $this->getMockClass('Crud\\Action\\BaseAction', ['_handle']);
     $this->ActionClass = new $this->actionClassName($this->Controller);
     $this->_configureAction($this->ActionClass);
 }
 public function setUp()
 {
     parent::setUp();
     $this->_debug = Configure::read('debug');
 }
Пример #3
0
 /**
  * setUp
  *
  * Setup the classes the crud component needs to be testable
  */
 public function setUp()
 {
     parent::setUp();
     EventManager::instance(new TestCrudEventManager());
     $this->model = TableRegistry::get('CrudExamples');
     $this->request = $this->getMock('Cake\\Network\\Request', ['is', 'method']);
     $this->request->expects($this->any())->method('is')->will($this->returnValue(true));
     $response = new Response();
     $this->controller = $this->getMock('Crud\\TestCase\\Controller\\Crud\\CrudExamplesController', ['header', 'redirect', 'render', '_stop'], [$this->request, $response, 'CrudExamples', EventManager::instance()]);
     $this->controller->methods = [];
     $this->Registry = $this->controller->components();
     $config = ['actions' => ['Crud.Index', 'Crud.Add', 'Crud.Edit', 'Crud.View', 'Crud.Delete']];
     $this->Crud = new TestCrudComponent($this->Registry, $config);
     $this->Crud->beforeFilter(new Event('Controller.beforeFilter'));
     $this->controller->Crud = $this->Crud;
 }