Ivan - Backend - Fix captcha test
This commit is contained in:
parent
12cf0df27f
commit
157cce4b5e
|
@ -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}()");
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
}
|
||||
}
|
|
@ -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'));
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue