diff options
author | Frédéric Guillot <fred@kanboard.net> | 2018-06-21 14:13:41 -0700 |
---|---|---|
committer | Frédéric Guillot <fred@kanboard.net> | 2018-06-21 14:13:41 -0700 |
commit | a491348d442ab8e6cd2fa403d4365cdad78e52ce (patch) | |
tree | a00f575d82afb2c9051bad95398b4250f4a3d44d /libs/jsonrpc/tests/Validator/RpcFormatValidatorTest.php | |
parent | c73ac5f1f818b6b21083f6785b4b2f6d778a6496 (diff) |
Vendoring deprecated composer libs
Diffstat (limited to 'libs/jsonrpc/tests/Validator/RpcFormatValidatorTest.php')
-rw-r--r-- | libs/jsonrpc/tests/Validator/RpcFormatValidatorTest.php | 48 |
1 files changed, 48 insertions, 0 deletions
diff --git a/libs/jsonrpc/tests/Validator/RpcFormatValidatorTest.php b/libs/jsonrpc/tests/Validator/RpcFormatValidatorTest.php new file mode 100644 index 00000000..3e6ba8bc --- /dev/null +++ b/libs/jsonrpc/tests/Validator/RpcFormatValidatorTest.php @@ -0,0 +1,48 @@ +<?php + +use JsonRPC\Validator\RpcFormatValidator; + +require_once __DIR__.'/../../../../vendor/autoload.php'; + +class RpcFormatValidatorTest extends PHPUnit_Framework_TestCase +{ + public function testWithMinimumRequirement() + { + $this->assertNull(RpcFormatValidator::validate(array('jsonrpc' => '2.0', 'method' => 'foobar'))); + } + + public function testWithNoVersion() + { + $this->setExpectedException('\JsonRPC\Exception\InvalidJsonRpcFormatException'); + RpcFormatValidator::validate(array('method' => 'foobar')); + } + + public function testWithNoMethod() + { + $this->setExpectedException('\JsonRPC\Exception\InvalidJsonRpcFormatException'); + RpcFormatValidator::validate(array('jsonrpc' => '2.0')); + } + + public function testWithMethodNotString() + { + $this->setExpectedException('\JsonRPC\Exception\InvalidJsonRpcFormatException'); + RpcFormatValidator::validate(array('jsonrpc' => '2.0', 'method' => array())); + } + + public function testWithBadVersion() + { + $this->setExpectedException('\JsonRPC\Exception\InvalidJsonRpcFormatException'); + RpcFormatValidator::validate(array('jsonrpc' => '1.0', 'method' => 'abc')); + } + + public function testWithBadParams() + { + $this->setExpectedException('\JsonRPC\Exception\InvalidJsonRpcFormatException'); + RpcFormatValidator::validate(array('jsonrpc' => '2.0', 'method' => 'abc', 'params' => 'foobar')); + } + + public function testWithParams() + { + $this->assertNull(RpcFormatValidator::validate(array('jsonrpc' => '2.0', 'method' => 'abc', 'params' => array(1, 2)))); + } +} |