mirror of
https://github.com/opensupports/opensupports.git
synced 2025-07-28 08:14:25 +02:00
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) {
|
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}()");
|
||||||
|
@ -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;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -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'));
|
||||||
}
|
}
|
||||||
}
|
}
|
Loading…
x
Reference in New Issue
Block a user