From c6e50a007daf18e1cb6ef6f42dd18cfdc1c6f319 Mon Sep 17 00:00:00 2001 From: s-nakajima Date: Tue, 6 Sep 2016 07:57:11 +0900 Subject: [PATCH] =?UTF-8?q?Unit=E3=83=86=E3=82=B9=E3=83=88=E7=94=A8?= =?UTF-8?q?=E3=81=AE=E5=85=B1=E9=80=9A=E3=83=A1=E3=82=BD=E3=83=83=E3=83=89?= =?UTF-8?q?=5FmockForReturn()=E3=81=AE=E4=BF=AE=E6=AD=A3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- TestSuite/NetCommonsControllerTestCase.php | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/TestSuite/NetCommonsControllerTestCase.php b/TestSuite/NetCommonsControllerTestCase.php index 1029cb52..cfc177bc 100644 --- a/TestSuite/NetCommonsControllerTestCase.php +++ b/TestSuite/NetCommonsControllerTestCase.php @@ -214,7 +214,7 @@ protected function _testActionOnValidationError($method, $data, $urlOptions, $va * * @param string $mockModel Mockのモデル * @param string $mockMethod Mockのメソッド - * @param int $count Mockの呼び出し回数 + * @param int|string $count Mockの呼び出し回数 * @return void */ protected function _mockForReturnFalse($mockModel, $mockMethod, $count = 1) { @@ -226,7 +226,7 @@ protected function _mockForReturnFalse($mockModel, $mockMethod, $count = 1) { * * @param string $mockModel Mockのモデル * @param string $mockMethod Mockのメソッド - * @param int $count Mockの呼び出し回数 + * @param int|string $count Mockの呼び出し回数 * @return void */ protected function _mockForReturnTrue($mockModel, $mockMethod, $count = 1) { @@ -239,7 +239,7 @@ protected function _mockForReturnTrue($mockModel, $mockMethod, $count = 1) { * @param string $mockModel Mockのモデル * @param string $mockMethod Mockのメソッド * @param bool $return 戻り値 - * @param int $count Mockの呼び出し回数 + * @param int|string $count Mockの呼び出し回数 * @return void */ protected function _mockForReturn($mockModel, $mockMethod, $return, $count = 1) { @@ -247,10 +247,14 @@ protected function _mockForReturn($mockModel, $mockMethod, $return, $count = 1) if (substr(get_class($this->controller->$mockModel), 0, strlen('Mock_')) !== 'Mock_') { $this->controller->$mockModel = $this->getMockForModel( - $mockPlugin . '.' . $mockModel, array($mockMethod) + $mockPlugin . '.' . $mockModel, + array($mockMethod), + array('plugin' => Inflector::underscore($mockPlugin)) ); } - if ($count === 1) { + if ($count === 'any') { + $funcCount = $this->any(); + } elseif ($count === 1) { $funcCount = $this->once(); } else { $funcCount = $this->exactly($count);