diff --git a/src/Client/MessageClient.php b/src/Client/MessageClient.php index 4bb6d30..fe06ceb 100644 --- a/src/Client/MessageClient.php +++ b/src/Client/MessageClient.php @@ -40,7 +40,7 @@ public function buildApiUrl(): string /** * Builds array for CURLOPT_POSTFIELDS curl argument. * - * @return array + * @return array */ public function buildCurlPostFields(Notification $notification): array { @@ -68,11 +68,11 @@ public function buildCurlPostFields(Notification $notification): array } if (null !== $notification->getMessage()->getPriority()) { - $curlPostFields['priority'] = $notification->getMessage()->getPriority()->getPriority(); + $curlPostFields['priority'] = (string) $notification->getMessage()->getPriority()->getPriority(); if (Priority::EMERGENCY === $notification->getMessage()->getPriority()->getPriority()) { - $curlPostFields['retry'] = $notification->getMessage()->getPriority()->getRetry(); - $curlPostFields['expire'] = $notification->getMessage()->getPriority()->getExpire(); + $curlPostFields['retry'] = (string) $notification->getMessage()->getPriority()->getRetry(); + $curlPostFields['expire'] = (string) $notification->getMessage()->getPriority()->getExpire(); if (null !== $notification->getMessage()->getPriority()->getCallback()) { $curlPostFields['callback'] = $notification->getMessage()->getPriority()->getCallback(); @@ -81,11 +81,11 @@ public function buildCurlPostFields(Notification $notification): array } if (true === $notification->getMessage()->getIsHtml()) { - $curlPostFields['html'] = 1; + $curlPostFields['html'] = '1'; } if (null !== $notification->getMessage()->getTtl()) { - $curlPostFields['ttl'] = $notification->getMessage()->getTtl(); + $curlPostFields['ttl'] = (string) $notification->getMessage()->getTtl(); } if (null !== $notification->getSound()) { diff --git a/tests/Client/MessageClientTest.php b/tests/Client/MessageClientTest.php index 75ec075..35b3579 100644 --- a/tests/Client/MessageClientTest.php +++ b/tests/Client/MessageClientTest.php @@ -55,10 +55,10 @@ public function testBuildCurlPostFields(): void $client = new MessageClient(); $curlPostFields = $client->buildCurlPostFields($notification); - $this->assertIsArray($curlPostFields); $this->assertSame('cccc3333CCCC3333dddd4444DDDD44', $curlPostFields['token']); $this->assertSame('aaaa1111AAAA1111bbbb2222BBBB22', $curlPostFields['user']); $this->assertSame('This is a test message', $curlPostFields['message']); + $this->assertSame($message->getTimestamp(), $curlPostFields['timestamp']); $this->assertSame('ios,android', $curlPostFields['device']); $this->assertSame('This is a title of the message', $curlPostFields['title']); $this->assertSame('https://www.example.com', $curlPostFields['url']);