From 67325c52676007649f6a68d7a348bbd90043c065 Mon Sep 17 00:00:00 2001 From: s-nakajima Date: Sat, 10 Oct 2015 15:02:30 +0900 Subject: [PATCH 1/2] =?UTF-8?q?Mock=E4=BD=9C=E6=88=90=E3=83=A1=E3=82=BD?= =?UTF-8?q?=E3=83=83=E3=83=89=E8=BF=BD=E5=8A=A0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- TestSuite/NetCommonsControllerTestCase.php | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/TestSuite/NetCommonsControllerTestCase.php b/TestSuite/NetCommonsControllerTestCase.php index feaddfd1..55d5e5de 100644 --- a/TestSuite/NetCommonsControllerTestCase.php +++ b/TestSuite/NetCommonsControllerTestCase.php @@ -316,6 +316,22 @@ protected function _testActionOnValidationError($method, $data, $urlOptions, $va return $result; } +/** + * ExceptionErrorのMockセット + * + * @param string $model モデル名 + * @param string $mockModel Mockのモデル + * @param string $mockMethod Mockのメソッド + * @return void + */ + protected function _mockForReturnFalse($mockModel, $mockMethod) { + list($mockPlugin, $mockModel) = pluginSplit($mockModel); + $Mock = $this->getMockForModel($mockPlugin . '.' . $mockModel, array($mockMethod)); + $Mock->expects($this->once()) + ->method($mockMethod) + ->will($this->returnValue(false)); + } + /** * Generates a mocked controller and mocks any classes passed to `$mocks`. By * default, `_stop()` is stubbed as is sending the response headers, so to not @@ -360,6 +376,7 @@ public function generateNc($controller, $mocks = array()) { public function asserts($asserts, $result) { //チェック if (isset($asserts)) { + CakeLog::debug(print_r($asserts, true)); foreach ($asserts as $assert) { $assertMethod = $assert['method']; From 70c352861eada419b4ce5d0976ddf7a663491b4b Mon Sep 17 00:00:00 2001 From: s-nakajima Date: Sat, 10 Oct 2015 15:07:58 +0900 Subject: [PATCH 2/2] =?UTF-8?q?Mock=E4=BD=9C=E6=88=90=E3=83=A1=E3=82=BD?= =?UTF-8?q?=E3=83=83=E3=83=89=E8=BF=BD=E5=8A=A0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- TestSuite/NetCommonsControllerTestCase.php | 2 -- 1 file changed, 2 deletions(-) diff --git a/TestSuite/NetCommonsControllerTestCase.php b/TestSuite/NetCommonsControllerTestCase.php index 55d5e5de..a310af54 100644 --- a/TestSuite/NetCommonsControllerTestCase.php +++ b/TestSuite/NetCommonsControllerTestCase.php @@ -319,7 +319,6 @@ protected function _testActionOnValidationError($method, $data, $urlOptions, $va /** * ExceptionErrorのMockセット * - * @param string $model モデル名 * @param string $mockModel Mockのモデル * @param string $mockMethod Mockのメソッド * @return void @@ -376,7 +375,6 @@ public function generateNc($controller, $mocks = array()) { public function asserts($asserts, $result) { //チェック if (isset($asserts)) { - CakeLog::debug(print_r($asserts, true)); foreach ($asserts as $assert) { $assertMethod = $assert['method'];