-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add PushNotificationDeferredResponseInterface for JPush reponse
Issue: HKGO-1801 Reviewed at https://reviews.lunr.nl/r/953/
- Loading branch information
1 parent
e088022
commit 50d3781
Showing
6 changed files
with
269 additions
and
23 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
131 changes: 131 additions & 0 deletions
131
src/Lunr/Vortex/JPush/Tests/JPushResponseGetMessageIdTest.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,131 @@ | ||
<?php | ||
|
||
/** | ||
* This file contains the JPushResponseGetMessageIdTest class. | ||
* | ||
* @package Lunr\Vortex\JPush | ||
* @author Brian Stoop <brian.stoop@moveagency.com> | ||
* @copyright 2020, M2Mobi BV, Amsterdam, The Netherlands | ||
* @license http://lunr.nl/LICENSE MIT License | ||
*/ | ||
|
||
namespace Lunr\Vortex\JPush\Tests; | ||
|
||
use Lunr\Vortex\PushNotificationStatus; | ||
|
||
/** | ||
* This class contains tests for the get_message_id function of the JPushResponse class. | ||
* | ||
* @covers Lunr\Vortex\JPush\JPushResponse | ||
*/ | ||
class JPushResponseGetMessageIdTest extends JPushResponseTest | ||
{ | ||
|
||
/** | ||
* Unit test data provider. | ||
* | ||
* @return array $data array of endpoints statuses / status result | ||
*/ | ||
public function endpointDataProvider(): array | ||
{ | ||
$data = []; | ||
|
||
// return NULL if endpoint not set | ||
$data[] = [ [], NULL ]; | ||
|
||
// return NULL if endpoint absent | ||
$data[] = [ | ||
[ | ||
'endpoint1' => [ | ||
'status' => PushNotificationStatus::INVALID_ENDPOINT, | ||
'message_id' => '165468564' | ||
], | ||
], | ||
NULL, | ||
]; | ||
$data[] = [ | ||
[ | ||
'endpoint1' => [ | ||
'status' => PushNotificationStatus::ERROR, | ||
'message_id' => '165468564' | ||
], | ||
'endpoint2' => [ | ||
'status' => PushNotificationStatus::INVALID_ENDPOINT, | ||
'message_id' => '165468564' | ||
], | ||
'endpoint3' => [ | ||
'status' => PushNotificationStatus::SUCCESS, | ||
'message_id' => '555165655' | ||
], | ||
], | ||
NULL, | ||
]; | ||
|
||
// return NULL if batch was not set | ||
$data[] = [ | ||
[ | ||
'endpoint_param' => PushNotificationStatus::INVALID_ENDPOINT, | ||
], | ||
NULL, | ||
]; | ||
$data[] = [ | ||
[ | ||
'endpoint_param' => [ | ||
'status' => PushNotificationStatus::INVALID_ENDPOINT, | ||
], | ||
], | ||
NULL, | ||
]; | ||
|
||
// return batch if batch is present | ||
$data[] = [ | ||
[ | ||
'endpoint_param' => [ | ||
'status' => PushNotificationStatus::INVALID_ENDPOINT, | ||
'message_id' => '165468564' | ||
], | ||
], | ||
'165468564', | ||
]; | ||
$data[] = [ | ||
[ | ||
'endpoint1' => [ | ||
'status' => PushNotificationStatus::ERROR, | ||
'message_id' => '165468564' | ||
], | ||
'endpoint_param' => [ | ||
'status' => PushNotificationStatus::SUCCESS, | ||
'message_id' => '165468564' | ||
], | ||
'endpoint2' => [ | ||
'status' => PushNotificationStatus::INVALID_ENDPOINT, | ||
'message_id' => '555165655' | ||
], | ||
], | ||
'165468564', | ||
]; | ||
|
||
return $data; | ||
} | ||
|
||
/** | ||
* Test the get_message_id() behavior. | ||
* | ||
* @param array $statuses Endpoints statuses | ||
* @param int $batch Expected function result | ||
* | ||
* @dataProvider endpointDataProvider | ||
* @covers Lunr\Vortex\JPush\JPushResponse::get_message_id | ||
*/ | ||
public function testGetBatch($statuses, $batch): void | ||
{ | ||
$this->set_reflection_property_value('statuses', $statuses); | ||
|
||
$result = $this->class->get_message_id('endpoint_param'); | ||
|
||
$this->assertEquals($batch, $result); | ||
} | ||
|
||
} | ||
|
||
?> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
31 changes: 31 additions & 0 deletions
31
src/Lunr/Vortex/PushNotificationDeferredResponseInterface.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
<?php | ||
|
||
/** | ||
* This file contains the PushNotificationDeferredResponseInterface. | ||
* | ||
* @package Lunr\Vortex | ||
* @author Brian Stoop <brian.stoop@moveagency.com> | ||
* @copyright 2023, Move BV, Amsterdam, The Netherlands | ||
* @license http://lunr.nl/LICENSE MIT License | ||
*/ | ||
|
||
namespace Lunr\Vortex; | ||
|
||
/** | ||
* Push notification deferred Response interface. | ||
*/ | ||
interface PushNotificationDeferredResponseInterface extends PushNotificationResponseInterface | ||
{ | ||
|
||
/** | ||
* Get message_id for an endpoint. | ||
* | ||
* @param string $endpoint Endpoint | ||
* | ||
* @return ?string Delivery batch info for an endpoint | ||
*/ | ||
public function get_message_id(string $endpoint): ?string; | ||
|
||
} | ||
|
||
?> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters