Skip to content

Commit d16f857

Browse files
authored
Support php8 (#257)
1 parent e75e571 commit d16f857

15 files changed

+100
-134
lines changed

.gitignore

+1
Original file line numberDiff line numberDiff line change
@@ -2,3 +2,4 @@ composer.lock
22
phpunit.xml
33
tests/config.php
44
vendor
5+
.phpunit.result.cache

.travis.yml

+2
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,8 @@ matrix:
1313
env: INSTALL_LIBSODIUM=false
1414
- php: 7.4
1515
env: INSTALL_LIBSODIUM=false
16+
- php: nightly
17+
env: INSTALL_LIBSODIUM=false
1618
dist: bionic
1719
install: ./scripts/travis-install.sh
1820
script: vendor/bin/phpunit --testsuite unit

README.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ This library depends on PHP modules for cURL and JSON. See [cURL module installa
3232

3333
## Supported platforms
3434

35-
* PHP - supports PHP versions 7.1, 7.2, 7.3 and 7.4.
35+
* PHP - supports PHP versions 7.1, 7.2, 7.3, 7.4 and 8.0.
3636
* Laravel - version 5.3 and above has built-in support for Pusher Channels as a [Broadcasting backend](https://laravel.com/docs/master/broadcasting).
3737
* Other PHP frameworks - supported provided you are using a supported version of PHP.
3838

composer.json

+2-2
Original file line numberDiff line numberDiff line change
@@ -4,13 +4,13 @@
44
"keywords": ["php-pusher-server", "pusher", "rest", "realtime", "real-time", "real time", "messaging", "push", "trigger", "publish", "events"],
55
"license": "MIT",
66
"require": {
7-
"php": "^7.1",
7+
"php": "^7.1|^8.0",
88
"ext-curl": "*",
99
"psr/log": "^1.0",
1010
"paragonie/sodium_compat": "^1.6"
1111
},
1212
"require-dev": {
13-
"phpunit/phpunit": "^7.2"
13+
"phpunit/phpunit": "^7.2|^8.5|^9.3"
1414
},
1515
"autoload": {
1616
"psr-4": {

tests/acceptance/channelQueryTest.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
class PusherChannelQueryTest extends PHPUnit\Framework\TestCase
44
{
5-
protected function setUp()
5+
protected function setUp(): void
66
{
77
$this->pusher = new Pusher\Pusher(PUSHERAPP_AUTHKEY, PUSHERAPP_SECRET, PUSHERAPP_APPID, true, PUSHERAPP_HOST);
88
$this->pusher->setLogger(new TestLogger());

tests/acceptance/triggerBatchTest.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
class PusherBatchPushTest extends PHPUnit\Framework\TestCase
44
{
5-
protected function setUp()
5+
protected function setUp(): void
66
{
77
if (PUSHERAPP_AUTHKEY === '' || PUSHERAPP_SECRET === '' || PUSHERAPP_APPID === '') {
88
$this->markTestSkipped('Please set the

tests/acceptance/triggerTest.php

+5-7
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
class PusherPushTest extends PHPUnit\Framework\TestCase
44
{
5-
protected function setUp()
5+
protected function setUp(): void
66
{
77
if (PUSHERAPP_AUTHKEY === '' || PUSHERAPP_SECRET === '' || PUSHERAPP_APPID === '') {
88
$this->markTestSkipped('Please set the
@@ -52,11 +52,10 @@ public function testSendingOver10kBMessageReturns413()
5252
$this->assertEquals(413, $response['status'], '413 HTTP status response expected');
5353
}
5454

55-
/**
56-
* @expectedException \Pusher\PusherException
57-
*/
5855
public function testTriggeringEventOnOver100ChannelsThrowsException()
5956
{
57+
$this->expectException(\Pusher\PusherException::class);
58+
6059
$channels = array();
6160
while (count($channels) <= 101) {
6261
$channels[] = ('channel-'.count($channels));
@@ -86,11 +85,10 @@ public function testTriggeringEventOnPrivateEncryptedChannelSuccess()
8685
$this->assertTrue($response);
8786
}
8887

89-
/**
90-
* @expectedException \Pusher\PusherException
91-
*/
9288
public function testTriggeringEventOnMultipleChannelsWithEncryptedChannelPresentError()
9389
{
90+
$this->expectException(\Pusher\PusherException::class);
91+
9492
$options = array('encryption_master_key' => 'cAzRH3W9FZM3iXqSNIGtKztwNuCz9xMV');
9593
$this->pusher = new Pusher\Pusher(PUSHERAPP_AUTHKEY, PUSHERAPP_SECRET, PUSHERAPP_APPID, $options, PUSHERAPP_HOST);
9694

tests/unit/authQueryStringTest.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
class PusherAuthQueryString extends PHPUnit\Framework\TestCase
44
{
5-
protected function setUp()
5+
protected function setUp(): void
66
{
77
$this->pusher = new Pusher\Pusher('thisisaauthkey', 'thisisasecret', 1, true);
88
}

tests/unit/channelInfoUnitTest.php

+9-13
Original file line numberDiff line numberDiff line change
@@ -2,40 +2,36 @@
22

33
class PusherChannelInfoUnitTest extends PHPUnit\Framework\TestCase
44
{
5-
protected function setUp()
5+
protected function setUp(): void
66
{
77
$this->pusher = new Pusher\Pusher('thisisaauthkey', 'thisisasecret', 1, true);
88
}
99

10-
/**
11-
* @expectedException \Pusher\PusherException
12-
*/
1310
public function testTrailingColonChannelThrowsException()
1411
{
12+
$this->expectException(\Pusher\PusherException::class);
13+
1514
$this->pusher->get_channel_info('test_channel:');
1615
}
1716

18-
/**
19-
* @expectedException \Pusher\PusherException
20-
*/
2117
public function testLeadingColonChannelThrowsException()
2218
{
19+
$this->expectException(\Pusher\PusherException::class);
20+
2321
$this->pusher->get_channel_info(':test_channel');
2422
}
2523

26-
/**
27-
* @expectedException \Pusher\PusherException
28-
*/
2924
public function testLeadingColonNLChannelThrowsException()
3025
{
26+
$this->expectException(\Pusher\PusherException::class);
27+
3128
$this->pusher->get_channel_info(':\ntest_channel');
3229
}
3330

34-
/**
35-
* @expectedException \Pusher\PusherException
36-
*/
3731
public function testTrailingColonNLChannelThrowsException()
3832
{
33+
$this->expectException(\Pusher\PusherException::class);
34+
3935
$this->pusher->get_channel_info('test_channel\n:');
4036
}
4137
}

tests/unit/cryptoTest.php

+27-37
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
class PusherCryptoTest extends PHPUnit\Framework\TestCase
44
{
5-
protected function setUp()
5+
protected function setUp(): void
66
{
77
if (function_exists('sodium_crypto_secretbox')) {
88
$this->crypto = new Pusher\PusherCrypto('aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa');
@@ -24,57 +24,51 @@ public function testValidMasterEncryptionKeys()
2424
$this->assertEquals(Pusher\PusherCrypto::parse_master_key('', 'dGhpcyBrZXkgaGFzIG5vbnByaW50YWJsZSBjaGFyIAA='), "this key has nonprintable char \x00");
2525
}
2626

27-
/**
28-
* @expectedException \Pusher\PusherException
29-
* @expectedExceptionMessage both
30-
*/
3127
public function testInvalidMasterEncryptionKeyTwoProvided()
3228
{
29+
$this->expectException(\Pusher\PusherException::class);
30+
$this->expectExceptionMessage('both');
31+
3332
Pusher\PusherCrypto::parse_master_key('this is 32 bytes 123456789012345', 'dGhpcyBpcyAzMiBieXRlcyAxMjM0NTY3ODkwMTIzNDU=');
3433
}
3534

36-
/**
37-
* @expectedException \Pusher\PusherException
38-
* @expectedExceptionMessage 32 bytes
39-
*/
4035
public function testInvalidMasterEncryptionKeyTooShort()
4136
{
37+
$this->expectException(\Pusher\PusherException::class);
38+
$this->expectExceptionMessage('32 bytes');
39+
4240
Pusher\PusherCrypto::parse_master_key('this is 31 bytes 12345678901234', '');
4341
}
4442

45-
/**
46-
* @expectedException \Pusher\PusherException
47-
* @expectedExceptionMessage 32 bytes
48-
*/
4943
public function testInvalidMasterEncryptionKeyTooLong()
5044
{
45+
$this->expectException(\Pusher\PusherException::class);
46+
$this->expectExceptionMessage('32 bytes');
47+
5148
Pusher\PusherCrypto::parse_master_key('this is 33 bytes 1234567890123456', '');
5249
}
5350

54-
/**
55-
* @expectedException \Pusher\PusherException
56-
* @expectedExceptionMessage 32 bytes
57-
*/
5851
public function testInvalidMasterEncryptionKeyBase64TooShort()
5952
{
53+
$this->expectException(\Pusher\PusherException::class);
54+
$this->expectExceptionMessage('32 bytes');
55+
6056
Pusher\PusherCrypto::parse_master_key('', 'dGhpcyBpcyAzMSBieXRlcyAxMjM0NTY3ODkwMTIzNA==');
6157
}
6258

63-
/**
64-
* @expectedException \Pusher\PusherException
65-
* @expectedExceptionMessage 32 bytes
66-
*/
6759
public function testInvalidMasterEncryptionKeyBase64TooLong()
6860
{
61+
$this->expectException(\Pusher\PusherException::class);
62+
$this->expectExceptionMessage('32 bytes');
63+
6964
Pusher\PusherCrypto::parse_master_key('', 'dGhpcyBpcyAzMyBieXRlcyAxMjM0NTY3ODkwMTIzNDU2');
7065
}
7166

72-
/**
73-
* @expectedException \Pusher\PusherException
74-
* @expectedExceptionMessage valid base64
75-
*/
7667
public function testInvalidMasterEncryptionKeyBase64InvalidBase64()
7768
{
69+
$this->expectException(\Pusher\PusherException::class);
70+
$this->expectExceptionMessage('valid base64');
71+
7872
Pusher\PusherCrypto::parse_master_key('', 'dGhpcyBpcyAzMyBi!XRlcyAxMjM0NTY3ODkw#TIzNDU2');
7973
}
8074

@@ -92,11 +86,10 @@ public function testGenerateSharedSecret()
9286
$this->assertNotEquals(base64_encode($crypto2->generate_shared_secret('private-encrypted-channel-a')), $expected);
9387
}
9488

95-
/**
96-
* @expectedException \Pusher\PusherException
97-
*/
9889
public function testGenerateSharedSecretNoChannel()
9990
{
91+
$this->expectException(\Pusher\PusherException::class);
92+
10093
$this->crypto->generate_shared_secret('');
10194
}
10295

@@ -123,33 +116,30 @@ public function testEncryptDecryptEventValid()
123116
$this->assertEquals($decrypted_payload, $payload);
124117
}
125118

126-
/**
127-
* @expectedException \Pusher\PusherException
128-
*/
129119
public function testEncryptPayloadNoChannel()
130120
{
121+
$this->expectException(\Pusher\PusherException::class);
122+
131123
$channel = '';
132124
$payload = "now that's what I call a payload!";
133125
$encrypted_payload = $this->crypto->encrypt_payload($channel, $payload);
134126
$this->assertEquals($encrypted_payload, false);
135127
}
136128

137-
/**
138-
* @expectedException \Pusher\PusherException
139-
*/
140129
public function testEncryptPayloadPublicChannel()
141130
{
131+
$this->expectException(\Pusher\PusherException::class);
132+
142133
$channel = 'public-static-void-main';
143134
$payload = "now that's what I call a payload!";
144135
$encrypted_payload = $this->crypto->encrypt_payload($channel, $payload);
145136
$this->assertEquals($encrypted_payload, false);
146137
}
147138

148-
/**
149-
* @expectedException \Pusher\PusherException
150-
*/
151139
public function testDecryptPayloadWrongKey()
152140
{
141+
$this->expectException(\Pusher\PusherException::class);
142+
153143
$channel = 'private-encrypted-bla';
154144
$payload = "now that's what I call a payload!";
155145
$encrypted_payload = $this->crypto->encrypt_payload($channel, $payload);

tests/unit/notificationsTest.php

+3-4
Original file line numberDiff line numberDiff line change
@@ -2,16 +2,15 @@
22

33
class PusherNotificationsUnitTest extends PHPUnit\Framework\TestCase
44
{
5-
protected function setUp()
5+
protected function setUp(): void
66
{
77
$this->pusher = new Pusher\Pusher('thisisaauthkey', 'thisisasecret', 1);
88
}
99

10-
/**
11-
* @expectedException \Pusher\PusherException
12-
*/
1310
public function testInvalidEmptyInterests()
1411
{
12+
$this->expectException(\Pusher\PusherException::class);
13+
1514
$this->pusher->notify(array(), array('foo' => 'bar'));
1615
}
1716
}

tests/unit/pusherConstructorTest.php

-4
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,6 @@
22

33
class pusherConstructorTest extends PHPUnit\Framework\TestCase
44
{
5-
protected function setUp()
6-
{
7-
}
8-
95
public function testDebugCanBeSetViaLegacyParameter()
106
{
117
$pusher = new Pusher\Pusher('app_key', 'app_secret', 'app_id', true);

0 commit comments

Comments
 (0)