From 575f34256aa6e7e77849e4acd53951a6b1db868d Mon Sep 17 00:00:00 2001 From: Ivan Diaz Date: Sat, 14 Jan 2017 23:51:31 -0300 Subject: [PATCH] Ivan - Fix unit testing backend --- server/tests/__mocks__/APIKeyMock.php | 12 ++++++++++++ server/tests/__mocks__/UserMock.php | 2 ++ server/tests/libs/validations/captchaTest.php | 4 ++++ 3 files changed, 18 insertions(+) create mode 100644 server/tests/__mocks__/APIKeyMock.php diff --git a/server/tests/__mocks__/APIKeyMock.php b/server/tests/__mocks__/APIKeyMock.php new file mode 100644 index 00000000..7ef32d77 --- /dev/null +++ b/server/tests/__mocks__/APIKeyMock.php @@ -0,0 +1,12 @@ + parent::stub()->returns(new NullDataStore()), + )); + } +} \ No newline at end of file diff --git a/server/tests/__mocks__/UserMock.php b/server/tests/__mocks__/UserMock.php index c8edb25a..d7913a23 100644 --- a/server/tests/__mocks__/UserMock.php +++ b/server/tests/__mocks__/UserMock.php @@ -5,6 +5,7 @@ class User extends \Mock { public static function initStubs() { parent::setStatics(array( 'authenticate' => parent::stub()->returns(self::getUserInstanceMock()), + 'getDataStore' => parent::stub()->returns(self::getUserInstanceMock()) )); } @@ -18,6 +19,7 @@ class User extends \Mock { $mockUserInstance->id = 'MOCK_ID'; $mockUserInstance->email = 'MOCK_EMAIL'; $mockUserInstance->password = 'MOCK_PASSWORD'; + $mockUserInstance->verificationToken = null; return $mockUserInstance; } diff --git a/server/tests/libs/validations/captchaTest.php b/server/tests/libs/validations/captchaTest.php index e2e86eaf..c85bfcf7 100644 --- a/server/tests/libs/validations/captchaTest.php +++ b/server/tests/libs/validations/captchaTest.php @@ -2,6 +2,8 @@ include_once 'tests/__lib__/Mock.php'; include_once 'tests/__mocks__/RespectMock.php'; include_once 'tests/__mocks__/SettingMock.php'; +include_once 'tests/__mocks__/APIKeyMock.php'; +include_once 'tests/__mocks__/ControllerMock.php'; include_once 'tests/__mocks__/ReCaptchaMock.php'; include_once 'libs/validations/captcha.php'; @@ -10,6 +12,8 @@ class CaptchaValidationTest extends PHPUnit_Framework_TestCase { protected function setUp() { Setting::initStubs(); + Controller::initStubs(); + APIKey::initStubs(); \ReCaptcha\ReCaptcha::initVerify(); $_SERVER['REMOTE_ADDR'] = 'MOCK_REMOTE';