Skip to content

Commit bd0e964

Browse files
Upgrade PHPUnit to the latest version (#378)
* [DO NOT REVIEW] Drop support for outdated PHP versions https://www.php.net/supported-versions.php Support for PHP 7.1 and 7.2 remains on a best-effort basis to accommodate users who haven’t upgraded yet. * Upgrade PHPUnit to the latest version @ExpectedException has been replaced with $this->expectException. assertInternalType was replaced with more specific assertions (assertIsArray). Co-authored-by: Joachim Fritschi <[email protected]>
1 parent e24d52d commit bd0e964

12 files changed

+63
-113
lines changed

Diff for: phpunit.xml.dist

+11-19
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,13 @@
11
<?xml version="1.0" encoding="UTF-8"?>
2-
<phpunit
3-
bootstrap="source/CAS.php"
4-
convertNoticesToExceptions="false"
5-
colors="true"
6-
stderr="true"
7-
backupGlobals="true"
8-
>
9-
10-
<testsuites>
11-
<testsuite name="phpCAS Tests">
12-
<directory>test/CAS/Tests/</directory>
13-
</testsuite>
14-
</testsuites>
15-
16-
<filter>
17-
<whitelist addUncoveredFilesFromWhitelist="false">
18-
<directory>source/</directory>
19-
</whitelist>
20-
</filter>
2+
<phpunit xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" bootstrap="source/CAS.php" convertNoticesToExceptions="false" colors="true" stderr="true" backupGlobals="true" xsi:noNamespaceSchemaLocation="https://schema.phpunit.de/9.3/phpunit.xsd">
3+
<coverage includeUncoveredFiles="false">
4+
<include>
5+
<directory>source/</directory>
6+
</include>
7+
</coverage>
8+
<testsuites>
9+
<testsuite name="phpCAS Tests">
10+
<directory>test/CAS/Tests/</directory>
11+
</testsuite>
12+
</testsuites>
2113
</phpunit>

Diff for: test/CAS/Tests/AuthenticationTest.php

+3-8
Original file line numberDiff line numberDiff line change
@@ -53,10 +53,8 @@ class AuthenticationTest extends TestCase
5353
/**
5454
* Sets up the fixture, for example, opens a network connection.
5555
* This method is called before a test is executed.
56-
*
57-
* @return void
5856
*/
59-
protected function setUp()
57+
protected function setUp(): void
6058
{
6159
// phpCAS::setDebug(dirname(__FILE__).'/../test.log');
6260
// error_reporting(E_ALL);
@@ -118,10 +116,8 @@ protected function setUp()
118116
/**
119117
* Tears down the fixture, for example, closes a network connection.
120118
* This method is called after a test is executed.
121-
*
122-
* @return void
123119
*/
124-
protected function tearDown()
120+
protected function tearDown(): void
125121
{
126122
DummyRequest::clearResponses();
127123
$_SESSION = array();
@@ -131,12 +127,11 @@ protected function tearDown()
131127
* Test that the user is redirected to the CAS server
132128
*
133129
* @return void
134-
*
135-
* @expectedException CAS_GracefullTerminationException
136130
*/
137131
public function testRedirect()
138132
{
139133
ob_start();
134+
$this->expectException(\CAS_GracefullTerminationException::class);
140135
try {
141136
$this->object->forceAuthentication();
142137
} catch (\Exception $e) {

Diff for: test/CAS/Tests/CallbackTest.php

+1-3
Original file line numberDiff line numberDiff line change
@@ -56,10 +56,8 @@ class CallbackTest extends TestCase
5656

5757
/**
5858
* Set up CAS_Client ReflectionClass
59-
*
60-
* @return void
6159
*/
62-
public static function setUpBeforeClass()
60+
public static function setUpBeforeClass(): void
6361
{
6462
\CAS_GracefullTerminationException::throwInsteadOfExiting();
6563

Diff for: test/CAS/Tests/Cas20AttributesTest.php

+5-9
Original file line numberDiff line numberDiff line change
@@ -53,10 +53,8 @@ class Cas20AttributesTest extends TestCase
5353
/**
5454
* Sets up the fixture, for example, opens a network connection.
5555
* This method is called before a test is executed.
56-
*
57-
* @return void
5856
*/
59-
protected function setUp()
57+
protected function setUp(): void
6058
{
6159
$_SERVER['SERVER_NAME'] = 'www.service.com';
6260
$_SERVER['SERVER_PORT'] = '80';
@@ -85,10 +83,8 @@ protected function setUp()
8583
/**
8684
* Tears down the fixture, for example, closes a network connection.
8785
* This method is called after a test is executed.
88-
*
89-
* @return void
9086
*/
91-
protected function tearDown()
87+
protected function tearDown(): void
9288
{
9389
DummyRequest::clearResponses();
9490
}
@@ -332,7 +328,7 @@ public function testNameValueAttributes()
332328
public function validateUserAttributes()
333329
{
334330
$attras = $this->object->getAttributes();
335-
$this->assertInternalType('array', $attras);
331+
$this->assertIsArray($attras);
336332

337333
if (count($attras) != 4 || !is_array($attras['memberOf'])) {
338334
print "\n";
@@ -358,7 +354,7 @@ public function validateUserAttributes()
358354
$this->assertTrue($this->object->hasAttribute('memberOf'));
359355
// direct access
360356
$memberOf = $this->object->getAttribute('memberOf');
361-
$this->assertInternalType('array', $memberOf);
357+
$this->assertIsArray($memberOf);
362358
$this->assertEquals(2, count($memberOf));
363359
$this->assertTrue(
364360
in_array('CN=Staff,OU=Groups,DC=example,DC=edu', $memberOf)
@@ -371,7 +367,7 @@ public function validateUserAttributes()
371367
);
372368
// array access
373369
$this->assertArrayHasKey('memberOf', $attras);
374-
$this->assertInternalType('array', $attras['memberOf']);
370+
$this->assertIsArray($attras['memberOf']);
375371
$this->assertEquals(2, count($attras['memberOf']));
376372
$this->assertTrue(
377373
in_array('CN=Staff,OU=Groups,DC=example,DC=edu', $attras['memberOf'])

Diff for: test/CAS/Tests/CookieJarTest.php

+18-20
Original file line numberDiff line numberDiff line change
@@ -87,7 +87,7 @@ class CookieJarTest extends TestCase
8787
*
8888
* @return void
8989
*/
90-
protected function setUp()
90+
protected function setUp(): void
9191
{
9292
$this->cookieArray = array();
9393
$this->object = new CookieJarExposed($this->cookieArray);
@@ -127,10 +127,8 @@ protected function setUp()
127127
/**
128128
* Tears down the fixture, for example, closes a network connection.
129129
* This method is called after a test is executed.
130-
*
131-
* @return void
132130
*/
133-
protected function tearDown()
131+
protected function tearDown(): void
134132
{
135133

136134
}
@@ -542,7 +540,7 @@ public function testPublicStoreCookiesHttponly()
542540

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

545-
$this->assertInternalType('array', $cookies);
543+
$this->assertIsArray($cookies);
546544
$this->assertEquals('hello world', $cookies['SID']);
547545
$this->assertEquals(
548546
1, count($cookies),
@@ -564,7 +562,7 @@ public function testPublicStoreCookiesComment()
564562

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

567-
$this->assertInternalType('array', $cookies);
565+
$this->assertIsArray($cookies);
568566
$this->assertEquals('hello world', $cookies['SID']);
569567
$this->assertEquals(
570568
1, count($cookies),
@@ -612,7 +610,7 @@ public function testPublicStoreCookiesQuotedEquals()
612610

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

615-
$this->assertInternalType('array', $cookies);
613+
$this->assertIsArray($cookies);
616614
$this->assertEquals(
617615
'hello=world', $cookies['SID'],
618616
"\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."
@@ -634,7 +632,7 @@ public function testPublicStoreCookiesQuotedEscapedQuote()
634632

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

637-
$this->assertInternalType('array', $cookies);
635+
$this->assertIsArray($cookies);
638636
$this->assertEquals('hello"world', $cookies['SID']);
639637
$this->assertEquals(1, count($cookies));
640638
}
@@ -658,7 +656,7 @@ public function testProtectedParseCookieHeaders()
658656
$this->responseHeaders_1, 'service.example.com'
659657
);
660658

661-
$this->assertInternalType('array', $cookies);
659+
$this->assertIsArray($cookies);
662660
$this->assertEquals(1, count($cookies));
663661
$this->assertEquals('SID', $cookies[0]['name']);
664662
$this->assertEquals('k1jut1r1bqrumpei837kk4jks0', $cookies[0]['value']);
@@ -680,7 +678,7 @@ public function testProtectedParseCookieHeadersWithDomain()
680678
$cookies = $this->object
681679
->parseCookieHeaders($headers, 'service.example.com');
682680

683-
$this->assertInternalType('array', $cookies);
681+
$this->assertIsArray($cookies);
684682
$this->assertEquals(1, count($cookies));
685683
$this->assertEquals('SID', $cookies[0]['name']);
686684
$this->assertEquals('k1jut1r1bqrumpei837kk4jks0', $cookies[0]['value']);
@@ -702,7 +700,7 @@ public function testProtectedParseCookieHeadersWithHostname()
702700
$cookies = $this->object
703701
->parseCookieHeaders($headers, 'service.example.com');
704702

705-
$this->assertInternalType('array', $cookies);
703+
$this->assertIsArray($cookies);
706704
$this->assertEquals(1, count($cookies));
707705
$this->assertEquals('SID', $cookies[0]['name']);
708706
$this->assertEquals('k1jut1r1bqrumpei837kk4jks0', $cookies[0]['value']);
@@ -724,7 +722,7 @@ public function testProtectedParseCookieHeadersNonDefaultHostname()
724722
$cookies = $this->object
725723
->parseCookieHeaders($headers, 'service.example.com');
726724

727-
$this->assertInternalType('array', $cookies);
725+
$this->assertIsArray($cookies);
728726
$this->assertEquals(1, count($cookies));
729727
$this->assertEquals('SID', $cookies[0]['name']);
730728
$this->assertEquals('k1jut1r1bqrumpei837kk4jks0', $cookies[0]['value']);
@@ -746,7 +744,7 @@ public function testProtectedParseCookieHeadersWithPath()
746744
$cookies = $this->object
747745
->parseCookieHeaders($headers, 'service.example.com');
748746

749-
$this->assertInternalType('array', $cookies);
747+
$this->assertIsArray($cookies);
750748
$this->assertEquals(1, count($cookies));
751749
$this->assertEquals('SID', $cookies[0]['name']);
752750
$this->assertEquals('k1jut1r1bqrumpei837kk4jks0', $cookies[0]['value']);
@@ -768,7 +766,7 @@ public function testProtectedParseCookieHeadersSecure()
768766
$cookies = $this->object
769767
->parseCookieHeaders($headers, 'service.example.com');
770768

771-
$this->assertInternalType('array', $cookies);
769+
$this->assertIsArray($cookies);
772770
$this->assertEquals(1, count($cookies));
773771
$this->assertEquals('SID', $cookies[0]['name']);
774772
$this->assertEquals('k1jut1r1bqrumpei837kk4jks0', $cookies[0]['value']);
@@ -790,7 +788,7 @@ public function testProtectedParseCookieHeadersSecureLC()
790788
$cookies = $this->object
791789
->parseCookieHeaders($headers, 'service.example.com');
792790

793-
$this->assertInternalType('array', $cookies);
791+
$this->assertIsArray($cookies);
794792
$this->assertEquals(1, count($cookies));
795793
$this->assertEquals('SID', $cookies[0]['name']);
796794
$this->assertEquals('k1jut1r1bqrumpei837kk4jks0', $cookies[0]['value']);
@@ -810,7 +808,7 @@ public function testProtectedParseCookieHeadersTrailingSemicolon()
810808
$cookies = $this->object
811809
->parseCookieHeaders($headers, 'service.example.com');
812810

813-
$this->assertInternalType('array', $cookies);
811+
$this->assertIsArray($cookies);
814812
$this->assertEquals(1, count($cookies));
815813
$this->assertEquals('SID', $cookies[0]['name']);
816814
$this->assertEquals('hello world', $cookies[0]['value']);
@@ -827,7 +825,7 @@ public function testProtectedParseCookieHeadersTrailingSemicolon()
827825
public function testProtectedSetCookie()
828826
{
829827
$cookies = $this->object->getCookies($this->serviceUrl_1c);
830-
$this->assertInternalType('array', $cookies);
828+
$this->assertIsArray($cookies);
831829
$this->assertEquals(1, count($cookies));
832830
$this->assertEquals('k1jut1r1bqrumpei837kk4jks0', $cookies['SID']);
833831
}
@@ -850,7 +848,7 @@ public function testProtectedStoreCookieWithDuplicates()
850848
$this->object->storeCookie($cookiesToSet[0]);
851849

852850
$cookies = $this->object->getCookies($this->serviceUrl_1c);
853-
$this->assertInternalType('array', $cookies);
851+
$this->assertIsArray($cookies);
854852
$this->assertEquals(1, count($cookies));
855853
$this->assertEquals('goodbye world', $cookies['SID']);
856854
}
@@ -869,7 +867,7 @@ public function testProtectedStoreCookieTwoCookies()
869867
$this->object->storeCookie($cookiesToSet[0]);
870868

871869
$cookies = $this->object->getCookies($this->serviceUrl_1c);
872-
$this->assertInternalType('array', $cookies);
870+
$this->assertIsArray($cookies);
873871
$this->assertEquals(2, count($cookies));
874872
$this->assertEquals('k1jut1r1bqrumpei837kk4jks0', $cookies['SID']);
875873
$this->assertEquals('hello world', $cookies['message']);
@@ -892,7 +890,7 @@ public function testProtectedStoreCookieTwoCookiesOneAtDomain()
892890
$this->object->storeCookie($cookiesToSet[0]);
893891

894892
$cookies = $this->object->getCookies($this->serviceUrl_1c);
895-
$this->assertInternalType('array', $cookies);
893+
$this->assertIsArray($cookies);
896894
$this->assertEquals(2, count($cookies));
897895
$this->assertEquals('k1jut1r1bqrumpei837kk4jks0', $cookies['SID']);
898896
$this->assertEquals('hello world', $cookies['message']);

Diff for: test/CAS/Tests/LogTest.php

+3-3
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ class LogTest extends TestCase
1919
*/
2020
private $logger;
2121

22-
public function setUp()
22+
public function setUp(): void
2323
{
2424
parent::setUp();
2525
$this->logPath = tempnam(sys_get_temp_dir(), 'phpCAS');
@@ -31,7 +31,7 @@ public function setUp()
3131
$this->logger->pushHandler($handler);
3232
}
3333

34-
public function tearDown()
34+
public function tearDown(): void
3535
{
3636
unlink($this->logPath);
3737
parent::tearDown();
@@ -56,7 +56,7 @@ public function testSetLogger()
5656
// EOF
5757
$lines = explode("\n", $contents);
5858
$this->assertCount(5, $lines);
59-
$this->assertContains('Session is not authenticated', $lines[2]);
59+
$this->assertStringContainsString('Session is not authenticated', $lines[2]);
6060
}
6161

6262
public function testSetLoggerNull()

Diff for: test/CAS/Tests/MultiRequestTest.php

+2-6
Original file line numberDiff line numberDiff line change
@@ -54,10 +54,8 @@ class MultiRequestTest extends TestCase
5454
/**
5555
* Sets up the fixture, for example, opens a network connection.
5656
* This method is called before a test is executed.
57-
*
58-
* @return void
5957
*/
60-
protected function setUp()
58+
protected function setUp(): void
6159
{
6260

6361
/*********************************************************
@@ -119,10 +117,8 @@ protected function setUp()
119117
/**
120118
* Tears down the fixture, for example, closes a network connection.
121119
* This method is called after a test is executed.
122-
*
123-
* @return void
124120
*/
125-
protected function tearDown()
121+
protected function tearDown(): void
126122
{
127123
DummyRequest::clearResponses();
128124
}

Diff for: test/CAS/Tests/ProxyChainsTest.php

+2-6
Original file line numberDiff line numberDiff line change
@@ -51,10 +51,8 @@ class ProxyChainsTest extends TestCase
5151
/**
5252
* Sets up the fixture, for example, opens a network connection.
5353
* This method is called before a test is executed.
54-
*
55-
* @return void
5654
*/
57-
protected function setUp()
55+
protected function setUp(): void
5856
{
5957
$this->object = new \CAS_ProxyChain_AllowedList;
6058
$this->list_size_0 = array();
@@ -76,10 +74,8 @@ protected function setUp()
7674
/**
7775
* Tears down the fixture, for example, closes a network connection.
7876
* This method is called after a test is executed.
79-
*
80-
* @return void
8177
*/
82-
protected function tearDown()
78+
protected function tearDown(): void
8379
{
8480

8581
}

0 commit comments

Comments
 (0)