-
Notifications
You must be signed in to change notification settings - Fork 16
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Cas is not anymore static, add unittests
- Loading branch information
Showing
7 changed files
with
100 additions
and
16 deletions.
There are no files selected for viewing
This file contains 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 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 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 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 |
---|---|---|
@@ -0,0 +1,3 @@ | ||
<?php namespace Payutc\Exception; | ||
|
||
class AuthenticationFailure extends PayutcException {}; |
This file contains 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 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 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 |
---|---|---|
@@ -0,0 +1,66 @@ | ||
<?php | ||
|
||
|
||
include 'bootstrap.php'; | ||
|
||
|
||
use \Payutc\Cas; | ||
use \Payutc\Config; | ||
|
||
class CasTest extends PHPUnit_Framework_TestCase | ||
{ | ||
public function __construct() | ||
{ | ||
global $_CONFIG; | ||
Config::initFromArray($_CONFIG); | ||
} | ||
|
||
public function testConstruct() | ||
{ | ||
$cas = new Cas("http://cas.coucou.fr/"); | ||
} | ||
|
||
public function testAuthenticateSuccess() | ||
{ | ||
$cas = new Cas(Config::get('cas_url')); | ||
$user = $cas->authenticate('trecouvr@coucou', 'coucou'); | ||
$this->assertEquals('trecouvr', $user); | ||
} | ||
|
||
/** | ||
* @expectedException \Payutc\Exception\AuthenticationFailure | ||
*/ | ||
public function testAuthenticationFailure() | ||
{ | ||
$cas = new Cas(Config::get('cas_url')); | ||
$cas->authenticate('trecouvr@coou', 'coucou'); | ||
} | ||
|
||
/** | ||
* @expectedException \Httpful\Exception\ConnectionErrorException | ||
*/ | ||
public function testNetworkFailure() | ||
{ | ||
$cas = new Cas('http://12345cas.coucou.fr/', 1); | ||
$cas->authenticate('trecouvr@coucou', 'coucou'); | ||
} | ||
|
||
/** | ||
* @expectedException \Httpful\Exception\ConnectionErrorException | ||
*/ | ||
public function testNetworkFailure2() | ||
{ | ||
$cas = new Cas('http://localhost:60904/', 1); | ||
$cas->authenticate('trecouvr@coucou', 'coucou'); | ||
} | ||
|
||
/** | ||
* @expectedException \UnexpectedValueException | ||
*/ | ||
public function testNoXmlResponse() | ||
{ | ||
$cas = new Cas('http://google.fr/'); | ||
$cas->authenticate('trecouvr@coucou', 'coucou'); | ||
} | ||
} | ||
|