Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
PHPCAS-128 merging the PHPCAS-128 branch changes back into /trunk. Fi…
…x phpunit warnings/notices.

git-svn-id: https://source.jasig.org/cas-clients/phpcas/trunk@25044 f5dbab47-78f9-eb45-b975-e544023573eb
  • Loading branch information
fritschi committed Sep 17, 2011
2 parents cd492cf + 615b870 commit 45257fc
Show file tree
Hide file tree
Showing 9 changed files with 29 additions and 39 deletions.
2 changes: 0 additions & 2 deletions test/TestSuite.php
Expand Up @@ -2,8 +2,6 @@

require_once dirname(__FILE__).'/../source/CAS.php';

require_once 'PHPUnit/Framework.php';

class PhpcasTestSuite extends PHPUnit_Framework_TestSuite
{
public static function suite()
Expand Down
7 changes: 3 additions & 4 deletions test/tests/Cas20AttributesTest.php
@@ -1,5 +1,4 @@
<?php
require_once 'PHPUnit/Framework.php';
require_once dirname(__FILE__).'/../harness/DummyRequest.php';
require_once dirname(__FILE__).'/../harness/BasicResponse.php';

Expand Down Expand Up @@ -224,7 +223,7 @@ public function test_name_value_attributes() {
*/
public function validateUserAttributes () {
$attras = $this->object->getAttributes();
$this->assertType('array', $attras);
$this->assertInternalType('array', $attras);

if (count($attras) != 4 || !is_array($attras['memberOf'])) {
print "\n";
Expand All @@ -250,13 +249,13 @@ public function validateUserAttributes () {
$this->assertTrue($this->object->hasAttribute('memberOf'));
// direct access
$memberOf = $this->object->getAttribute('memberOf');
$this->assertType('array', $memberOf);
$this->assertInternalType('array', $memberOf);
$this->assertEquals(2, count($memberOf));
$this->assertTrue(in_array('CN=Staff,OU=Groups,DC=example,DC=edu', $memberOf));
$this->assertTrue(in_array('CN=Spanish Department,OU=Departments,OU=Groups,DC=example,DC=edu', $memberOf));
// array access
$this->assertArrayHasKey('memberOf', $attras);
$this->assertType('array', $attras['memberOf']);
$this->assertInternalType('array', $attras['memberOf']);
$this->assertEquals(2, count($attras['memberOf']));
$this->assertTrue(in_array('CN=Staff,OU=Groups,DC=example,DC=edu', $attras['memberOf']));
$this->assertTrue(in_array('CN=Spanish Department,OU=Departments,OU=Groups,DC=example,DC=edu', $attras['memberOf']));
Expand Down
35 changes: 17 additions & 18 deletions test/tests/CookieJarTest.php
@@ -1,5 +1,4 @@
<?php
require_once 'PHPUnit/Framework.php';

require_once dirname(__FILE__).'/../../source/CAS/CookieJar.php';

Expand Down Expand Up @@ -300,7 +299,7 @@ public function test_public_storeCookies_httponly()

$cookies = $this->object->getCookies($this->serviceUrl_1b);

$this->assertType('array', $cookies);
$this->assertInternalType('array', $cookies);
$this->assertEquals('hello world', $cookies['SID']);
$this->assertEquals(1, count($cookies), "Should only a single SID cookie, not a cookie for the HttpOnly attribute");
}
Expand All @@ -315,7 +314,7 @@ public function test_public_storeCookies_comment()

$cookies = $this->object->getCookies($this->serviceUrl_1b);

$this->assertType('array', $cookies);
$this->assertInternalType('array', $cookies);
$this->assertEquals('hello world', $cookies['SID']);
$this->assertEquals(1, count($cookies), "Should only a single SID cookie, not a cookie for the comment attribute");
}
Expand All @@ -336,7 +335,7 @@ public function test_public_storeCookies_QuotedSemicolon()
$cookies = $this->object->getCookies($this->serviceUrl_1b);
$this->assertType('array', $cookies);
$this->assertInternalType('array', $cookies);
$this->assertEquals('hello;world', $cookies['SID'], "\tNote: The implementation as of Sept 15, 2010 makes the assumption \n\tthat semicolons will not be present in quoted attribute values. \n\tWhile attribute values that contain semicolons are allowed by \n\tRFC2965, they are hopefully rare enough to ignore for our purposes.");
$this->assertEquals(1, count($cookies));
}
Expand All @@ -356,7 +355,7 @@ public function test_public_storeCookies_QuotedEquals()

$cookies = $this->object->getCookies($this->serviceUrl_1b);

$this->assertType('array', $cookies);
$this->assertInternalType('array', $cookies);
$this->assertEquals('hello=world', $cookies['SID'], "\tNote: The implementation as of Sept 15, 2010 makes the assumption \n\tthat equals symbols will not be present in quoted attribute values. \n\tWhile attribute values that contain equals symbols are allowed by \n\tRFC2965, they are hopefully rare enough to ignore for our purposes.");
$this->assertEquals(1, count($cookies));
}
Expand All @@ -372,7 +371,7 @@ public function test_public_storeCookies_QuotedEscapedQuote()

$cookies = $this->object->getCookies($this->serviceUrl_1b);

$this->assertType('array', $cookies);
$this->assertInternalType('array', $cookies);
$this->assertEquals('hello"world', $cookies['SID']);
$this->assertEquals(1, count($cookies));
}
Expand All @@ -393,7 +392,7 @@ public function test_protected_parseCookieHeaders()
{
$cookies = $this->object->parseCookieHeaders($this->responseHeaders_1, 'service.example.com');

$this->assertType('array', $cookies);
$this->assertInternalType('array', $cookies);
$this->assertEquals(1, count($cookies));
$this->assertEquals('SID', $cookies[0]['name']);
$this->assertEquals('k1jut1r1bqrumpei837kk4jks0', $cookies[0]['value']);
Expand All @@ -410,7 +409,7 @@ public function test_protected_parseCookieHeaders_WithDomain()
$headers = array('Set-Cookie: SID=k1jut1r1bqrumpei837kk4jks0; path=/; domain=.example.com');
$cookies = $this->object->parseCookieHeaders($headers, 'service.example.com');

$this->assertType('array', $cookies);
$this->assertInternalType('array', $cookies);
$this->assertEquals(1, count($cookies));
$this->assertEquals('SID', $cookies[0]['name']);
$this->assertEquals('k1jut1r1bqrumpei837kk4jks0', $cookies[0]['value']);
Expand All @@ -427,7 +426,7 @@ public function test_protected_parseCookieHeaders_WithHostname()
$headers = array('Set-Cookie: SID=k1jut1r1bqrumpei837kk4jks0; path=/; domain=service.example.com');
$cookies = $this->object->parseCookieHeaders($headers, 'service.example.com');

$this->assertType('array', $cookies);
$this->assertInternalType('array', $cookies);
$this->assertEquals(1, count($cookies));
$this->assertEquals('SID', $cookies[0]['name']);
$this->assertEquals('k1jut1r1bqrumpei837kk4jks0', $cookies[0]['value']);
Expand All @@ -444,7 +443,7 @@ public function test_protected_parseCookieHeaders_NonDefaultHostname()
$headers = array('Set-Cookie: SID=k1jut1r1bqrumpei837kk4jks0; path=/; domain=service2.example.com');
$cookies = $this->object->parseCookieHeaders($headers, 'service.example.com');

$this->assertType('array', $cookies);
$this->assertInternalType('array', $cookies);
$this->assertEquals(1, count($cookies));
$this->assertEquals('SID', $cookies[0]['name']);
$this->assertEquals('k1jut1r1bqrumpei837kk4jks0', $cookies[0]['value']);
Expand All @@ -461,7 +460,7 @@ public function test_protected_parseCookieHeaders_WithPath()
$headers = array('Set-Cookie: SID=k1jut1r1bqrumpei837kk4jks0; path=/something/; domain=service2.example.com');
$cookies = $this->object->parseCookieHeaders($headers, 'service.example.com');

$this->assertType('array', $cookies);
$this->assertInternalType('array', $cookies);
$this->assertEquals(1, count($cookies));
$this->assertEquals('SID', $cookies[0]['name']);
$this->assertEquals('k1jut1r1bqrumpei837kk4jks0', $cookies[0]['value']);
Expand All @@ -478,7 +477,7 @@ public function test_protected_parseCookieHeaders_Secure()
$headers = array('Set-Cookie: SID=k1jut1r1bqrumpei837kk4jks0; Secure; path=/something/; domain=service2.example.com');
$cookies = $this->object->parseCookieHeaders($headers, 'service.example.com');

$this->assertType('array', $cookies);
$this->assertInternalType('array', $cookies);
$this->assertEquals(1, count($cookies));
$this->assertEquals('SID', $cookies[0]['name']);
$this->assertEquals('k1jut1r1bqrumpei837kk4jks0', $cookies[0]['value']);
Expand All @@ -495,7 +494,7 @@ public function test_protected_parseCookieHeaders_SecureLC()
$headers = array('Set-Cookie: SID=k1jut1r1bqrumpei837kk4jks0; secure; path=/something/; domain=service2.example.com');
$cookies = $this->object->parseCookieHeaders($headers, 'service.example.com');

$this->assertType('array', $cookies);
$this->assertInternalType('array', $cookies);
$this->assertEquals(1, count($cookies));
$this->assertEquals('SID', $cookies[0]['name']);
$this->assertEquals('k1jut1r1bqrumpei837kk4jks0', $cookies[0]['value']);
Expand All @@ -512,7 +511,7 @@ public function test_protected_parseCookieHeaders_trailingSemicolon()
$headers = array('Set-Cookie: SID="hello world"; path=/;');
$cookies = $this->object->parseCookieHeaders($headers, 'service.example.com');

$this->assertType('array', $cookies);
$this->assertInternalType('array', $cookies);
$this->assertEquals(1, count($cookies));
$this->assertEquals('SID', $cookies[0]['name']);
$this->assertEquals('hello world', $cookies[0]['value']);
Expand All @@ -527,7 +526,7 @@ public function test_protected_parseCookieHeaders_trailingSemicolon()
public function test_protected_setCookie()
{
$cookies = $this->object->getCookies($this->serviceUrl_1c);
$this->assertType('array', $cookies);
$this->assertInternalType('array', $cookies);
$this->assertEquals(1, count($cookies));
$this->assertEquals('k1jut1r1bqrumpei837kk4jks0', $cookies['SID']);
}
Expand All @@ -546,7 +545,7 @@ public function test_protected_storeCookie_WithDuplicates()
$this->object->storeCookie($cookiesToSet[0]);

$cookies = $this->object->getCookies($this->serviceUrl_1c);
$this->assertType('array', $cookies);
$this->assertInternalType('array', $cookies);
$this->assertEquals(1, count($cookies));
$this->assertEquals('goodbye world', $cookies['SID']);
}
Expand All @@ -563,7 +562,7 @@ public function test_protected_storeCookie_TwoCookies()


$cookies = $this->object->getCookies($this->serviceUrl_1c);
$this->assertType('array', $cookies);
$this->assertInternalType('array', $cookies);
$this->assertEquals(2, count($cookies));
$this->assertEquals('k1jut1r1bqrumpei837kk4jks0', $cookies['SID']);
$this->assertEquals('hello world', $cookies['message']);
Expand All @@ -582,7 +581,7 @@ public function test_protected_storeCookie_TwoCookiesOneAtDomain()


$cookies = $this->object->getCookies($this->serviceUrl_1c);
$this->assertType('array', $cookies);
$this->assertInternalType('array', $cookies);
$this->assertEquals(2, count($cookies));
$this->assertEquals('k1jut1r1bqrumpei837kk4jks0', $cookies['SID']);
$this->assertEquals('hello world', $cookies['message']);
Expand Down
1 change: 0 additions & 1 deletion test/tests/MultiRequestTest.php
@@ -1,5 +1,4 @@
<?php
require_once 'PHPUnit/Framework.php';
require_once dirname(__FILE__).'/../harness/DummyRequest.php';
require_once dirname(__FILE__).'/../harness/DummyMultiRequest.php';
require_once dirname(__FILE__).'/../harness/BasicResponse.php';
Expand Down
1 change: 0 additions & 1 deletion test/tests/ProxyChainsTest.php
@@ -1,5 +1,4 @@
<?php
require_once 'PHPUnit/Framework.php';

require_once dirname(__FILE__).'/../../source/CAS/ProxyChain/AllowedList.php';

Expand Down
9 changes: 4 additions & 5 deletions test/tests/ProxyTicketValidationTest.php
@@ -1,5 +1,4 @@
<?php
require_once 'PHPUnit/Framework.php';
require_once dirname(__FILE__).'/../harness/DummyRequest.php';
require_once dirname(__FILE__).'/../harness/BasicResponse.php';

Expand Down Expand Up @@ -138,7 +137,7 @@ public function test_validation_success() {
</cas:authenticationSuccess>
</cas:serviceResponse>"
, $text_response);
$this->assertType('DOMElement', $tree_response);
$this->assertInstanceOf('DOMElement', $tree_response);
}

/**
Expand All @@ -160,7 +159,7 @@ public function test_invalid_ticket_failure() {
</cas:serviceResponse>
", $text_response);
$this->assertType('DOMElement', $tree_response);
$this->assertInstanceOf('DOMElement', $tree_response);
}


Expand All @@ -185,7 +184,7 @@ public function test_allowed_proxies_string_success(){
</cas:authenticationSuccess>
</cas:serviceResponse>"
, $text_response);
$this->assertType('DOMElement', $tree_response);
$this->assertInstanceOf('DOMElement', $tree_response);
}
/**
* Test that the trusted proxy allows any proxies beyond the one we trust.
Expand All @@ -211,7 +210,7 @@ public function test_allowed_proxies_trusted_success(){
</cas:authenticationSuccess>
</cas:serviceResponse>"
, $text_response);
$this->assertType('DOMElement', $tree_response);
$this->assertInstanceOf('DOMElement', $tree_response);
}

/**
Expand Down
7 changes: 3 additions & 4 deletions test/tests/ServiceMailTest.php
@@ -1,5 +1,4 @@
<?php
require_once 'PHPUnit/Framework.php';
require_once dirname(__FILE__).'/../harness/DummyRequest.php';
require_once dirname(__FILE__).'/../harness/BasicResponse.php';

Expand Down Expand Up @@ -172,7 +171,7 @@ public function test_serviceMail() {
$this->markTestIncomplete('This test has not been implemented yet.');

// $stream = $this->object->serviceMail('mailbox_name', 'imap://mail.example.edu/path/to/something', OP_READONLY, $err_code, $err_msg, $pt);
// $this->assertType('resource', $stream);
// $this->assertInternalType('resource', $stream);
// $this->assertEquals(PHPCAS_SERVICE_OK, $err_code);
// $this->assertEquals('', $err_msg);
// $this->assertEquals('PT-asdfas-dfasgww2323radf3', $pt);
Expand Down Expand Up @@ -215,8 +214,8 @@ public function test_Imap() {
// $service->setMailbox('mailbox_name');
// $service->setOptions(OP_READONLY);
// $stream = $service->open();
// $this->assertType('resource', $stream);
// $this->assertType('resource', $service->getStream());
// $this->assertInternalType('resource', $stream);
// $this->assertInternalType('resource', $service->getStream());
// $this->assertEquals('PT-asdfas-dfasgww2323radf3', $service->getImapProxyTicket());

}
Expand Down
5 changes: 2 additions & 3 deletions test/tests/ServiceTicketValidationTest.php
@@ -1,5 +1,4 @@
<?php
require_once 'PHPUnit/Framework.php';
require_once dirname(__FILE__).'/../harness/DummyRequest.php';
require_once dirname(__FILE__).'/../harness/BasicResponse.php';

Expand Down Expand Up @@ -132,7 +131,7 @@ public function test_validation_success() {
</cas:authenticationSuccess>
</cas:serviceResponse>
", $text_response);
$this->assertType('DOMElement', $tree_response);
$this->assertInstanceOf('DOMElement', $tree_response);
}

/**
Expand All @@ -154,7 +153,7 @@ public function test_invalid_ticket_failure() {
</cas:serviceResponse>
", $text_response);
$this->assertType('DOMElement', $tree_response);
$this->assertInstanceOf('DOMElement', $tree_response);
}

}
Expand Down
1 change: 0 additions & 1 deletion test/tests/ServiceWebTest.php
@@ -1,5 +1,4 @@
<?php
require_once 'PHPUnit/Framework.php';
require_once dirname(__FILE__).'/../harness/DummyRequest.php';
require_once dirname(__FILE__).'/../harness/BasicResponse.php';

Expand Down

0 comments on commit 45257fc

Please sign in to comment.