Skip to content

Commit

Permalink
fixes after review
Browse files Browse the repository at this point in the history
  • Loading branch information
seba-aln committed Nov 19, 2024
1 parent 652dfb0 commit ffe8702
Show file tree
Hide file tree
Showing 5 changed files with 49 additions and 41 deletions.
2 changes: 1 addition & 1 deletion examples/cli/pub.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
use PubNub\PubNub;
use PubNub\PNConfiguration;

if ($argc < 3) {
if ($argc < 5) {
echo "Usage: php pub.php <uuid> <channel> <message> <custom_message_type>\n";
exit(1);
}
Expand Down
2 changes: 1 addition & 1 deletion src/PubNub/Endpoints/MessagePersistance/FetchMessages.php
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ class FetchMessages extends Endpoint
protected bool $includeUuid = false;
protected bool $includeMessageType = true;
protected bool $includeMessageActions = false;
protected bool $includeCustomMessageType = true;
protected bool $includeCustomMessageType = false;

protected array $customParamMapping = [
'start' => 'start',
Expand Down
29 changes: 29 additions & 0 deletions tests/Acceptance/CustomMessageType/CustomMessageTypeContext.php
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,35 @@ public function iFetchMessageHistoryWithSetToForChannel(string $attribute, strin
}
}

/**
* @When I fetch message history with messageType for :channelName channel
*/
public function iFetchMessageHistoryWithMessagetypeForChannel($channelName)

Check failure on line 93 in tests/Acceptance/CustomMessageType/CustomMessageTypeContext.php

View workflow job for this annotation

GitHub Actions / Lint project

Method PubNubTests\Acceptance\CustomMessageType\CustomMessageTypeContext::iFetchMessageHistoryWithMessagetypeForChannel() has no return type specified.

Check failure on line 93 in tests/Acceptance/CustomMessageType/CustomMessageTypeContext.php

View workflow job for this annotation

GitHub Actions / Lint project

Method PubNubTests\Acceptance\CustomMessageType\CustomMessageTypeContext::iFetchMessageHistoryWithMessagetypeForChannel() has parameter $channelName with no type specified.
{
$this->channelName = $channelName;
$builder = $this->pubnub->fetchMessages()->channels($this->channelName)->includeMessageType(true);
try {
$this->response = $builder->sync();
} catch (PubNubServerException $e) {
$this->response = $e;
}
}

/**
* @When I fetch message history with customMessageType for :channelName channel
*/
public function iFetchMessageHistoryWithCustommessagetypeForChannel($channelName)

Check failure on line 107 in tests/Acceptance/CustomMessageType/CustomMessageTypeContext.php

View workflow job for this annotation

GitHub Actions / Lint project

Method PubNubTests\Acceptance\CustomMessageType\CustomMessageTypeContext::iFetchMessageHistoryWithCustommessagetypeForChannel() has no return type specified.

Check failure on line 107 in tests/Acceptance/CustomMessageType/CustomMessageTypeContext.php

View workflow job for this annotation

GitHub Actions / Lint project

Method PubNubTests\Acceptance\CustomMessageType\CustomMessageTypeContext::iFetchMessageHistoryWithCustommessagetypeForChannel() has parameter $channelName with no type specified.
{
$this->channelName = $channelName;
$builder = $this->pubnub->fetchMessages()->channels($this->channelName)->includeCustomMessageType(true);

try {
$this->response = $builder->sync();
} catch (PubNubServerException $e) {
$this->response = $e;
}
}

/**
* @Then history response contains messages with :messageType1 and :messageType2 message types
*/
Expand Down

This file was deleted.

32 changes: 18 additions & 14 deletions tests/integrational/FetchMessagesTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -22,17 +22,18 @@ class FetchMessagesTest extends PubNubTestCase

public function testFetchWithDefaults()
{
$fetchMessages = new FetchMessagesExposed($this->pubnub);
$subKey = $this->pubnub_demo->getConfiguration()->getSubscribeKey();
$fetchMessages = new FetchMessagesExposed($this->pubnub_demo);

$fetchMessages
->stubFor("/v3/history/sub-key/demo/channel/TheMessageHistoryChannelHD")
->withQuery([
"uuid" => $this->pubnub->getConfiguration()->getUserId(),
"uuid" => $this->pubnub_demo->getConfiguration()->getUserId(),
"pnsdk" => $this->encodedSdkName,
"include_meta" => "false",
"include_uuid" => "false",
"include_message_type" => "true",
"include_custom_message_type" => "true",
"include_custom_message_type" => "false",
])
->setResponseBody('{"status": 200, "error": false, "error_message": "", "channels":
{"TheMessageHistoryChannelHD":[
Expand All @@ -59,18 +60,19 @@ public function testFetchWithDefaults()

public function testFetchWithCount()
{
$fetchMessages = new FetchMessagesExposed($this->pubnub);
$subKey = $this->pubnub_demo->getConfiguration()->getSubscribeKey();
$fetchMessages = new FetchMessagesExposed($this->pubnub_demo);

$fetchMessages
->stubFor("/v3/history/sub-key/demo/channel/TheMessageHistoryChannelHD")
->stubFor("/v3/history/sub-key/{$subKey}/channel/TheMessageHistoryChannelHD")
->withQuery([
"max" => "5",
"uuid" => $this->pubnub->getConfiguration()->getUserId(),
"uuid" => $this->pubnub_demo->getConfiguration()->getUserId(),
"pnsdk" => $this->encodedSdkName,
"include_meta" => "false",
"include_uuid" => "false",
"include_message_type" => "true",
"include_custom_message_type" => "true",
"include_custom_message_type" => "false",
])
->setResponseBody('{"status": 200, "error": false, "error_message": "", "channels":
{"TheMessageHistoryChannelHD":[
Expand All @@ -92,19 +94,20 @@ public function testFetchWithCount()

public function testFetchWithStartEnd()
{
$fetchMessages = new FetchMessagesExposed($this->pubnub);
$subKey = $this->pubnub_demo->getConfiguration()->getSubscribeKey();
$fetchMessages = new FetchMessagesExposed($this->pubnub_demo);

$fetchMessages
->stubFor("/v3/history/sub-key/demo/channel/TheMessageHistoryChannelHD")
->stubFor("/v3/history/sub-key/{$subKey}/channel/TheMessageHistoryChannelHD")
->withQuery([
"start" => "17165627042258346",
"end" => "17165627042258546",
"uuid" => $this->pubnub->getConfiguration()->getUserId(),
"uuid" => $this->pubnub_demo->getConfiguration()->getUserId(),
"pnsdk" => $this->encodedSdkName,
"include_meta" => "false",
"include_uuid" => "false",
"include_message_type" => "true",
"include_custom_message_type" => "true",
"include_custom_message_type" => "false",
])
->setResponseBody('{"status": 200, "error": false, "error_message": "", "channels":
{"TheMessageHistoryChannelHD":[
Expand All @@ -126,17 +129,18 @@ public function testFetchWithStartEnd()

public function testFetchEncrypted()
{
$subKey = $this->pubnub_enc->getConfiguration()->getSubscribeKey();
$fetchMessages = new FetchMessagesExposed($this->pubnub_enc);

$fetchMessages
->stubFor("/v3/history/sub-key/demo/channel/TheMessageHistoryChannelHD-ENCRYPTED")
->stubFor("/v3/history/sub-key/{$subKey}/channel/TheMessageHistoryChannelHD-ENCRYPTED")
->withQuery([
"uuid" => $this->pubnub->getConfiguration()->getUserId(),
"uuid" => $this->pubnub_enc->getConfiguration()->getUserId(),
"pnsdk" => $this->encodedSdkName,
"include_meta" => "false",
"include_uuid" => "false",
"include_message_type" => "true",
"include_custom_message_type" => "true",
"include_custom_message_type" => "false",
])

->setResponseBody('{"status": 200, "error": false, "error_message": "", "channels": {
Expand Down

0 comments on commit ffe8702

Please sign in to comment.