oauth2-server/tests/unit/Exception/OAuthExceptionTest.php

35 lines
1.1 KiB
PHP
Raw Normal View History

2014-05-07 21:55:25 +05:30
<?php
namespace LeagueTests;
2014-11-08 23:56:12 +05:30
use League\OAuth2\Server\Exception\OAuthException;
2014-05-07 21:55:25 +05:30
class OAuthExceptionTest extends \PHPUnit_Framework_TestCase
{
public function testGetHttpHeaders()
{
2014-11-08 23:56:12 +05:30
$exception = new OAuthException();
2014-05-07 21:55:25 +05:30
$exception->httpStatusCode = 400;
$this->assertSame($exception->getHttpHeaders(), ['HTTP/1.1 400 Bad Request']);
$exception->httpStatusCode = 401;
$this->assertSame($exception->getHttpHeaders(), ['HTTP/1.1 401 Unauthorized']);
$exception->httpStatusCode = 500;
$this->assertSame($exception->getHttpHeaders(), ['HTTP/1.1 500 Internal Server Error']);
$exception->httpStatusCode = 501;
$this->assertSame($exception->getHttpHeaders(), ['HTTP/1.1 501 Not Implemented']);
}
2014-11-08 22:46:17 +05:30
public function testShouldRedirect()
{
2014-11-08 23:56:12 +05:30
$exception = new OAuthException();
2014-11-08 22:46:17 +05:30
$exception->redirectUri = 'http://example.com/';
$exception->errorType = 'Error';
$this->assertTrue($exception->shouldRedirect());
$this->assertEquals('http://example.com/?error=Error&message=An+error+occured', $exception->getRedirectUri());
}
2014-05-07 21:55:25 +05:30
}