-
Notifications
You must be signed in to change notification settings - Fork 402
Move the tests directory to PSR-4 autoloading #332
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
2 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -27,19 +27,23 @@ | |
* @link https://wiki.jasig.org/display/CASC/phpCAS | ||
*/ | ||
|
||
namespace PhpCas\TestHarness; | ||
|
||
use PhpCas\TestHarness\ResponseInterface; | ||
|
||
/** | ||
* The BasicResponse allows tests to dynamically create a response that can be used | ||
* in unit tests. | ||
* | ||
* @class CAS_TestHarness_BasicResponse | ||
* @class BasicResponse | ||
* @category Authentication | ||
* @package PhpCAS | ||
* @author Adam Franco <[email protected]> | ||
* @license http://www.apache.org/licenses/LICENSE-2.0 Apache License 2.0 | ||
* @link https://wiki.jasig.org/display/CASC/phpCAS | ||
*/ | ||
|
||
class CAS_TestHarness_BasicResponse implements CAS_TestHarness_ResponseInterface | ||
class BasicResponse implements ResponseInterface | ||
{ | ||
protected $scheme = 'http'; | ||
protected $host = null; | ||
|
@@ -304,7 +308,7 @@ public function getResponseHeaders() | |
public function getResponseStatusCode() | ||
{ | ||
if (!$this->sent) { | ||
throw new CAS_OutOfSequenceException( | ||
throw new \CAS_OutOfSequenceException( | ||
'Request has not been sent yet. Cannot ' . __METHOD__ | ||
); | ||
} | ||
|
@@ -313,7 +317,7 @@ public function getResponseStatusCode() | |
$this->responseHeaders[0], $matches | ||
) | ||
) { | ||
throw new CAS_Request_Exception( | ||
throw new \CAS_Request_Exception( | ||
"Bad response, no status code was found in the first line." | ||
); | ||
} | ||
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -27,21 +27,25 @@ | |
* @link https://wiki.jasig.org/display/CASC/phpCAS | ||
*/ | ||
|
||
namespace PhpCas\TestHarness; | ||
|
||
use PhpCas\TestHarness\DummyRequest; | ||
|
||
/** | ||
* This interface defines a class library for performing multiple web requests | ||
* in batches. Implementations of this interface may perform requests serially | ||
* or in parallel. | ||
* | ||
* @class CAS_TestHarness_DummyMultiRequest | ||
* @class DummyMultiRequest | ||
* @category Authentication | ||
* @package PhpCAS | ||
* @author Adam Franco <[email protected]> | ||
* @license http://www.apache.org/licenses/LICENSE-2.0 Apache License 2.0 | ||
* @link https://wiki.jasig.org/display/CASC/phpCAS | ||
*/ | ||
|
||
class CAS_TestHarness_DummyMultiRequest implements | ||
CAS_Request_MultiRequestInterface | ||
class DummyMultiRequest implements | ||
\CAS_Request_MultiRequestInterface | ||
{ | ||
private $_requests = array(); | ||
private $_sent = false; | ||
|
@@ -63,16 +67,16 @@ class CAS_TestHarness_DummyMultiRequest implements | |
* @throws CAS_InvalidArgumentException If passed a Request of the wrong | ||
* implmentation. | ||
*/ | ||
public function addRequest(CAS_Request_RequestInterface $request) | ||
public function addRequest(\CAS_Request_RequestInterface $request) | ||
{ | ||
if ($this->_sent) { | ||
throw new CAS_OutOfSequenceException( | ||
throw new \CAS_OutOfSequenceException( | ||
'Request has already been sent cannot ' . __METHOD__ | ||
); | ||
} | ||
if (!$request instanceof CAS_TestHarness_DummyRequest) { | ||
throw new CAS_InvalidArgumentException( | ||
'As a CAS_TestHarness_DummyMultiRequest, I can only work with CAS_TestHarness_DummyRequest objects.' | ||
if (!$request instanceof DummyRequest) { | ||
throw new \CAS_InvalidArgumentException( | ||
'As a DummyMultiRequest, I can only work with DummyRequest objects.' | ||
); | ||
} | ||
|
||
|
@@ -94,12 +98,12 @@ public function addRequest(CAS_Request_RequestInterface $request) | |
public function send() | ||
{ | ||
if ($this->_sent) { | ||
throw new CAS_OutOfSequenceException( | ||
throw new \CAS_OutOfSequenceException( | ||
'Request has already been sent cannot send again.' | ||
); | ||
} | ||
if (!count($this->_requests)) { | ||
throw new CAS_OutOfSequenceException( | ||
throw new \CAS_OutOfSequenceException( | ||
'At least one request must be added via addRequest() before the multi-request can be sent.' | ||
); | ||
} | ||
|
@@ -119,7 +123,7 @@ public function send() | |
public function getNumRequests() | ||
{ | ||
if ($this->_sent) { | ||
throw new CAS_OutOfSequenceException( | ||
throw new \CAS_OutOfSequenceException( | ||
'Request has already been sent cannot ' . __METHOD__ | ||
); | ||
} | ||
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -27,30 +27,34 @@ | |
* @link https://wiki.jasig.org/display/CASC/phpCAS | ||
*/ | ||
|
||
namespace PhpCas\TestHarness; | ||
|
||
use PhpCas\TestHarness\ResponseInterface; | ||
|
||
/** | ||
* Provides support for performing dummy web-requests | ||
* | ||
* @class CAS_TestHarness_DummyRequest | ||
* @class DummyRequest | ||
* @category Authentication | ||
* @package PhpCAS | ||
* @author Adam Franco <[email protected]> | ||
* @license http://www.apache.org/licenses/LICENSE-2.0 Apache License 2.0 | ||
* @link https://wiki.jasig.org/display/CASC/phpCAS | ||
*/ | ||
class CAS_TestHarness_DummyRequest extends CAS_Request_AbstractRequest | ||
implements CAS_Request_RequestInterface | ||
class DummyRequest extends \CAS_Request_AbstractRequest | ||
implements \CAS_Request_RequestInterface | ||
{ | ||
private static $_responses = array(); | ||
|
||
/** | ||
* Configure a URL/Response that the test harness will respond to. | ||
* | ||
* @param CAS_TestHarness_ResponseInterface $response response interface | ||
* @param ResponseInterface $response response interface | ||
* | ||
* @return void | ||
*/ | ||
public static function addResponse( | ||
CAS_TestHarness_ResponseInterface $response | ||
ResponseInterface $response | ||
) { | ||
self::$_responses[] = $response; | ||
} | ||
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -27,19 +27,21 @@ | |
* @link https://wiki.jasig.org/display/CASC/phpCAS | ||
*/ | ||
|
||
namespace PhpCas\TestHarness; | ||
|
||
/** | ||
* Implementations of this interface can validate a request and provide response | ||
* headers and body, allowing the spoofing of responses to web requests for testing | ||
* purposes. | ||
* | ||
* @class CAS_TestHarness_ResponseInterface | ||
* @class ResponseInterface | ||
* @category Authentication | ||
* @package PhpCAS | ||
* @author Adam Franco <[email protected]> | ||
* @license http://www.apache.org/licenses/LICENSE-2.0 Apache License 2.0 | ||
* @link https://wiki.jasig.org/display/CASC/phpCAS | ||
*/ | ||
interface CAS_TestHarness_ResponseInterface | ||
interface ResponseInterface | ||
{ | ||
|
||
/** | ||
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -27,19 +27,23 @@ | |
* @link https://wiki.jasig.org/display/CASC/phpCAS | ||
*/ | ||
|
||
namespace PhpCas\Tests; | ||
|
||
use PhpCas\TestHarness\BasicResponse; | ||
use PhpCas\TestHarness\DummyRequest; | ||
use PHPUnit\Framework\TestCase; | ||
|
||
/** | ||
* Test class for verifying the operation of service tickets. | ||
* | ||
* @class CAS_Tests_AuthenticationTest | ||
* @class AuthenticationTest | ||
* @category Authentication | ||
* @package PhpCAS | ||
* @author Adam Franco <[email protected]> | ||
* @license http://www.apache.org/licenses/LICENSE-2.0 Apache License 2.0 | ||
* @link https://wiki.jasig.org/display/CASC/phpCAS | ||
*/ | ||
class CAS_Tests_AuthenticationTest extends TestCase | ||
class AuthenticationTest extends TestCase | ||
{ | ||
/** | ||
* @var CAS_Client | ||
|
@@ -57,7 +61,7 @@ protected function setUp() | |
// phpCAS::setDebug(dirname(__FILE__).'/../test.log'); | ||
// error_reporting(E_ALL); | ||
|
||
CAS_GracefullTerminationException::throwInsteadOfExiting(); | ||
\CAS_GracefullTerminationException::throwInsteadOfExiting(); | ||
|
||
$_SERVER['SERVER_NAME'] = 'www.clientapp.com'; | ||
$_SERVER['SERVER_PORT'] = '80'; | ||
|
@@ -68,7 +72,7 @@ protected function setUp() | |
$_SERVER['PHP_SELF'] = '/index.php'; | ||
$_SESSION = array(); | ||
|
||
$this->object = new CAS_Client( | ||
$this->object = new \CAS_Client( | ||
phy25 marked this conversation as resolved.
Show resolved
Hide resolved
|
||
CAS_VERSION_2_0, // Server Version | ||
true, // Proxy | ||
'cas.example.edu', // Server Hostname | ||
|
@@ -77,15 +81,15 @@ protected function setUp() | |
false // Start Session | ||
); | ||
|
||
$this->object->setRequestImplementation('CAS_TestHarness_DummyRequest'); | ||
$this->object->setRequestImplementation('PhpCas\TestHarness\DummyRequest'); | ||
$this->object->setCasServerCACert(__FILE__, true); | ||
|
||
/********************************************************* | ||
* Enumerate our responses | ||
*********************************************************/ | ||
|
||
// Set up our response. | ||
$response = new CAS_TestHarness_BasicResponse( | ||
$response = new BasicResponse( | ||
'https', 'cas.example.edu', '/cas/serviceValidate' | ||
); | ||
$response->setResponseHeaders( | ||
|
@@ -107,7 +111,7 @@ protected function setUp() | |
</cas:serviceResponse> | ||
" | ||
); | ||
CAS_TestHarness_DummyRequest::addResponse($response); | ||
DummyRequest::addResponse($response); | ||
|
||
} | ||
|
||
|
@@ -119,7 +123,7 @@ protected function setUp() | |
*/ | ||
protected function tearDown() | ||
{ | ||
CAS_TestHarness_DummyRequest::clearResponses(); | ||
DummyRequest::clearResponses(); | ||
$_SESSION = array(); | ||
} | ||
|
||
|
@@ -135,7 +139,7 @@ public function testRedirect() | |
ob_start(); | ||
try { | ||
$this->object->forceAuthentication(); | ||
} catch (Exception $e) { | ||
} catch (\Exception $e) { | ||
ob_end_clean(); | ||
throw $e; | ||
} | ||
|
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.