Ivan - Backend - Fix captcha test

This commit is contained in:
ivan 2016-08-30 16:13:31 -03:00
parent 12cf0df27f
commit 157cce4b5e
3 changed files with 6 additions and 5 deletions

View File

@ -87,7 +87,7 @@ class Mock {
} }
public function __call($method, $arguments) { 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); return call_user_func_array($this->{$method}, $arguments);
} else if (!self::__callStatic($method, $arguments)) { } else if (!self::__callStatic($method, $arguments)) {
throw new Exception("Fatal error: Call to undefined method stdObject::{$method}()"); throw new Exception("Fatal error: Call to undefined method stdObject::{$method}()");

View File

@ -5,10 +5,11 @@ namespace ReCaptcha {
class ReCaptcha extends \Mock { class ReCaptcha extends \Mock {
public static $functionList = array(); public static $functionList = array();
public static $verify; public static $staticVerify;
public $verify;
public static function initVerify($value = true) { 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) 'isSuccess' => \Mock::stub()->returns($value)
])); ]));
} }
@ -17,7 +18,7 @@ namespace ReCaptcha {
parent::__construct(); parent::__construct();
$this->privateKey = $privateKey; $this->privateKey = $privateKey;
$this->verify = ReCaptcha::$verify; $this->verify = self::$staticVerify;
} }
} }
} }

View File

@ -30,6 +30,6 @@ class CaptchaValidationTest extends PHPUnit_Framework_TestCase {
$captchaValidation->validate('MOCK_RESPONSE'); $captchaValidation->validate('MOCK_RESPONSE');
$this->assertTrue(Setting::get('getSetting')->hasBeenCalledWithArgs('recaptcha-private')); $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'));
} }
} }