예제 #1
0
 /**
  * test that the proper names and variable values are set by Scaffold
  *
  * @return void
  **/
 function testEditScaffoldWithScaffoldFields()
 {
     $this->Controller = new ScaffoldMockControllerWithFields();
     $this->Controller->action = 'edit';
     $this->Controller->here = '/scaffold_mock';
     $this->Controller->webroot = '/';
     $params = array('plugin' => null, 'pass' => array(1), 'form' => array(), 'named' => array(), 'url' => array('url' => 'scaffold_mock'), 'controller' => 'scaffold_mock', 'action' => 'edit');
     //set router.
     Router::reload();
     Router::setRequestInfo(array($params, array('base' => '/', 'here' => '/scaffold_mock', 'webroot' => '/')));
     $this->Controller->params = $params;
     $this->Controller->controller = 'scaffold_mock';
     $this->Controller->base = '/';
     $this->Controller->constructClasses();
     ob_start();
     new Scaffold($this->Controller, $params);
     $result = ob_get_clean();
     $this->assertNoPattern('/textarea name="data\\[ScaffoldMock\\]\\[body\\]" cols="30" rows="6" id="ScaffoldMockBody"/', $result);
 }
예제 #2
0
 /**
  * test that the proper names and variable values are set by Scaffold
  *
  * @return void
  */
 public function testEditScaffoldWithScaffoldFields()
 {
     $request = new CakeRequest(null, false);
     $this->Controller = new ScaffoldMockControllerWithFields($request);
     $this->Controller->response = $this->getMock('CakeResponse', array('_sendHeader'));
     $params = array('plugin' => null, 'pass' => array(1), 'form' => array(), 'named' => array(), 'url' => array('url' => 'scaffold_mock/edit'), 'controller' => 'scaffold_mock', 'action' => 'edit');
     $this->Controller->request->base = '';
     $this->Controller->request->webroot = '/';
     $this->Controller->request->here = '/scaffold_mock/edit';
     $this->Controller->request->addParams($params);
     //set router.
     Router::reload();
     Router::setRequestInfo($this->Controller->request);
     $this->Controller->constructClasses();
     ob_start();
     new Scaffold($this->Controller, $this->Controller->request);
     $this->Controller->response->send();
     $result = ob_get_clean();
     $this->assertNotRegExp('/textarea name="data\\[ScaffoldMock\\]\\[body\\]" cols="30" rows="6" id="ScaffoldMockBody"/', $result);
 }
예제 #3
0
 /**
  * test that the proper names and variable values are set by Scaffold
  *
  * @return void
  **/
 function testScaffoldVariableSetting()
 {
     $this->Controller->action = 'admin_edit';
     $this->Controller->here = '/admin/scaffold_mock/edit';
     $this->Controller->webroot = '/';
     $params = array('plugin' => null, 'pass' => array(), 'form' => array(), 'named' => array(), 'url' => array('url' => 'admin/scaffold_mock/edit'), 'controller' => 'scaffold_mock', 'action' => 'admin_edit', 'admin' => true);
     //set router.
     Router::setRequestInfo(array($params, array('base' => '/', 'here' => 'admin/scaffold_mock', 'webroot' => '/')));
     $this->Controller->params = $params;
     $this->Controller->controller = 'scaffold_mock';
     $this->Controller->base = '/';
     $this->Controller->constructClasses();
     $Scaffold =& new TestScaffoldMock($this->Controller, $params);
     $result = $this->Controller->viewVars;
     $this->assertEqual($result['singularHumanName'], 'Scaffold Mock');
     $this->assertEqual($result['pluralHumanName'], 'Scaffold Mock');
     $this->assertEqual($result['modelClass'], 'ScaffoldMock');
     $this->assertEqual($result['primaryKey'], 'id');
     $this->assertEqual($result['displayField'], 'title');
     $this->assertEqual($result['singularVar'], 'scaffoldMock');
     $this->assertEqual($result['pluralVar'], 'scaffoldMock');
     $this->assertEqual($result['scaffoldFields'], array('id', 'user_id', 'title', 'body', 'published', 'created', 'updated'));
 }
예제 #4
0
 /**
  * Test the correct Generation of Scaffold Params.
  * This ensures that the correct action and view will be generated
  *
  * @access public
  * @return void
  */
 function testScaffoldParams()
 {
     $this->Controller->action = 'admin_edit';
     $this->Controller->here = '/admin/scaffold_mock/edit';
     $this->Controller->webroot = '/';
     $params = array('plugin' => null, 'pass' => array(), 'form' => array(), 'named' => array(), 'url' => array('url' => 'admin/scaffold_mock/edit'), 'controller' => 'scaffold_mock', 'action' => 'admin_edit', 'admin' => true);
     //set router.
     Router::setRequestInfo(array($params, array('base' => '/', 'here' => 'admin/scaffold_mock', 'webroot' => '/')));
     $this->Controller->params = $params;
     $this->Controller->controller = 'scaffold_mock';
     $this->Controller->base = '/';
     $this->Controller->constructClasses();
     $Scaffold =& new TestScaffoldMock($this->Controller, $params);
     $result = $Scaffold->getParams();
     $this->assertEqual($result['action'], 'admin_edit');
 }
 /**
  * test in case of scaffold error
  *
  * @return void
  */
 public function testScaffoldError()
 {
     $request = new CakeRequest(null, false);
     $this->Controller = new ScaffoldMockControllerWithError($request);
     $this->Controller->response = $this->getMock('CakeResponse', array('_sendHeader'));
     $params = array('plugin' => null, 'pass' => array(1), 'form' => array(), 'named' => array(), 'url' => array('url' => 'scaffold_mock/edit'), 'controller' => 'scaffold_mock', 'action' => 'edit');
     $this->Controller->request->base = '';
     $this->Controller->request->webroot = '/';
     $this->Controller->request->here = '/scaffold_mock/edit';
     $this->Controller->request->addParams($params);
     //set router.
     Router::reload();
     Router::setRequestInfo($this->Controller->request);
     $this->Controller->constructClasses();
     ob_start();
     new Scaffold($this->Controller, $this->Controller->request);
     $this->Controller->response->send();
     $result = ob_get_clean();
     $this->assertRegExp('/Scaffold Error/', $result);
 }