diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml index 57a0e74..799b016 100644 --- a/.github/workflows/tests.yml +++ b/.github/workflows/tests.yml @@ -65,4 +65,6 @@ jobs: - name: Run php-cs-fixer if: ${{ matrix.php != '8.2' }} # Not supported yet. - run: composer test:syntax + run: | + composer test:syntax + composer test:syntax_tests diff --git a/composer.json b/composer.json index 2b164ac..622e205 100644 --- a/composer.json +++ b/composer.json @@ -13,9 +13,12 @@ } ], "scripts": { + "fix:syntax": "./vendor/bin/php-cs-fixer fix ./src --using-cache=no", + "fix:syntax_tests": "./vendor/bin/php-cs-fixer fix ./tests --using-cache=no", "test:unit": "./vendor/bin/phpunit --color", "test:typing": "./vendor/bin/phpstan analyse", - "test:syntax": "./vendor/bin/php-cs-fixer fix ./src --dry-run --stop-on-violation --using-cache=no" + "test:syntax": "./vendor/bin/php-cs-fixer fix ./src --dry-run --stop-on-violation --using-cache=no", + "test:syntax_tests": "./vendor/bin/php-cs-fixer fix ./tests --dry-run --stop-on-violation --using-cache=no" }, "require": { "php": ">=8.0", @@ -39,8 +42,8 @@ "friendsofphp/php-cs-fixer": "^v3.13.2" }, "autoload": { - "psr-4" : { - "Minishlink\\WebPush\\" : "src" + "psr-4": { + "Minishlink\\WebPush\\": "src" } } } diff --git a/tests/EncryptionTest.php b/tests/EncryptionTest.php index 59cb109..d53a998 100644 --- a/tests/EncryptionTest.php +++ b/tests/EncryptionTest.php @@ -13,15 +13,12 @@ use Base64Url\Base64Url; use Jose\Component\Core\JWK; -use Jose\Component\Core\Util\Ecc\NistCurve; -use Jose\Component\Core\Util\Ecc\PrivateKey; -use Jose\Component\KeyManagement\JWKFactory; use Minishlink\WebPush\Encryption; use Minishlink\WebPush\Utils; final class EncryptionTest extends PHPUnit\Framework\TestCase { - public function testDeterministicEncrypt() + public function testDeterministicEncrypt(): void { $contentEncoding = "aes128gcm"; $plaintext = 'When I grow up, I want to be a watermelon'; @@ -65,7 +62,7 @@ public function testDeterministicEncrypt() $this->assertEquals($expected, $result); } - public function testGetContentCodingHeader() + public function testGetContentCodingHeader(): void { $localPublicKey = Base64Url::decode('BP4z9KsN6nGRTbVYI_c7VJSPQTBtkgcy27mlmlMoZIIgDll6e3vCYLocInmYWAmS6TlzAC8wEqKK6PBru3jl7A8'); $salt = Base64Url::decode('DGv6ra1nlYgDCS1FRnbzlw'); @@ -82,7 +79,7 @@ public function testGetContentCodingHeader() * * @throws ErrorException */ - public function testPadPayload(string $payload, int $maxLengthToPad, int $expectedResLength) + public function testPadPayload(string $payload, int $maxLengthToPad, int $expectedResLength): void { $res = Encryption::padPayload($payload, $maxLengthToPad, "aesgcm"); diff --git a/tests/MessageSentReportTest.php b/tests/MessageSentReportTest.php index 76797bf..afbba44 100644 --- a/tests/MessageSentReportTest.php +++ b/tests/MessageSentReportTest.php @@ -5,118 +5,129 @@ */ use GuzzleHttp\Psr7\Request; -use \Minishlink\WebPush\MessageSentReport; -use \GuzzleHttp\Psr7\Response; +use GuzzleHttp\Psr7\Response; +use Minishlink\WebPush\MessageSentReport; +use PHPUnit\Framework\TestCase; /** * @covers \Minishlink\WebPush\MessageSentReport */ -class MessageSentReportTest extends \PHPUnit\Framework\TestCase { +class MessageSentReportTest extends TestCase +{ + /** + * @dataProvider generateReportsWithExpiration + */ + public function testIsSubscriptionExpired(MessageSentReport $report, bool $expected): void + { + $this->assertEquals($expected, $report->isSubscriptionExpired()); + } - /** - * @dataProvider generateReportsWithExpiration - */ - public function testIsSubscriptionExpired(MessageSentReport $report, bool $expected): void { - $this->assertEquals($expected, $report->isSubscriptionExpired()); - } - - public function generateReportsWithExpiration(): array { - $request = new Request('POST', 'https://example.com'); - return [ - [new MessageSentReport($request, new Response(404)), true], - [new MessageSentReport($request, new Response(410)), true], - [new MessageSentReport($request, new Response(500)), false], - [new MessageSentReport($request, new Response(200)), false] - ]; - } + public function generateReportsWithExpiration(): array + { + $request = new Request('POST', 'https://example.com'); + return [ + [new MessageSentReport($request, new Response(404)), true], + [new MessageSentReport($request, new Response(410)), true], + [new MessageSentReport($request, new Response(500)), false], + [new MessageSentReport($request, new Response(200)), false] + ]; + } - /** - * @dataProvider generateReportsWithEndpoints - */ - public function testGetEndpoint(MessageSentReport $report, string $expected): void { - $this->assertEquals($expected, $report->getEndpoint()); - } + /** + * @dataProvider generateReportsWithEndpoints + */ + public function testGetEndpoint(MessageSentReport $report, string $expected): void + { + $this->assertEquals($expected, $report->getEndpoint()); + } - public function generateReportsWithEndpoints(): array { - return [ - [new MessageSentReport(new Request('POST', 'https://www.example.com')), 'https://www.example.com'], - [new MessageSentReport(new Request('POST', 'https://m.example.com')), 'https://m.example.com'], - [new MessageSentReport(new Request('POST', 'https://test.net')), 'https://test.net'], - ]; - } + public function generateReportsWithEndpoints(): array + { + return [ + [new MessageSentReport(new Request('POST', 'https://www.example.com')), 'https://www.example.com'], + [new MessageSentReport(new Request('POST', 'https://m.example.com')), 'https://m.example.com'], + [new MessageSentReport(new Request('POST', 'https://test.net')), 'https://test.net'], + ]; + } - /** - * @dataProvider generateReportsWithRequests - */ - public function testGetRequest(MessageSentReport $report, Request $expected): void { - $this->assertEquals($expected, $report->getRequest()); - } + /** + * @dataProvider generateReportsWithRequests + */ + public function testGetRequest(MessageSentReport $report, Request $expected): void + { + $this->assertEquals($expected, $report->getRequest()); + } - public function generateReportsWithRequests(): array { - $r1 = new Request('POST', 'https://www.example.com'); - $r2 = new Request('PUT', 'https://m.example.com'); - $r3 = new Request('GET', 'https://test.net'); + public function generateReportsWithRequests(): array + { + $r1 = new Request('POST', 'https://www.example.com'); + $r2 = new Request('PUT', 'https://m.example.com'); + $r3 = new Request('GET', 'https://test.net'); - return [ - [new MessageSentReport($r1), $r1], - [new MessageSentReport($r2), $r2], - [new MessageSentReport($r3), $r3], - ]; - } + return [ + [new MessageSentReport($r1), $r1], + [new MessageSentReport($r2), $r2], + [new MessageSentReport($r3), $r3], + ]; + } - /** - * @dataProvider generateReportsWithJson - */ - public function testJsonSerialize(MessageSentReport $report, string $json): void { - $this->assertJsonStringEqualsJsonString($json, json_encode($report, JSON_THROW_ON_ERROR)); - } + /** + * @dataProvider generateReportsWithJson + */ + public function testJsonSerialize(MessageSentReport $report, string $json): void + { + $this->assertJsonStringEqualsJsonString($json, json_encode($report, JSON_THROW_ON_ERROR)); + } - public function generateReportsWithJson(): array { - $request1Body = json_encode(['title' => 'test', 'body' => 'blah', 'data' => []]); - $request1 = new Request('POST', 'https://www.example.com', [], $request1Body); - $response1 = new Response(200, [], 'test'); + public function generateReportsWithJson(): array + { + $request1Body = json_encode(['title' => 'test', 'body' => 'blah', 'data' => []], JSON_THROW_ON_ERROR); + $request1 = new Request('POST', 'https://www.example.com', [], $request1Body); + $response1 = new Response(200, [], 'test'); - $request2Body = ''; - $request2 = new Request('POST', 'https://www.example.com', [], $request2Body); - $response2 = new Response(410, [], 'Faield to do somthing', '1.1', 'Gone'); + $request2Body = ''; + $request2 = new Request('POST', 'https://www.example.com', [], $request2Body); + $response2 = new Response(410, [], 'Failed to do something', '1.1', 'Gone'); - return [ - [ - new MessageSentReport($request1, $response1), - json_encode([ - 'success' => true, - 'expired' => false, - 'reason' => 'OK', - 'endpoint' => (string) $request1->getUri(), - 'payload' => $request1Body, - ], JSON_THROW_ON_ERROR) - ], - [ - new MessageSentReport($request2, $response2, false, 'Gone'), - json_encode([ - 'success' => false, - 'expired' => true, - 'reason' => 'Gone', - 'endpoint' => (string) $request2->getUri(), - 'payload' => $request2Body, - ], JSON_THROW_ON_ERROR) - ] - ]; - } + return [ + [ + new MessageSentReport($request1, $response1), + json_encode([ + 'success' => true, + 'expired' => false, + 'reason' => 'OK', + 'endpoint' => (string) $request1->getUri(), + 'payload' => $request1Body, + ], JSON_THROW_ON_ERROR) + ], + [ + new MessageSentReport($request2, $response2, false, 'Gone'), + json_encode([ + 'success' => false, + 'expired' => true, + 'reason' => 'Gone', + 'endpoint' => (string) $request2->getUri(), + 'payload' => $request2Body, + ], JSON_THROW_ON_ERROR) + ] + ]; + } - /** - * @dataProvider generateReportsWithSuccess - */ - public function testIsSuccess(MessageSentReport $report, bool $expected): void { - $this->assertEquals($expected, $report->isSuccess()); - } + /** + * @dataProvider generateReportsWithSuccess + */ + public function testIsSuccess(MessageSentReport $report, bool $expected): void + { + $this->assertEquals($expected, $report->isSuccess()); + } - public function generateReportsWithSuccess(): array { + public function generateReportsWithSuccess(): array + { $request = new Request('POST', 'https://example.com'); - return [ - [new MessageSentReport($request), true], - [new MessageSentReport($request, null, true), true], - [new MessageSentReport($request, null, false), false], - ]; - } + return [ + [new MessageSentReport($request), true], + [new MessageSentReport($request, null, true), true], + [new MessageSentReport($request, null, false), false], + ]; + } } diff --git a/tests/PushServiceTest.php b/tests/PushServiceTest.php index 510640f..f991652 100644 --- a/tests/PushServiceTest.php +++ b/tests/PushServiceTest.php @@ -11,22 +11,23 @@ * file that was distributed with this source code. */ -use Minishlink\WebPush\WebPush; +use Minishlink\WebPush\MessageSentReport; use Minishlink\WebPush\Subscription; +use Minishlink\WebPush\WebPush; final class PushServiceTest extends PHPUnit\Framework\TestCase { - private static $timeout = 30; - private static $portNumber = 9012; - private static $testServiceUrl; - public static $vapidKeys = [ + private static int $timeout = 30; + private static int $portNumber = 9012; + private static string $testServiceUrl; + public static array $vapidKeys = [ 'subject' => 'http://test.com', 'publicKey' => 'BA6jvk34k6YjElHQ6S0oZwmrsqHdCNajxcod6KJnI77Dagikfb--O_kYXcR2eflRz6l3PcI2r8fPCH3BElLQHDk', 'privateKey' => '-3CdhFOqjzixgAbUSa0Zv9zi-dwDVmWO7672aBxSFPQ', ]; /** @var WebPush WebPush with correct api keys */ - private $webPush; + private WebPush $webPush; /** * {@inheritdoc} @@ -36,7 +37,7 @@ public static function setUpBeforeClass(): void self::$testServiceUrl = 'http://localhost:'.self::$portNumber; } - public function browserProvider() + public function browserProvider(): array { return [ ['firefox', ['VAPID' => self::$vapidKeys]], @@ -49,7 +50,7 @@ public function browserProvider() /** * Selenium tests are flakey so add retries. */ - public function retryTest($retryCount, $test) + public function retryTest($retryCount, $test): void { // just like above without checking the annotation for ($i = 0; $i < $retryCount; $i++) { @@ -70,12 +71,12 @@ public function retryTest($retryCount, $test) * @dataProvider browserProvider * Run integration tests with browsers */ - public function testBrowsers($browserId, $options) + public function testBrowsers($browserId, $options): void { $this->retryTest(2, $this->createClosureTest($browserId, $options)); } - protected function createClosureTest($browserId, $options) + protected function createClosureTest($browserId, $options): callable { return function () use ($browserId, $options) { $this->webPush = new WebPush($options); @@ -115,19 +116,19 @@ protected function createClosureTest($browserId, $options) foreach ($supportedContentEncodings as $contentEncoding) { if (!in_array($contentEncoding, ['aesgcm', 'aes128gcm'])) { - $this->expectException(\ErrorException::class); + $this->expectException(ErrorException::class); $this->expectExceptionMessage('This content encoding ('.$contentEncoding.') is not supported.'); $this->markTestIncomplete('Unsupported content encoding: '.$contentEncoding); } $subscription = new Subscription($endpoint, $p256dh, $auth, $contentEncoding); $report = $this->webPush->sendOneNotification($subscription, $payload); - $this->assertInstanceOf(\Minishlink\WebPush\MessageSentReport::class, $report); + $this->assertInstanceOf(MessageSentReport::class, $report); $this->assertTrue($report->isSuccess()); $dataString = json_encode([ - 'clientHash' => $clientHash, - ]); + 'clientHash' => $clientHash, + ], JSON_THROW_ON_ERROR); $getNotificationCurl = curl_init(self::$testServiceUrl.'/get-notifications'); curl_setopt_array($getNotificationCurl, [ @@ -144,7 +145,7 @@ protected function createClosureTest($browserId, $options) $parsedResp = $this->getResponse($getNotificationCurl); if (!property_exists($parsedResp->{'data'}, 'messages')) { - throw new Exception('web-push-testing error, no messages: '.json_encode($parsedResp)); + throw new RuntimeException('web-push-testing error, no messages: '.json_encode($parsedResp, JSON_THROW_ON_ERROR)); } $messages = $parsedResp->{'data'}->{'messages'}; @@ -161,13 +162,13 @@ private function getResponse($ch) if (!$resp) { $error = 'Curl error: n'.curl_errno($ch).' - '.curl_error($ch); curl_close($ch); - throw new Exception($error); + throw new RuntimeException($error); } $parsedResp = json_decode($resp, null, 512, JSON_THROW_ON_ERROR); if (!property_exists($parsedResp, 'data')) { - throw new Exception('web-push-testing-service error: '.$resp); + throw new RuntimeException('web-push-testing-service error: '.$resp); } // Close request to clear up some resources diff --git a/tests/SubscriptionTest.php b/tests/SubscriptionTest.php index bbe5353..3f64109 100644 --- a/tests/SubscriptionTest.php +++ b/tests/SubscriptionTest.php @@ -4,7 +4,7 @@ class SubscriptionTest extends PHPUnit\Framework\TestCase { - public function testCreateMinimal() + public function testCreateMinimal(): void { $subscriptionArray = array( "endpoint" => "http://toto.com" @@ -16,7 +16,7 @@ public function testCreateMinimal() $this->assertEquals(null, $subscription->getContentEncoding()); } - public function testConstructMinimal() + public function testConstructMinimal(): void { $subscription = new Subscription("http://toto.com"); $this->assertEquals("http://toto.com", $subscription->getEndpoint()); @@ -25,7 +25,7 @@ public function testConstructMinimal() $this->assertEquals(null, $subscription->getContentEncoding()); } - public function testCreatePartial() + public function testCreatePartial(): void { $subscriptionArray = array( "endpoint" => "http://toto.com", @@ -39,7 +39,7 @@ public function testCreatePartial() $this->assertEquals("aesgcm", $subscription->getContentEncoding()); } - public function testConstructPartial() + public function testConstructPartial(): void { $subscription = new Subscription("http://toto.com", "publicKey", "authToken"); $this->assertEquals("http://toto.com", $subscription->getEndpoint()); @@ -48,7 +48,7 @@ public function testConstructPartial() $this->assertEquals("aesgcm", $subscription->getContentEncoding()); } - public function testCreateFull() + public function testCreateFull(): void { $subscriptionArray = array( "endpoint" => "http://toto.com", @@ -63,7 +63,7 @@ public function testCreateFull() $this->assertEquals("aes128gcm", $subscription->getContentEncoding()); } - public function testConstructFull() + public function testConstructFull(): void { $subscription = new Subscription("http://toto.com", "publicKey", "authToken", "aes128gcm"); $this->assertEquals("http://toto.com", $subscription->getEndpoint()); @@ -72,7 +72,7 @@ public function testConstructFull() $this->assertEquals("aes128gcm", $subscription->getContentEncoding()); } - public function testCreatePartialWithNewStructure() + public function testCreatePartialWithNewStructure(): void { $subscription = Subscription::create([ "endpoint" => "http://toto.com", @@ -86,7 +86,7 @@ public function testCreatePartialWithNewStructure() $this->assertEquals("authToken", $subscription->getAuthToken()); } - public function testCreatePartialWithNewStructureAndContentEncoding() + public function testCreatePartialWithNewStructureAndContentEncoding(): void { $subscription = Subscription::create([ "endpoint" => "http://toto.com", diff --git a/tests/UtilsTest.php b/tests/UtilsTest.php index 462241f..68e6ede 100644 --- a/tests/UtilsTest.php +++ b/tests/UtilsTest.php @@ -1,13 +1,12 @@ assertArrayHasKey('publicKey', $keys); diff --git a/tests/WebPushTest.php b/tests/WebPushTest.php index c936dfe..d6f756c 100644 --- a/tests/WebPushTest.php +++ b/tests/WebPushTest.php @@ -11,19 +11,19 @@ * file that was distributed with this source code. */ -use Minishlink\WebPush\WebPush; use Minishlink\WebPush\Subscription; use Minishlink\WebPush\SubscriptionInterface; +use Minishlink\WebPush\WebPush; final class WebPushTest extends PHPUnit\Framework\TestCase { - private static $endpoints; - private static $keys; - private static $tokens; - private static $vapidKeys; + private static array $endpoints; + private static array $keys; + private static array $tokens; + private static array $vapidKeys; /** @var WebPush WebPush with correct api keys */ - private $webPush; + private WebPush $webPush; /** * {@inheritdoc} @@ -48,7 +48,7 @@ public static function setUpBeforeClass(): void ]; if (getenv('CI')) { - self::setCiEnvironment();; + self::setCiEnvironment(); } } @@ -108,7 +108,7 @@ private static function setCiEnvironment(): void if (!$response) { $error = 'Curl error: n'.curl_errno($getSubscriptionCurl).' - '.curl_error($getSubscriptionCurl); curl_close($getSubscriptionCurl); - throw new Exception($error); + throw new RuntimeException($error); } $parsedResp = json_decode($response, null, 512, JSON_THROW_ON_ERROR); @@ -137,10 +137,10 @@ public function notificationProvider(): array * @dataProvider notificationProvider * * @param SubscriptionInterface $subscription - * @param string $payload + * @param string $payload * @throws ErrorException */ - public function testSendOneNotification($subscription, $payload) + public function testSendOneNotification(SubscriptionInterface $subscription, string $payload): void { $report = $this->webPush->sendOneNotification($subscription, $payload); $this->assertTrue($report->isSuccess()); @@ -149,7 +149,7 @@ public function testSendOneNotification($subscription, $payload) /** * @throws ErrorException */ - public function testSendNotificationBatch() + public function testSendNotificationBatch(): void { $batchSize = 10; $total = 50; @@ -171,9 +171,9 @@ public function testSendNotificationBatch() /** * @throws ErrorException */ - public function testSendOneNotificationWithTooBigPayload() + public function testSendOneNotificationWithTooBigPayload(): void { - $this->expectException(\ErrorException::class); + $this->expectException(ErrorException::class); $this->expectExceptionMessage('Size of payload must not be greater than 4078 octets.'); $subscription = new Subscription(self::$endpoints['standard'], self::$keys['standard']); @@ -184,57 +184,61 @@ public function testSendOneNotificationWithTooBigPayload() } /** - * @throws ErrorException + * @throws \ErrorException + * @throws \JsonException */ - public function testFlush() { - $subscription = new Subscription(self::$endpoints['standard']); + public function testFlush(): void + { + $subscription = new Subscription(self::$endpoints['standard']); - $report = $this->webPush->sendOneNotification($subscription); - $this->assertFalse($report->isSuccess()); // it doesn't have VAPID + $report = $this->webPush->sendOneNotification($subscription); + $this->assertFalse($report->isSuccess()); // it doesn't have VAPID - // queue has been reset - $this->assertEmpty(iterator_to_array($this->webPush->flush())); + // queue has been reset + $this->assertEmpty(iterator_to_array($this->webPush->flush())); $report = $this->webPush->sendOneNotification($subscription); $this->assertFalse($report->isSuccess()); // it doesn't have VAPID - $nonExistantSubscription = Subscription::create([ - 'endpoint' => 'https://fcm.googleapis.com/fcm/send/fCd2-8nXJhU:APA91bGi2uaqFXGft4qdolwyRUcUPCL1XV_jWy1tpCRqnu4sk7ojUpC5gnq1PTncbCdMq9RCVQIIFIU9BjzScvjrDqpsI7J-K_3xYW8xo1xSNCfge1RvJ6Xs8RGL_Sw7JtbCyG1_EVgWDc22on1r_jozD8vsFbB0Fg', - 'publicKey' => 'BME-1ZSAv2AyGjENQTzrXDj6vSnhAIdKso4n3NDY0lsd1DUgEzBw7ARMKjrYAm7JmJBPsilV5CWNH0mVPyJEt0Q', - 'authToken' => 'hUIGbmiypj9_EQea8AnCKA', - 'contentEncoding' => 'aes128gcm', - ]); - - // test multiple requests - $this->webPush->queueNotification($nonExistantSubscription, json_encode(['test' => 1])); - $this->webPush->queueNotification($nonExistantSubscription, json_encode(['test' => 2])); - $this->webPush->queueNotification($nonExistantSubscription, json_encode(['test' => 3])); - - /** @var \Minishlink\WebPush\MessageSentReport $report */ - foreach ($this->webPush->flush() as $report) { - $this->assertFalse($report->isSuccess()); - $this->assertTrue($report->isSubscriptionExpired()); - $this->assertEquals(410, $report->getResponse()->getStatusCode()); - $this->assertNotEmpty($report->getReason()); - $this->assertNotFalse(filter_var($report->getEndpoint(), FILTER_VALIDATE_URL)); - } + $nonExistentSubscription = Subscription::create([ + 'endpoint' => 'https://fcm.googleapis.com/fcm/send/fCd2-8nXJhU:APA91bGi2uaqFXGft4qdolwyRUcUPCL1XV_jWy1tpCRqnu4sk7ojUpC5gnq1PTncbCdMq9RCVQIIFIU9BjzScvjrDqpsI7J-K_3xYW8xo1xSNCfge1RvJ6Xs8RGL_Sw7JtbCyG1_EVgWDc22on1r_jozD8vsFbB0Fg', + 'publicKey' => 'BME-1ZSAv2AyGjENQTzrXDj6vSnhAIdKso4n3NDY0lsd1DUgEzBw7ARMKjrYAm7JmJBPsilV5CWNH0mVPyJEt0Q', + 'authToken' => 'hUIGbmiypj9_EQea8AnCKA', + 'contentEncoding' => 'aes128gcm', + ]); + + // test multiple requests + $this->webPush->queueNotification($nonExistentSubscription, json_encode(['test' => 1], JSON_THROW_ON_ERROR)); + $this->webPush->queueNotification($nonExistentSubscription, json_encode(['test' => 2], JSON_THROW_ON_ERROR)); + $this->webPush->queueNotification($nonExistentSubscription, json_encode(['test' => 3], JSON_THROW_ON_ERROR)); + + /** @var \Minishlink\WebPush\MessageSentReport $report */ + foreach ($this->webPush->flush() as $report) { + $this->assertFalse($report->isSuccess()); + $this->assertTrue($report->isSubscriptionExpired()); + $this->assertEquals(410, $report->getResponse()->getStatusCode()); + $this->assertNotEmpty($report->getReason()); + $this->assertNotFalse(filter_var($report->getEndpoint(), FILTER_VALIDATE_URL)); + } } - public function testFlushEmpty(): void { + public function testFlushEmpty(): void + { $this->assertEmpty(iterator_to_array($this->webPush->flush(300))); } - /** - * @throws ErrorException - */ - public function testCount(): void { - $subscription = new Subscription(self::$endpoints['standard']); + /** + * @throws ErrorException + */ + public function testCount(): void + { + $subscription = new Subscription(self::$endpoints['standard']); - $this->webPush->queueNotification($subscription); - $this->webPush->queueNotification($subscription); - $this->webPush->queueNotification($subscription); - $this->webPush->queueNotification($subscription); + $this->webPush->queueNotification($subscription); + $this->webPush->queueNotification($subscription); + $this->webPush->queueNotification($subscription); + $this->webPush->queueNotification($subscription); - $this->assertEquals(4, $this->webPush->countPendingNotifications()); + $this->assertEquals(4, $this->webPush->countPendingNotifications()); } }