From 10664aede9945cf17b7213bea865aabe8fec7866 Mon Sep 17 00:00:00 2001 From: Sean Molenaar Date: Fri, 8 Nov 2024 11:15:43 +0100 Subject: [PATCH] chore: update PHPUnit to latest version --- .github/workflows/php-tests.yml | 5 ++- .../CustomMessageGetPayloadDictionaryTest.php | 2 +- .../Message/Tests/CustomMessageGetTest.php | 2 +- ...sageTest.php => CustomMessageTestBase.php} | 2 +- .../SafariMessageGetPayloadDictionaryTest.php | 2 +- .../Message/Tests/SafariMessageGetTest.php | 2 +- ...sageTest.php => SafariMessageTestBase.php} | 2 +- ApnsPHP/Push.php | 2 +- ApnsPHP/Tests/MessageAddRecipientTest.php | 2 +- .../Tests/MessageGetPayloadDictionaryTest.php | 2 +- ApnsPHP/Tests/MessageGetPayloadTest.php | 4 +-- ApnsPHP/Tests/MessageGetTest.php | 2 +- ApnsPHP/Tests/MessageSelfForRecipientTest.php | 6 ++-- ApnsPHP/Tests/MessageSetTest.php | 10 +++--- .../{MessageTest.php => MessageTestBase.php} | 2 +- ApnsPHP/Tests/PushAddTest.php | 32 +++++++++++-------- ApnsPHP/Tests/PushConnectTest.php | 13 +++----- ApnsPHP/Tests/PushDisconnectTest.php | 2 +- ApnsPHP/Tests/PushGetTest.php | 2 +- ApnsPHP/Tests/PushHttpInitTest.php | 12 +++---- ApnsPHP/Tests/PushHttpSendTest.php | 28 ++++++++-------- ApnsPHP/Tests/PushInvalidTest.php | 2 +- .../Tests/PushRemoveMessageFromQueueTest.php | 2 +- ApnsPHP/Tests/PushSendTest.php | 18 +++++------ ApnsPHP/Tests/PushSetTest.php | 2 +- .../Tests/{PushTest.php => PushTestBase.php} | 4 +-- ApnsPHP/Tests/PushUpdateQueueTest.php | 10 +++--- composer.json | 2 +- 28 files changed, 89 insertions(+), 87 deletions(-) rename ApnsPHP/Message/Tests/{CustomMessageTest.php => CustomMessageTestBase.php} (94%) rename ApnsPHP/Message/Tests/{SafariMessageTest.php => SafariMessageTestBase.php} (94%) rename ApnsPHP/Tests/{MessageTest.php => MessageTestBase.php} (94%) rename ApnsPHP/Tests/{PushTest.php => PushTestBase.php} (94%) diff --git a/.github/workflows/php-tests.yml b/.github/workflows/php-tests.yml index cbc048e2..be315f2a 100644 --- a/.github/workflows/php-tests.yml +++ b/.github/workflows/php-tests.yml @@ -25,8 +25,7 @@ jobs: uses: shivammathur/setup-php@v2 with: php-version: ${{ matrix.php-versions }} - extensions: uopz - tools: phpunit:9.5.x + extensions: uopz,mbstring - name: Setup problem matchers for PHP run: echo "::add-matcher::${{ runner.tool_cache }}/php.json" @@ -45,7 +44,7 @@ jobs: chmod 000 server_certificates_bundle_unreadable.pem - name: Run PHPUnit - run: phpunit -c phpunit.xml + run: ./vendor/bin/phpunit -c phpunit.xml sample_push: runs-on: ubuntu-latest diff --git a/ApnsPHP/Message/Tests/CustomMessageGetPayloadDictionaryTest.php b/ApnsPHP/Message/Tests/CustomMessageGetPayloadDictionaryTest.php index a370cda0..332ca93c 100644 --- a/ApnsPHP/Message/Tests/CustomMessageGetPayloadDictionaryTest.php +++ b/ApnsPHP/Message/Tests/CustomMessageGetPayloadDictionaryTest.php @@ -15,7 +15,7 @@ * * @covers \ApnsPHP\Message\CustomMessage */ -class CustomMessageGetPayloadDictionaryTest extends CustomMessageTest +class CustomMessageGetPayloadDictionaryTest extends CustomMessageTestBase { /** * Test that getPayloadDictionary returns complete payload with body if locKey isn't set diff --git a/ApnsPHP/Message/Tests/CustomMessageGetTest.php b/ApnsPHP/Message/Tests/CustomMessageGetTest.php index 1dc17809..d7b11146 100644 --- a/ApnsPHP/Message/Tests/CustomMessageGetTest.php +++ b/ApnsPHP/Message/Tests/CustomMessageGetTest.php @@ -14,7 +14,7 @@ * * @covers \ApnsPHP\Message\CustomMessage */ -class CustomMessageGetTest extends CustomMessageTest +class CustomMessageGetTest extends CustomMessageTestBase { /** * Test that getActionLocKey() gets the view button title. diff --git a/ApnsPHP/Message/Tests/CustomMessageTest.php b/ApnsPHP/Message/Tests/CustomMessageTestBase.php similarity index 94% rename from ApnsPHP/Message/Tests/CustomMessageTest.php rename to ApnsPHP/Message/Tests/CustomMessageTestBase.php index 66643003..2d2d85c2 100644 --- a/ApnsPHP/Message/Tests/CustomMessageTest.php +++ b/ApnsPHP/Message/Tests/CustomMessageTestBase.php @@ -20,7 +20,7 @@ * * @covers \ApnsPHP\Message\CustomMessage */ -abstract class CustomMessageTest extends LunrBaseTest +abstract class CustomMessageTestBase extends LunrBaseTest { /** * Class to test diff --git a/ApnsPHP/Message/Tests/SafariMessageGetPayloadDictionaryTest.php b/ApnsPHP/Message/Tests/SafariMessageGetPayloadDictionaryTest.php index 371245cb..69abae83 100644 --- a/ApnsPHP/Message/Tests/SafariMessageGetPayloadDictionaryTest.php +++ b/ApnsPHP/Message/Tests/SafariMessageGetPayloadDictionaryTest.php @@ -15,7 +15,7 @@ * * @covers \ApnsPHP\Message\SafariMessage */ -class SafariMessageGetPayloadDictionaryTest extends SafariMessageTest +class SafariMessageGetPayloadDictionaryTest extends SafariMessageTestBase { /** * Test that getPayloadDictionary returns complete payload diff --git a/ApnsPHP/Message/Tests/SafariMessageGetTest.php b/ApnsPHP/Message/Tests/SafariMessageGetTest.php index 4c00d132..0d8ef30b 100644 --- a/ApnsPHP/Message/Tests/SafariMessageGetTest.php +++ b/ApnsPHP/Message/Tests/SafariMessageGetTest.php @@ -14,7 +14,7 @@ * * @covers \ApnsPHP\Message\SafariMessage */ -class SafariMessageGetTest extends SafariMessageTest +class SafariMessageGetTest extends SafariMessageTestBase { /** * Test that getAction() gets the label of the action button. diff --git a/ApnsPHP/Message/Tests/SafariMessageTest.php b/ApnsPHP/Message/Tests/SafariMessageTestBase.php similarity index 94% rename from ApnsPHP/Message/Tests/SafariMessageTest.php rename to ApnsPHP/Message/Tests/SafariMessageTestBase.php index 4449c289..2208ee30 100644 --- a/ApnsPHP/Message/Tests/SafariMessageTest.php +++ b/ApnsPHP/Message/Tests/SafariMessageTestBase.php @@ -20,7 +20,7 @@ * * @covers \ApnsPHP\Message\SafariMessage */ -abstract class SafariMessageTest extends LunrBaseTest +abstract class SafariMessageTestBase extends LunrBaseTest { /** * Class to test diff --git a/ApnsPHP/Push.php b/ApnsPHP/Push.php index 96c53998..1be02b29 100644 --- a/ApnsPHP/Push.php +++ b/ApnsPHP/Push.php @@ -470,7 +470,7 @@ protected function getJsonWebToken(): string public function add(Message $message): void { $messagePayload = $message->getPayload(); - $recipients = $message->getRecipientsNumber(); + $recipients = $message->getRecipientsCount(); $messageQueueLen = count($this->messageQueue); for ($i = 0; $i < $recipients; $i++) { diff --git a/ApnsPHP/Tests/MessageAddRecipientTest.php b/ApnsPHP/Tests/MessageAddRecipientTest.php index 922502a4..646d3457 100644 --- a/ApnsPHP/Tests/MessageAddRecipientTest.php +++ b/ApnsPHP/Tests/MessageAddRecipientTest.php @@ -15,7 +15,7 @@ * * @covers \ApnsPHP\Message */ -class MessageAddRecipientTest extends MessageTest +class MessageAddRecipientTest extends MessageTestBase { /** * Test that addRecipient throws exception on invalid token diff --git a/ApnsPHP/Tests/MessageGetPayloadDictionaryTest.php b/ApnsPHP/Tests/MessageGetPayloadDictionaryTest.php index 1a489a0b..1a651f90 100644 --- a/ApnsPHP/Tests/MessageGetPayloadDictionaryTest.php +++ b/ApnsPHP/Tests/MessageGetPayloadDictionaryTest.php @@ -15,7 +15,7 @@ * * @covers \ApnsPHP\Message */ -class MessageGetPayloadDictionaryTest extends MessageTest +class MessageGetPayloadDictionaryTest extends MessageTestBase { /** * Test that getPayloadDictionary returns complete payload diff --git a/ApnsPHP/Tests/MessageGetPayloadTest.php b/ApnsPHP/Tests/MessageGetPayloadTest.php index 1252ec4e..76e453d2 100644 --- a/ApnsPHP/Tests/MessageGetPayloadTest.php +++ b/ApnsPHP/Tests/MessageGetPayloadTest.php @@ -15,7 +15,7 @@ * * @covers \ApnsPHP\Message */ -class MessageGetPayloadTest extends MessageTest +class MessageGetPayloadTest extends MessageTestBase { /** * Test that getPayload() returns complete JSON encoded payload @@ -161,7 +161,7 @@ public function testCastToStringReturnsEmptyStringOnTooLongPayloadWithoutAutoAdj * * @return string String of certain size in bytes */ - private function getLargeString($size): string + private function getLargeString(int $size): string { $characters = '0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ'; $length = strlen($characters); diff --git a/ApnsPHP/Tests/MessageGetTest.php b/ApnsPHP/Tests/MessageGetTest.php index 5a3f0fd6..202b5ade 100644 --- a/ApnsPHP/Tests/MessageGetTest.php +++ b/ApnsPHP/Tests/MessageGetTest.php @@ -17,7 +17,7 @@ * * @covers \ApnsPHP\Message */ -class MessageGetTest extends MessageTest +class MessageGetTest extends MessageTestBase { /** * Test that getText() gets the message text. diff --git a/ApnsPHP/Tests/MessageSelfForRecipientTest.php b/ApnsPHP/Tests/MessageSelfForRecipientTest.php index 8c971d47..5ef15865 100644 --- a/ApnsPHP/Tests/MessageSelfForRecipientTest.php +++ b/ApnsPHP/Tests/MessageSelfForRecipientTest.php @@ -17,14 +17,14 @@ * * @covers \ApnsPHP\Message */ -class MessageSelfForRecipientTest extends MessageTest +class MessageSelfForRecipientTest extends MessageTestBase { /** * Test that selfForRecipient throws exception on invalid index * * @covers \ApnsPHP\Message::selfForRecipient */ - public function testselfForRecipientThrowsExceptionOnInvalidIndex(): void + public function testSelfForRecipientThrowsExceptionOnInvalidIndex(): void { $this->expectException('ApnsPHP\Exception'); $this->expectExceptionMessage('No recipient at index \'1\''); @@ -37,7 +37,7 @@ public function testselfForRecipientThrowsExceptionOnInvalidIndex(): void * * @covers \ApnsPHP\Message::selfForRecipient */ - public function testselfForRecipientGetsMessage(): void + public function testSelfForRecipientGetsMessage(): void { $token = '1e82db91c7ceddd72bf33d74ae052ac9c84a065b35148ac401388843106a7485'; $message = new Message($token); diff --git a/ApnsPHP/Tests/MessageSetTest.php b/ApnsPHP/Tests/MessageSetTest.php index 61f7b193..daad3b0d 100644 --- a/ApnsPHP/Tests/MessageSetTest.php +++ b/ApnsPHP/Tests/MessageSetTest.php @@ -17,14 +17,14 @@ * * @covers \ApnsPHP\Message */ -class MessageSetTest extends MessageTest +class MessageSetTest extends MessageTestBase { /** * Unit test data provider for reserved apple namespace keys. * * @return array Variations of the reserved apple namespace key */ - public function reservedAppleNamespaceKeyProvider(): array + public static function reservedAppleNamespaceKeyProvider(): array { $data = []; $data[] = [ 'aps' ]; @@ -40,7 +40,7 @@ public function reservedAppleNamespaceKeyProvider(): array * * @return array Variations of valid custom identifiers */ - public function validCustomIdentifierProvider(): array + public static function validCustomIdentifierProvider(): array { $data = []; $data[] = [ '3491ac4b-0681-4c92-8308-d8d8441f4e64' ]; @@ -54,7 +54,7 @@ public function validCustomIdentifierProvider(): array * * @return array Variations of a valid message priority */ - public function validPriorityProvider(): array + public static function validPriorityProvider(): array { $data = []; $data[] = [ Priority::PrioritizePowerUsage ]; @@ -69,7 +69,7 @@ public function validPriorityProvider(): array * * @return array Variations of a valid push type */ - public function validPushTypeProvider(): array + public static function validPushTypeProvider(): array { $data = []; $data[] = [ PushType::Alert ]; diff --git a/ApnsPHP/Tests/MessageTest.php b/ApnsPHP/Tests/MessageTestBase.php similarity index 94% rename from ApnsPHP/Tests/MessageTest.php rename to ApnsPHP/Tests/MessageTestBase.php index 6bbd1d88..817b0776 100644 --- a/ApnsPHP/Tests/MessageTest.php +++ b/ApnsPHP/Tests/MessageTestBase.php @@ -21,7 +21,7 @@ * * @covers \ApnsPHP\Message */ -abstract class MessageTest extends LunrBaseTest +abstract class MessageTestBase extends LunrBaseTest { /** * Class to test diff --git a/ApnsPHP/Tests/PushAddTest.php b/ApnsPHP/Tests/PushAddTest.php index 3a47e4a9..7eeda284 100644 --- a/ApnsPHP/Tests/PushAddTest.php +++ b/ApnsPHP/Tests/PushAddTest.php @@ -15,7 +15,7 @@ * * @covers \ApnsPHP\Push */ -class PushAddTest extends PushTest +class PushAddTest extends PushTestBase { /** * Test that add() successfully adds one message @@ -26,16 +26,16 @@ public function testAddOneMessage(): void { $this->message->expects($this->once()) ->method('getPayLoad') - ->will($this->returnValue('payload')); + ->willReturn('payload'); $this->message->expects($this->once()) - ->method('getRecipientsNumber') - ->will($this->returnValue(1)); + ->method('getRecipientsCount') + ->willReturn(1); $this->message->expects($this->once()) ->method('selfForRecipient') ->with(0) - ->will($this->returnValue($this->message)); + ->willReturn($this->message); $this->class->add($this->message); @@ -60,16 +60,22 @@ public function testAddMultipleMessages(): void $this->message->expects($this->once()) ->method('getPayLoad') - ->will($this->returnValue('payload')); + ->willReturn('payload'); $this->message->expects($this->once()) - ->method('getRecipientsNumber') - ->will($this->returnValue(4)); + ->method('getRecipientsCount') + ->willReturn(4); + + $map = [ + [ 0, $this->message ], + [ 1, $this->message ], + [ 2, $this->message ], + [ 3, $this->message ], + ]; $this->message->expects($this->exactly(4)) ->method('selfForRecipient') - ->withConsecutive([0], [1], [2], [3]) - ->will($this->returnValue($this->message)); + ->willReturnMap($map); $this->class->add($this->message); @@ -87,11 +93,11 @@ public function testAddDoesNothing(): void { $this->message->expects($this->once()) ->method('getPayLoad') - ->will($this->returnValue('payload')); + ->willReturn('payload'); $this->message->expects($this->once()) - ->method('getRecipientsNumber') - ->will($this->returnValue(0)); + ->method('getRecipientsCount') + ->willReturn(0); $this->class->add($this->message); diff --git a/ApnsPHP/Tests/PushConnectTest.php b/ApnsPHP/Tests/PushConnectTest.php index 355195a8..1b8a6da9 100644 --- a/ApnsPHP/Tests/PushConnectTest.php +++ b/ApnsPHP/Tests/PushConnectTest.php @@ -19,7 +19,7 @@ * * @covers \ApnsPHP\Push */ -class PushConnectTest extends PushTest +class PushConnectTest extends PushTestBase { /** * Test that connect() connects successfully @@ -34,11 +34,11 @@ public function testConnectSuccess(): void $this->logger->expects($this->exactly(3)) ->method('info') - ->withConsecutive( + ->willReturnMap([ [ 'Trying to initialize HTTP/2 backend...' ], [ 'Initializing HTTP/2 backend with certificate.' ], [ 'Initialized HTTP/2 backend.' ], - ); + ]); $this->class->connect(); @@ -57,16 +57,13 @@ public function testConnectThrowsExceptionOnHttpInitFail(): void $this->mock_function('curl_setopt_array', fn() => false); - $message = [ - ]; - $this->logger->expects($this->exactly(4)) ->method('error') ->with('Unable to initialize HTTP/2 backend.'); $this->logger->expects($this->exactly(11)) ->method('info') - ->withConsecutive( + ->willReturnMap([ [ 'Trying to initialize HTTP/2 backend...' ], [ 'Initializing HTTP/2 backend with certificate.' ], [ 'Retry to connect (1/3)...' ], @@ -78,7 +75,7 @@ public function testConnectThrowsExceptionOnHttpInitFail(): void [ 'Retry to connect (3/3)...' ], [ 'Trying to initialize HTTP/2 backend...' ], [ 'Initializing HTTP/2 backend with certificate.' ], - ); + ]); $this->expectException('ApnsPHP\Exception'); $this->expectExceptionMessage('Unable to initialize HTTP/2 backend.'); diff --git a/ApnsPHP/Tests/PushDisconnectTest.php b/ApnsPHP/Tests/PushDisconnectTest.php index b9c6b119..3e6bb1c9 100644 --- a/ApnsPHP/Tests/PushDisconnectTest.php +++ b/ApnsPHP/Tests/PushDisconnectTest.php @@ -15,7 +15,7 @@ * * @covers \ApnsPHP\Push */ -class PushDisconnectTest extends PushTest +class PushDisconnectTest extends PushTestBase { /** * Test that disconnect() disconnects successfully diff --git a/ApnsPHP/Tests/PushGetTest.php b/ApnsPHP/Tests/PushGetTest.php index 06964dcb..643b47bf 100644 --- a/ApnsPHP/Tests/PushGetTest.php +++ b/ApnsPHP/Tests/PushGetTest.php @@ -14,7 +14,7 @@ * * @covers \ApnsPHP\Push */ -class PushGetTest extends PushTest +class PushGetTest extends PushTestBase { /** * Test that getSendRetryTimes() returns how often sends should be retried. diff --git a/ApnsPHP/Tests/PushHttpInitTest.php b/ApnsPHP/Tests/PushHttpInitTest.php index 92c424d2..61b3a35f 100644 --- a/ApnsPHP/Tests/PushHttpInitTest.php +++ b/ApnsPHP/Tests/PushHttpInitTest.php @@ -20,7 +20,7 @@ * * @covers \ApnsPHP\Push */ -class PushHttpInitTest extends PushTest +class PushHttpInitTest extends PushTestBase { /** * Test that httpInit() succeeds with certificate @@ -40,7 +40,7 @@ public function testHttpInitSucceedsWithCertificate(): void $this->logger->expects($this->exactly(3)) ->method('info') - ->withConsecutive(...$message); + ->willReturnMap($message); $method = $this->get_reflection_method('httpInit'); $result = $method->invoke($this->class); @@ -99,11 +99,11 @@ public function testHttpInitSucceedsWithKey(): void $this->logger->expects($this->exactly(3)) ->method('info') - ->withConsecutive( + ->willReturnMap([ [ 'Trying to initialize HTTP/2 backend...' ], [ 'Initializing HTTP/2 backend with key.' ], [ 'Initialized HTTP/2 backend.' ] - ); + ]); $method = $this->get_reflection_method('httpInit'); $result = $method->invoke($this->class); @@ -167,10 +167,10 @@ public function testHttpInitThrowsExceptionOnCurlSetoptFail(): void $this->logger->expects($this->exactly(2)) ->method('info') - ->withConsecutive( + ->willReturnMap([ [ 'Trying to initialize HTTP/2 backend...' ], [ 'Initializing HTTP/2 backend with key.' ], - ); + ]); $this->expectException('ApnsPHP\Exception'); $this->expectExceptionMessage('Unable to initialize HTTP/2 backend.'); diff --git a/ApnsPHP/Tests/PushHttpSendTest.php b/ApnsPHP/Tests/PushHttpSendTest.php index 6440f5e8..bc89720a 100644 --- a/ApnsPHP/Tests/PushHttpSendTest.php +++ b/ApnsPHP/Tests/PushHttpSendTest.php @@ -19,7 +19,7 @@ * * @covers \ApnsPHP\Push */ -class PushHttpSendTest extends PushTest +class PushHttpSendTest extends PushTestBase { /** * Helper function to set the http headers and verify calls to message getters @@ -29,11 +29,11 @@ private function setHttpHeaders(): void { $this->message->expects($this->exactly(2)) ->method('getTopic') - ->will($this->returnValue('topic')); + ->willReturn('topic'); $this->message->expects($this->exactly(2)) ->method('getExpiry') - ->will($this->returnValue(10)); + ->willReturn(10); $this->message->expects($this->exactly(2)) ->method('getPriority') @@ -41,15 +41,15 @@ private function setHttpHeaders(): void $this->message->expects($this->exactly(2)) ->method('getCollapseId') - ->will($this->returnValue('1')); + ->willReturn('1'); $this->message->expects($this->exactly(2)) ->method('getCustomIdentifier') - ->will($this->returnValue('7530A828-E58E-433E-A38F-D8042208CF96')); + ->willReturn('7530A828-E58E-433E-A38F-D8042208CF96'); $this->message->expects($this->exactly(2)) ->method('getPushType') - ->will($this->returnValue(PushType::Alert)); + ->willReturn(PushType::Alert); $this->set_reflection_property_value('providerToken', 'jwt'); } @@ -70,11 +70,11 @@ public function testHttpSendReturnsFalseOnCurlSessionFail(): void $this->message->expects($this->once()) ->method('getRecipient') - ->will($this->returnValue('recipient')); + ->willReturn('recipient'); $this->message->expects($this->once()) ->method('getPayload') - ->will($this->returnValue('payload')); + ->willReturn('payload'); $reply = 'reply'; @@ -105,11 +105,11 @@ public function testHttpSendReturnsFalseOnCurlOptsCannotBeSet(): void $this->message->expects($this->once()) ->method('getRecipient') - ->will($this->returnValue('recipient')); + ->willReturn('recipient'); $this->message->expects($this->once()) ->method('getPayload') - ->will($this->returnValue('payload')); + ->willReturn('payload'); $reply = 'reply'; @@ -139,11 +139,11 @@ public function testHttpSendReturnsFalseOnRequestFail(): void $this->message->expects($this->once()) ->method('getRecipient') - ->will($this->returnValue('recipient')); + ->willReturn('recipient'); $this->message->expects($this->once()) ->method('getPayload') - ->will($this->returnValue('payload')); + ->willReturn('payload'); $reply = 'reply'; @@ -174,11 +174,11 @@ public function testHttpSendReturnsTrueOnSuccess(): void $this->message->expects($this->once()) ->method('getRecipient') - ->will($this->returnValue('recipient')); + ->willReturn('recipient'); $this->message->expects($this->once()) ->method('getPayload') - ->will($this->returnValue('payload')); + ->willReturn('payload'); $reply = 'reply'; diff --git a/ApnsPHP/Tests/PushInvalidTest.php b/ApnsPHP/Tests/PushInvalidTest.php index 140bc870..2d66fd3f 100644 --- a/ApnsPHP/Tests/PushInvalidTest.php +++ b/ApnsPHP/Tests/PushInvalidTest.php @@ -17,7 +17,7 @@ * * @covers \ApnsPHP\Push */ -class PushInvalidTest extends PushTest +class PushInvalidTest extends PushTestBase { /** * TestCase constructor diff --git a/ApnsPHP/Tests/PushRemoveMessageFromQueueTest.php b/ApnsPHP/Tests/PushRemoveMessageFromQueueTest.php index 43d7cd7a..d6f75aea 100644 --- a/ApnsPHP/Tests/PushRemoveMessageFromQueueTest.php +++ b/ApnsPHP/Tests/PushRemoveMessageFromQueueTest.php @@ -15,7 +15,7 @@ * * @covers \ApnsPHP\Push */ -class PushRemoveMessageFromQueueTest extends PushTest +class PushRemoveMessageFromQueueTest extends PushTestBase { /** * Test that removeMessageFromQueue() throws an exception if the message id is not valid diff --git a/ApnsPHP/Tests/PushSendTest.php b/ApnsPHP/Tests/PushSendTest.php index 841fe0d1..db9d9163 100644 --- a/ApnsPHP/Tests/PushSendTest.php +++ b/ApnsPHP/Tests/PushSendTest.php @@ -18,7 +18,7 @@ * * @covers \ApnsPHP\Push */ -class PushSendTest extends PushTest +class PushSendTest extends PushTestBase { /** * Test that send() throws an exception if there is no connection to the push notification service @@ -79,14 +79,14 @@ public function testSendFailsWithoutRetrying(): void $this->logger->expects($this->exactly(6)) ->method('info') - ->withConsecutive( + ->willReturnMap([ [ 'Sending messages queue, run #1: 1 message(s) left in queue.' ], [ 'Disconnected.' ], [ 'Trying to initialize HTTP/2 backend...' ], [ 'Initializing HTTP/2 backend with certificate.' ], [ 'Initialized HTTP/2 backend.' ], [ 'Sending messages queue, run #2: 1 message(s) left in queue.' ], - ); + ]); $this->logger->expects($this->once()) ->method('debug') @@ -127,7 +127,7 @@ public function testSendFailsWithRetrying(): void $this->logger->expects($this->exactly(16)) ->method('info') - ->withConsecutive( + ->willReturnMap([ [ 'Sending messages queue, run #1: 1 message(s) left in queue.' ], [ 'Disconnected.' ], [ 'Trying to initialize HTTP/2 backend...' ], @@ -144,15 +144,15 @@ public function testSendFailsWithRetrying(): void [ 'Initializing HTTP/2 backend with certificate.' ], [ 'Initialized HTTP/2 backend.' ], [ 'Sending messages queue, run #4: 1 message(s) left in queue.' ], - ); + ]); $this->logger->expects($this->exactly(3)) ->method('debug') - ->withConsecutive( + ->willReturnMap([ [ 'Sending message ID 1 [custom identifier: unset] (1/3): 0 bytes.' ], [ 'Sending message ID 1 [custom identifier: unset] (2/3): 0 bytes.' ], [ 'Sending message ID 1 [custom identifier: unset] (3/3): 0 bytes.' ], - ); + ]); $this->logger->expects($this->once()) ->method('warning') @@ -190,7 +190,7 @@ public function testSendRemovesWhenNoError(): void $this->logger->expects($this->exactly(7)) ->method('info') - ->withConsecutive( + ->willReturnMap([ [ 'Sending messages queue, run #1: 1 message(s) left in queue.' ], [ 'Disconnected.' ], [ 'Trying to initialize HTTP/2 backend...' ], @@ -199,7 +199,7 @@ public function testSendRemovesWhenNoError(): void [ 'Sending messages queue, run #2: 1 message(s) left in queue.' ], [ 'Message ID 1 [custom identifier: unset] has no error (200), removing from queue...'], - ); + ]); $this->logger->expects($this->once()) ->method('debug') diff --git a/ApnsPHP/Tests/PushSetTest.php b/ApnsPHP/Tests/PushSetTest.php index 1946f3e6..f6660102 100644 --- a/ApnsPHP/Tests/PushSetTest.php +++ b/ApnsPHP/Tests/PushSetTest.php @@ -14,7 +14,7 @@ * * @covers \ApnsPHP\Push */ -class PushSetTest extends PushTest +class PushSetTest extends PushTestBase { /** * Test that setSendRetryTimes() sets how often sends should be retried. diff --git a/ApnsPHP/Tests/PushTest.php b/ApnsPHP/Tests/PushTestBase.php similarity index 94% rename from ApnsPHP/Tests/PushTest.php rename to ApnsPHP/Tests/PushTestBase.php index e941a9fc..c16fc374 100644 --- a/ApnsPHP/Tests/PushTest.php +++ b/ApnsPHP/Tests/PushTestBase.php @@ -1,7 +1,7 @@ logger->expects($this->exactly(3)) ->method('info') - ->withConsecutive( + ->willReturnMap([ [ 'Trying to initialize HTTP/2 backend...' ], [ 'Initializing HTTP/2 backend with certificate.' ], [ 'Initialized HTTP/2 backend.' ], - ); + ]); $this->logger->expects($this->never()) ->method('warning'); @@ -104,11 +104,11 @@ public function testUpdateQueueDoesNotDeleteUnsentMessages(): void $this->logger->expects($this->exactly(3)) ->method('info') - ->withConsecutive( + ->willReturnMap([ [ 'Trying to initialize HTTP/2 backend...' ], [ 'Initializing HTTP/2 backend with certificate.' ], [ 'Initialized HTTP/2 backend.' ], - ); + ]); $this->logger->expects($this->never()) ->method('warning'); diff --git a/composer.json b/composer.json index 20a56f3f..33a83e14 100644 --- a/composer.json +++ b/composer.json @@ -16,7 +16,7 @@ "lcobucci/jwt": "~4.1 || ~5.0" }, "require-dev": { - "phpunit/phpunit": ">=9.0 <9.6", + "phpunit/phpunit": "~10.0", "lunr/halo": "~0.10.0" }, "config": {