|
|
@@ -63,7 +63,7 @@ class ScaffoldMockControllerWithFields extends Controller {
|
|
|
/**
|
|
|
* function beforeScaffold
|
|
|
*
|
|
|
- * @param string method
|
|
|
+ * @param string $method Method name.
|
|
|
* @return bool true
|
|
|
*/
|
|
|
public function beforeScaffold($method) {
|
|
|
@@ -74,6 +74,39 @@ class ScaffoldMockControllerWithFields extends Controller {
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
+ * ScaffoldMockControllerWithError class
|
|
|
+ *
|
|
|
+ * @package Cake.Test.Case.Controller
|
|
|
+ */
|
|
|
+class ScaffoldMockControllerWithError extends Controller {
|
|
|
+
|
|
|
+/**
|
|
|
+ * name property
|
|
|
+ *
|
|
|
+ * @var string
|
|
|
+ */
|
|
|
+ public $name = 'ScaffoldMock';
|
|
|
+
|
|
|
+/**
|
|
|
+ * scaffold property
|
|
|
+ *
|
|
|
+ * @var mixed
|
|
|
+ */
|
|
|
+ public $scaffold;
|
|
|
+
|
|
|
+/**
|
|
|
+ * function beforeScaffold
|
|
|
+ *
|
|
|
+ * @param string $method Method name.
|
|
|
+ * @return bool false
|
|
|
+ */
|
|
|
+ public function beforeScaffold($method) {
|
|
|
+ return false;
|
|
|
+ }
|
|
|
+
|
|
|
+}
|
|
|
+
|
|
|
+/**
|
|
|
* TestScaffoldMock class
|
|
|
*
|
|
|
* @package Cake.Test.Case.Controller
|
|
|
@@ -83,7 +116,7 @@ class TestScaffoldMock extends Scaffold {
|
|
|
/**
|
|
|
* Overload _scaffold
|
|
|
*
|
|
|
- * @param CakeRequest $request
|
|
|
+ * @param CakeRequest $request Request object for scaffolding
|
|
|
* @return void
|
|
|
*/
|
|
|
protected function _scaffold(CakeRequest $request) {
|
|
|
@@ -344,4 +377,40 @@ class ScaffoldTest extends CakeTestCase {
|
|
|
$this->assertNotRegExp('/textarea name="data\[ScaffoldMock\]\[body\]" cols="30" rows="6" id="ScaffoldMockBody"/', $result);
|
|
|
}
|
|
|
|
|
|
+/**
|
|
|
+ * 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);
|
|
|
+ }
|
|
|
}
|