Skip to content

Commit

Permalink
fix tests
Browse files Browse the repository at this point in the history
  • Loading branch information
sokil committed Jan 23, 2022
1 parent 69ffb40 commit bda58aa
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 10 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,8 @@ class SendMessageCommandHandlerTest extends TestCase
public function testBroadcast()
{
$subscriberIdCollection = new SubscriberIdCollection([
new SubscriberId('==aaa=='),
new SubscriberId('==bbb==')
new SubscriberId(base64_encode(hex2bin('5e0025cb55baef890b46995b12195807'))),
new SubscriberId(base64_encode(hex2bin('0c9df24193126bf29fed71691f722cdb'))),
]);

$senderName = 'Sender name';
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ class HandleWebHookCommandHandlerTest extends TestCase
{
public function subscribeDataProvider()
{
$viberUserId = 'xxxffff==';
$viberUserId = base64_encode(hex2bin('d5241619e59440b447c2721c360fb648'));
$viberUserName = 'User name';

return [
Expand Down Expand Up @@ -94,7 +94,7 @@ public function testSubscribe(string $viberUserId, string $viberUserName, array

public function testUnsubscribe()
{
$viberUserId = 'xxxffff==';
$viberUserId = base64_encode(hex2bin('d5241619e59440b447c2721c360fb648'));

$command = new HandleWebHookCommand(
[
Expand Down
15 changes: 9 additions & 6 deletions tests/Service/ViberClient/ViberClientTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -67,8 +67,8 @@ public function testBroadcastMessage()
{
$authToken = 'AuthToken';
$subscriberIdCollection = new SubscriberIdCollection([
new SubscriberId('===aaa==='),
new SubscriberId('===bbb==='),
new SubscriberId(base64_encode(hex2bin('355be750e9aee9125def9effef5d9426'))),
new SubscriberId(base64_encode(hex2bin('d33d1e9f91b4f41f57ab2110be4ac487'))),
]);

$httpClient = $this->getMockBuilder(HttpClientInterface::class)->getMock();
Expand Down Expand Up @@ -96,7 +96,7 @@ public function testBroadcastMessage()
"status_message" => "ok",
"failed_list" => [
[
"receiver" => "===bbb===",
"receiver" => base64_encode(hex2bin('d33d1e9f91b4f41f57ab2110be4ac487')),
"status" => 6,
"status_message" => "Not subscribed"
]
Expand All @@ -118,15 +118,18 @@ public function testBroadcastMessage()
$this->assertCount(1, $statusCollection);
$status = $statusCollection->current();

$this->assertSame('===bbb===', $status->getSubscriberId()->getValue());
$this->assertSame(
base64_encode(hex2bin('d33d1e9f91b4f41f57ab2110be4ac487')),
$status->getSubscriberId()->getValue()
);
$this->assertSame(6, $status->getStatus());
$this->assertSame('Not subscribed', $status->getStatusMessage());
}

public function testSendMessage()
{
$authToken = 'AuthToken';
$subscriberId = new SubscriberId('===aaa===');
$subscriberId = new SubscriberId(base64_encode(hex2bin('c7272dd64f77c5be33a3975094427b98')));

$httpClient = $this->getMockBuilder(HttpClientInterface::class)->getMock();
$httpClient
Expand Down Expand Up @@ -165,7 +168,7 @@ public function testSendMessage()
$subscriberId
);

$this->assertSame('===aaa===', $status->getSubscriberId()->getValue());
$this->assertSame($subscriberId->getValue(), $status->getSubscriberId()->getValue());
$this->assertSame(0, $status->getStatus());
$this->assertSame('ok', $status->getStatusMessage());
}
Expand Down

0 comments on commit bda58aa

Please sign in to comment.