From 157cce4b5efd78fdfd586979fb258a60be59da4d Mon Sep 17 00:00:00 2001 From: ivan Date: Tue, 30 Aug 2016 16:13:31 -0300 Subject: [PATCH] Ivan - Backend - Fix captcha test --- server/tests/__lib__/Mock.php | 2 +- server/tests/__mocks__/ReCaptchaMock.php | 7 ++++--- server/tests/libs/validations/captchaTest.php | 2 +- 3 files changed, 6 insertions(+), 5 deletions(-) diff --git a/server/tests/__lib__/Mock.php b/server/tests/__lib__/Mock.php index 343274c5..f15e86c0 100644 --- a/server/tests/__lib__/Mock.php +++ b/server/tests/__lib__/Mock.php @@ -87,7 +87,7 @@ class Mock { } public function __call($method, $arguments) { - if (@isset($this->{$method}) && is_callable($this->{$method})) { + if (isset($this->{$method}) && is_callable($this->{$method})) { return call_user_func_array($this->{$method}, $arguments); } else if (!self::__callStatic($method, $arguments)) { throw new Exception("Fatal error: Call to undefined method stdObject::{$method}()"); diff --git a/server/tests/__mocks__/ReCaptchaMock.php b/server/tests/__mocks__/ReCaptchaMock.php index fe4ff2ce..21474c4f 100644 --- a/server/tests/__mocks__/ReCaptchaMock.php +++ b/server/tests/__mocks__/ReCaptchaMock.php @@ -5,10 +5,11 @@ namespace ReCaptcha { class ReCaptcha extends \Mock { public static $functionList = array(); - public static $verify; + public static $staticVerify; + public $verify; public static function initVerify($value = true) { - self::$verify = \Mock::stub()->returns(new \Mock([ + self::$staticVerify = \Mock::stub()->returns(new \Mock([ 'isSuccess' => \Mock::stub()->returns($value) ])); } @@ -17,7 +18,7 @@ namespace ReCaptcha { parent::__construct(); $this->privateKey = $privateKey; - $this->verify = ReCaptcha::$verify; + $this->verify = self::$staticVerify; } } } \ No newline at end of file diff --git a/server/tests/libs/validations/captchaTest.php b/server/tests/libs/validations/captchaTest.php index 618d0bc3..e2e86eaf 100644 --- a/server/tests/libs/validations/captchaTest.php +++ b/server/tests/libs/validations/captchaTest.php @@ -30,6 +30,6 @@ class CaptchaValidationTest extends PHPUnit_Framework_TestCase { $captchaValidation->validate('MOCK_RESPONSE'); $this->assertTrue(Setting::get('getSetting')->hasBeenCalledWithArgs('recaptcha-private')); - $this->assertTrue(\ReCaptcha\ReCaptcha::$verify->hasBeenCalledWithArgs('MOCK_RESPONSE', 'MOCK_REMOTE')); + $this->assertTrue(\ReCaptcha\ReCaptcha::$staticVerify->hasBeenCalledWithArgs('MOCK_RESPONSE', 'MOCK_REMOTE')); } } \ No newline at end of file