From 1409df6eb40b07ad33169777cd128b56f31c4bad Mon Sep 17 00:00:00 2001 From: Alex Bilbie Date: Wed, 1 Aug 2012 17:15:29 +0100 Subject: [PATCH] Started adding tests for auth server --- tests/authentication/server_test.php | 37 ++++++++++++++++++++++++++++ 1 file changed, 37 insertions(+) create mode 100644 tests/authentication/server_test.php diff --git a/tests/authentication/server_test.php b/tests/authentication/server_test.php new file mode 100644 index 00000000..f9d4df29 --- /dev/null +++ b/tests/authentication/server_test.php @@ -0,0 +1,37 @@ +oauth = new Oauth2\Authentication\Server(); + + //$this->oauth->registerDbAbstractor($this->oauthdb); + } + + function test_generateCode() + { + $reflector = new ReflectionClass($this->oauth); + $method = $reflector->getMethod('generateCode'); + $method->setAccessible(true); + + $result = $method->invoke($this->oauth); + $result2 = $method->invoke($this->oauth); + + $this->assertEquals(40, strlen($result)); + $this->assertNotEquals($result, $result2); + } + + function test_redirectUri() + { + $result1 = $this->oauth->redirectUri('http://example.com/foo'); + $result2 = $this->oauth->redirectUri('http://example.com/foo', array('foo' => 'bar')); + $result3 = $this->oauth->redirectUri('http://example.com/foo', array('foo' => 'bar'), '#'); + + $this->assertEquals('http://example.com/foo?', $result1); + $this->assertEquals('http://example.com/foo?foo=bar', $result2); + $this->assertEquals('http://example.com/foo#foo=bar', $result3); + } + + +} \ No newline at end of file