summaryrefslogtreecommitdiff
path: root/libs/jsonrpc/tests/Validator/UserValidatorTest.php
diff options
context:
space:
mode:
Diffstat (limited to 'libs/jsonrpc/tests/Validator/UserValidatorTest.php')
-rw-r--r--libs/jsonrpc/tests/Validator/UserValidatorTest.php24
1 files changed, 24 insertions, 0 deletions
diff --git a/libs/jsonrpc/tests/Validator/UserValidatorTest.php b/libs/jsonrpc/tests/Validator/UserValidatorTest.php
new file mode 100644
index 00000000..e514c105
--- /dev/null
+++ b/libs/jsonrpc/tests/Validator/UserValidatorTest.php
@@ -0,0 +1,24 @@
+<?php
+
+use JsonRPC\Validator\UserValidator;
+
+require_once __DIR__.'/../../../../vendor/autoload.php';
+
+class UserValidatorTest extends PHPUnit_Framework_TestCase
+{
+ public function testWithEmptyHosts()
+ {
+ $this->assertNull(UserValidator::validate(array(), 'user', 'pass'));
+ }
+
+ public function testWithValidHosts()
+ {
+ $this->assertNull(UserValidator::validate(array('user' => 'pass'), 'user', 'pass'));
+ }
+
+ public function testWithNotAuthorizedHosts()
+ {
+ $this->setExpectedException('\JsonRPC\Exception\AuthenticationFailureException');
+ UserValidator::validate(array('user' => 'pass'), 'user', 'wrong password');
+ }
+}