diff --git a/.github/pull_request_template.md b/.github/pull_request_template.md index 7c52669..8299310 100644 --- a/.github/pull_request_template.md +++ b/.github/pull_request_template.md @@ -1,10 +1,10 @@ | Q | A | ------------- | --- -| Branch? | master for features / 1.x up to 3.x for bug fixes +| Branch? | master | Bug fix? | yes/no -| New feature? | yes/no -| BC breaks? | no -| Deprecations? | yes/no +| New feature? | yes/no +| BC breaks? | yes/no +| Deprecations? | yes/no | Tests pass? | yes | Fixed tickets | #... | License | MIT diff --git a/tests/Mocks/Event/message.json b/tests/Mocks/Event/message.json index 7a9f92b..aa427f8 100644 --- a/tests/Mocks/Event/message.json +++ b/tests/Mocks/Event/message.json @@ -13,6 +13,14 @@ "quick_reply": { "payload": "DEVELOPER_DEFINED_PAYLOAD" }, + "attachments": [ + { + "type": "image", + "payload": { + "url": "IMAGE_URL" + } + } + ], "nlp": { "entities": { "datetime": [ diff --git a/tests/TestCase/Event/EventFactoryTest.php b/tests/TestCase/Event/EventFactoryTest.php index 7b6d3d1..c1fe1e6 100644 --- a/tests/TestCase/Event/EventFactoryTest.php +++ b/tests/TestCase/Event/EventFactoryTest.php @@ -34,6 +34,8 @@ use Kerox\Messenger\Model\Callback\Optin; use Kerox\Messenger\Model\Callback\PassThreadControl; use Kerox\Messenger\Model\Callback\Payment; +use Kerox\Messenger\Model\Callback\Payment\PaymentCredential; +use Kerox\Messenger\Model\Callback\Payment\RequestedUserInfo; use Kerox\Messenger\Model\Callback\PolicyEnforcement; use Kerox\Messenger\Model\Callback\Postback; use Kerox\Messenger\Model\Callback\PreCheckout; @@ -42,6 +44,7 @@ use Kerox\Messenger\Model\Callback\Referral; use Kerox\Messenger\Model\Callback\RequestThreadControl; use Kerox\Messenger\Model\Callback\TakeThreadControl; +use Kerox\Messenger\Model\Common\Address; use Kerox\Messenger\Test\TestCase\AbstractTestCase; class EventFactoryTest extends AbstractTestCase @@ -57,6 +60,11 @@ public function testRawEvent(): void $this->assertEquals($expectedEvent, $event); } + public function testEntryEvent(): void + { + + } + public function testMessageEvent(): void { $json = file_get_contents(__DIR__ . '/../../Mocks/Event/message.json'); @@ -66,6 +74,24 @@ public function testMessageEvent(): void $event = EventFactory::create($array); $this->assertEquals($expectedEvent, $event); + + $message = $event->getMessage(); + $this->assertSame('mid.1457764197618:41d102a3e1ae206a38', $message->getMessageId()); + $this->assertTrue($message->hasText()); + $this->assertSame('hello, world!', $message->getText()); + $this->assertTrue($message->hasQuickReply()); + $this->assertSame('DEVELOPER_DEFINED_PAYLOAD', $message->getQuickReply()); + $this->assertTrue($message->hasAttachments()); + $this->assertSame([['type' => 'image', 'payload' => ['url' => 'IMAGE_URL']]], $message->getAttachments()); + $this->assertTrue($message->hasEntities()); + $this->assertSame([ + 'datetime' => [ + ['confidence' => 0.97249440664957, 'values' => ['...'], 'value' => '2017-05-10T14:00:00.000-07:00', 'grain' => 'hour', 'type' => 'value'] + ], + 'greetings' => [ + ['confidence' => 1, 'value' => 'true'] + ] + ], $message->getEntities()); } public function testMessageEchoEvent(): void @@ -77,6 +103,12 @@ public function testMessageEchoEvent(): void $event = EventFactory::create($array); $this->assertEquals($expectedEvent, $event); + + $messageEcho = $event->getMessageEcho(); + $this->assertTrue($messageEcho->isEcho()); + $this->assertSame(1517776481860111, $messageEcho->getAppId()); + $this->assertSame('DEVELOPER_DEFINED_METADATA_STRING', $messageEcho->getMetadata()); + $this->assertSame('mid.1457764197618:41d102a3e1ae206a38', $messageEcho->getMessageId()); } public function testPostbackEvent(): void @@ -88,6 +120,31 @@ public function testPostbackEvent(): void $event = EventFactory::create($array); $this->assertEquals($expectedEvent, $event); + + $postback = $event->getPostback(); + $this->assertSame('TITLE_FOR_THE_CTA', $postback->getTitle()); + $this->assertTrue($postback->hasPayload()); + $this->assertSame('USER_DEFINED_PAYLOAD', $postback->getPayload()); + $this->assertTrue($postback->hasReferral()); + $this->assertInstanceOf(Referral::class, $postback->getReferral()); + } + + public function testPostbackEventFromStandBy(): void + { + $json = file_get_contents(__DIR__ . '/../../Mocks/Event/postback_from_stand_by.json'); + $array = json_decode($json, true); + + $expectedEvent = new PostbackEvent('USER_ID', 'PAGE_ID', 1458692752478, Postback::create($array['postback'])); + $event = EventFactory::create($array); + + $this->assertEquals($expectedEvent, $event); + + $postback = $event->getPostback(); + $this->assertSame('TITLE_FOR_THE_CTA', $postback->getTitle()); + $this->assertFalse($postback->hasPayload()); + $this->assertNull($postback->getPayload()); + $this->assertFalse($postback->hasReferral()); + $this->assertNull($postback->getReferral()); } public function testOptinEvent(): void @@ -99,6 +156,9 @@ public function testOptinEvent(): void $event = EventFactory::create($array); $this->assertEquals($expectedEvent, $event); + + $optin = $event->getOptin(); + $this->assertSame('PASS_THROUGH_PARAM', $optin->getRef()); } public function testAccountLinkingEvent(): void @@ -110,6 +170,11 @@ public function testAccountLinkingEvent(): void $event = EventFactory::create($array); $this->assertEquals($expectedEvent, $event); + + $accountLinking = $event->getAccountLinking(); + $this->assertSame('linked', $accountLinking->getStatus()); + $this->assertTrue($accountLinking->hasAuthorizationCode()); + $this->assertSame('PASS_THROUGH_AUTHORIZATION_CODE', $accountLinking->getAuthorizationCode()); } public function testDeliveryEvent(): void @@ -121,6 +186,10 @@ public function testDeliveryEvent(): void $event = EventFactory::create($array); $this->assertEquals($expectedEvent, $event); + + $delivery = $event->getDelivery(); + $this->assertSame(1458668856253, $delivery->getWatermark()); + $this->assertSame(['mid.1458668856218:ed81099e15d3f4f233'], $delivery->getMessageIds()); } public function testReadEvent(): void @@ -132,6 +201,9 @@ public function testReadEvent(): void $event = EventFactory::create($array); $this->assertEquals($expectedEvent, $event); + + $read = $event->getRead(); + $this->assertSame(1458668856253, $read->getWatermark()); } public function testPaymentEvent(): void @@ -143,6 +215,37 @@ public function testPaymentEvent(): void $event = EventFactory::create($array); $this->assertEquals($expectedEvent, $event); + + $payment = $event->getPayment(); + $this->assertSame('DEVELOPER_DEFINED_PAYLOAD', $payment->getPayload()); + $this->assertSame('123', $payment->getShippingOptionId()); + $this->assertSame('USD', $payment->getCurrency()); + $this->assertSame('29.62', $payment->getAmount()); + $this->assertInstanceOf(RequestedUserInfo::class, $payment->getRequestedUserInfo()); + $this->assertInstanceOf(PaymentCredential::class, $payment->getPaymentCredential()); + $this->assertInstanceOf(Address::class, $payment->getShippingAddress()); + + $requestedUserInfo = $payment->getRequestedUserInfo(); + $this->assertSame('Peter Chang', $requestedUserInfo->getContactName()); + $this->assertSame('peter@anemailprovider.com', $requestedUserInfo->getContactEmail()); + $this->assertSame('+15105551234', $requestedUserInfo->getContactPhone()); + + $paymentCredential = $payment->getPaymentCredential(); + $this->assertSame('token', $paymentCredential->getProviderType()); + $this->assertSame('ch_18tmdBEoNIH3FPJHa60ep123', $paymentCredential->getChargeId()); + $this->assertSame('__tokenized_card__', $paymentCredential->getTokenizedCard()); + $this->assertSame('tokenized cvv', $paymentCredential->getTokenizedCvv()); + $this->assertSame('3', $paymentCredential->getTokenExpiryMonth()); + $this->assertSame('2019', $paymentCredential->getTokenExpiryYear()); + $this->assertSame('123456789', $paymentCredential->getFbPaymentId()); + + $shippingAddress = $payment->getShippingAddress(); + $this->assertSame('1 Hacker Way', $shippingAddress->getStreet()); + $this->assertSame('', $shippingAddress->getAdditionalStreet()); + $this->assertSame('MENLO PARK', $shippingAddress->getCity()); + $this->assertSame('CA', $shippingAddress->getState()); + $this->assertSame('US', $shippingAddress->getCountry()); + $this->assertSame('94025', $shippingAddress->getPostalCode()); } public function testCheckoutUpdateEvent(): void @@ -154,6 +257,19 @@ public function testCheckoutUpdateEvent(): void $event = EventFactory::create($array); $this->assertEquals($expectedEvent, $event); + + $checkoutUpdate = $event->getCheckoutUpdate(); + $this->assertSame('DEVELOPER_DEFINED_PAYLOAD', $checkoutUpdate->getPayload()); + $this->assertInstanceOf(Address::class, $checkoutUpdate->getShippingAddress()); + + $shippingAddress = $checkoutUpdate->getShippingAddress(); + $this->assertSame('1 Hacker Way', $shippingAddress->getStreet()); + $this->assertSame('', $shippingAddress->getAdditionalStreet()); + $this->assertSame('MENLO PARK', $shippingAddress->getCity()); + $this->assertSame('CA', $shippingAddress->getState()); + $this->assertSame('US', $shippingAddress->getCountry()); + $this->assertSame('94025', $shippingAddress->getPostalCode()); + $this->assertSame(10105655000959552, $shippingAddress->getId()); } public function testPreCheckoutEvent(): void @@ -165,6 +281,25 @@ public function testPreCheckoutEvent(): void $event = EventFactory::create($array); $this->assertEquals($expectedEvent, $event); + + $preCheckout = $event->getPreCheckout(); + $this->assertSame('DEVELOPER_DEFINED_PAYLOAD', $preCheckout->getPayload()); + $this->assertSame('USD', $preCheckout->getCurrency()); + $this->assertSame('29.62', $preCheckout->getAmount()); + $this->assertInstanceOf(RequestedUserInfo::class, $preCheckout->getRequestedUserInfo()); + $this->assertInstanceOf(Address::class, $preCheckout->getShippingAddress()); + + $requestedUserInfo = $preCheckout->getRequestedUserInfo(); + $this->assertSame('Peter Chang', $requestedUserInfo->getContactName()); + + $shippingAddress = $preCheckout->getShippingAddress(); + $this->assertSame('Peter Chang', $shippingAddress->getName()); + $this->assertSame('1 Hacker Way', $shippingAddress->getStreet()); + $this->assertSame('', $shippingAddress->getAdditionalStreet()); + $this->assertSame('MENLO PARK', $shippingAddress->getCity()); + $this->assertSame('CA', $shippingAddress->getState()); + $this->assertSame('US', $shippingAddress->getCountry()); + $this->assertSame('94025', $shippingAddress->getPostalCode()); } public function testTakeThreadControlEvent(): void @@ -176,6 +311,10 @@ public function testTakeThreadControlEvent(): void $event = EventFactory::create($array); $this->assertEquals($expectedEvent, $event); + + $takeThreadControl = $event->getTakeThreadControl(); + $this->assertSame(123456789, $takeThreadControl->getPreviousOwnerAppId()); + $this->assertSame('additional content that the caller wants to set', $takeThreadControl->getMetadata()); } public function testPassThreadControlEvent(): void @@ -187,6 +326,10 @@ public function testPassThreadControlEvent(): void $event = EventFactory::create($array); $this->assertEquals($expectedEvent, $event); + + $passThreadControl = $event->getPassThreadControl(); + $this->assertSame(123456789, $passThreadControl->getNewOwnerAppId()); + $this->assertSame('additional content that the caller wants to set', $passThreadControl->getMetadata()); } public function testRequestThreadControlEvent(): void @@ -198,6 +341,10 @@ public function testRequestThreadControlEvent(): void $event = EventFactory::create($array); $this->assertEquals($expectedEvent, $event); + + $requestThreadControl = $event->getRequestThreadControl(); + $this->assertSame(123456789, $requestThreadControl->getRequestedOwnerAppId()); + $this->assertSame('additional content that the caller wants to set', $requestThreadControl->getMetadata()); } public function testPolicyEnforcementEvent(): void @@ -209,6 +356,11 @@ public function testPolicyEnforcementEvent(): void $event = EventFactory::create($array); $this->assertEquals($expectedEvent, $event); + + $policyEnforcement = $event->getPolicyEnforcement(); + $this->assertSame('block', $policyEnforcement->getAction()); + $this->assertSame('The bot violated our Platform Policies (https://developers.facebook.com/policy/#messengerplatform). Common violations include sending out excessive spammy messages or being non-functional.', $policyEnforcement->getReason()); + } public function testAppRolesEvent(): void @@ -220,6 +372,9 @@ public function testAppRolesEvent(): void $event = EventFactory::create($array); $this->assertEquals($expectedEvent, $event); + + $appRoles = $event->getAppRoles(); + $this->assertSame(['123456789' => ['automation']], $appRoles->getAppRoles()); } public function testReferralEvent(): void @@ -231,6 +386,11 @@ public function testReferralEvent(): void $event = EventFactory::create($array); $this->assertEquals($expectedEvent, $event); + + $referral = $event->getReferral(); + $this->assertSame('REF DATA PASSED IN M.ME PARAM', $referral->getRef()); + $this->assertSame('SHORTLINK', $referral->getSource()); + $this->assertSame('OPEN_THREAD', $referral->getType()); } public function testGamePlayEvent(): void @@ -242,6 +402,14 @@ public function testGamePlayEvent(): void $event = EventFactory::create($array); $this->assertEquals($expectedEvent, $event); + + $gamePlay = $event->getGamePlay(); + $this->assertSame('1234', $gamePlay->getGameId()); + $this->assertSame('666', $gamePlay->getPlayerId()); + $this->assertSame('SOLO|THREAD', $gamePlay->getContextType()); + $this->assertSame('123', $gamePlay->getContextId()); + $this->assertSame(1234567890, $gamePlay->getScore()); + $this->assertSame('DEVELOPER_DEFINED_PAYLOAD', $gamePlay->getPayload()); } public function testReactionEvent(): void @@ -253,5 +421,11 @@ public function testReactionEvent(): void $event = EventFactory::create($array); $this->assertEquals($expectedEvent, $event); + + $reaction = $event->getReaction(); + $this->assertSame('smile', $reaction->getReaction()); + $this->assertSame("❤️", $reaction->getEmoji()); + $this->assertSame('react', $reaction->getAction()); + $this->assertSame('', $reaction->getMid()); } } diff --git a/tests/TestCase/Event/EventTest.php b/tests/TestCase/Event/EventTest.php index 4f8dda6..b50ff56 100644 --- a/tests/TestCase/Event/EventTest.php +++ b/tests/TestCase/Event/EventTest.php @@ -261,13 +261,13 @@ public function testReferralEvent(): void public function testReactionEvent(): void { - $mockedReferral = $this->createMock(Reaction::class); - $event = new ReactionEvent('sender_id', 'recipient_id', 123456, $mockedReferral); + $mockedReaction = $this->createMock(Reaction::class); + $event = new ReactionEvent('sender_id', 'recipient_id', 123456, $mockedReaction); $this->assertSame('sender_id', $event->getSenderId()); $this->assertSame('recipient_id', $event->getRecipientId()); $this->assertSame(123456, $event->getTimestamp()); - $this->assertSame($mockedReferral, $event->getReaction()); + $this->assertSame($mockedReaction, $event->getReaction()); $this->assertSame('reaction', $event->getName()); } } diff --git a/tests/TestCase/Model/Callback/AccountLinkingTest.php b/tests/TestCase/Model/Callback/AccountLinkingTest.php deleted file mode 100644 index 023d59b..0000000 --- a/tests/TestCase/Model/Callback/AccountLinkingTest.php +++ /dev/null @@ -1,20 +0,0 @@ -assertSame('linked', $accountLinking->getStatus()); - $this->assertTrue($accountLinking->hasAuthorizationCode()); - $this->assertSame('PASS_THROUGH_AUTHORIZATION_CODE', $accountLinking->getAuthorizationCode()); - } -} diff --git a/tests/TestCase/Model/Callback/AppRolesTest.php b/tests/TestCase/Model/Callback/AppRolesTest.php deleted file mode 100644 index 72c6910..0000000 --- a/tests/TestCase/Model/Callback/AppRolesTest.php +++ /dev/null @@ -1,18 +0,0 @@ - ['automation']]); - - $this->assertSame(['123456789' => ['automation']], $appRoles->getAppRoles()); - } -} diff --git a/tests/TestCase/Model/Callback/CheckoutUpdateTest.php b/tests/TestCase/Model/Callback/CheckoutUpdateTest.php deleted file mode 100644 index 2325c27..0000000 --- a/tests/TestCase/Model/Callback/CheckoutUpdateTest.php +++ /dev/null @@ -1,49 +0,0 @@ -checkoutUpdate = CheckoutUpdate::create($array['checkout_update']); - } - - public function testCheckoutUpdateCallback(): void - { - $this->assertSame('DEVELOPER_DEFINED_PAYLOAD', $this->checkoutUpdate->getPayload()); - $this->assertInstanceOf(Address::class, $this->checkoutUpdate->getShippingAddress()); - } - - public function testCheckoutUpdateShippingAddress(): void - { - $shippingAddress = $this->checkoutUpdate->getShippingAddress(); - - $this->assertSame('1 Hacker Way', $shippingAddress->getStreet()); - $this->assertSame('', $shippingAddress->getAdditionalStreet()); - $this->assertSame('MENLO PARK', $shippingAddress->getCity()); - $this->assertSame('CA', $shippingAddress->getState()); - $this->assertSame('US', $shippingAddress->getCountry()); - $this->assertSame('94025', $shippingAddress->getPostalCode()); - $this->assertSame(10105655000959552, $shippingAddress->getId()); - } - - public function tearDown(): void - { - unset($this->checkoutUpdate); - } -} diff --git a/tests/TestCase/Model/Callback/DeliveryTest.php b/tests/TestCase/Model/Callback/DeliveryTest.php deleted file mode 100644 index d2f6a3c..0000000 --- a/tests/TestCase/Model/Callback/DeliveryTest.php +++ /dev/null @@ -1,19 +0,0 @@ -assertSame(1458668856253, $delivery->getWatermark()); - $this->assertSame(['mid.1458668856218:ed81099e15d3f4f233'], $delivery->getMessageIds()); - } -} diff --git a/tests/TestCase/Model/Callback/GamePlayTest.php b/tests/TestCase/Model/Callback/GamePlayTest.php deleted file mode 100644 index 3b8faf4..0000000 --- a/tests/TestCase/Model/Callback/GamePlayTest.php +++ /dev/null @@ -1,23 +0,0 @@ -assertSame('game_id', $gamePlay->getGameId()); - $this->assertSame('player_id', $gamePlay->getPlayerId()); - $this->assertSame('THREAD', $gamePlay->getContextType()); - $this->assertSame('context_id', $gamePlay->getContextId()); - $this->assertSame(1000, $gamePlay->getScore()); - $this->assertSame('', $gamePlay->getPayload()); - } -} diff --git a/tests/TestCase/Model/Callback/MessageEchoTest.php b/tests/TestCase/Model/Callback/MessageEchoTest.php deleted file mode 100644 index 448840a..0000000 --- a/tests/TestCase/Model/Callback/MessageEchoTest.php +++ /dev/null @@ -1,26 +0,0 @@ -assertTrue($messageEcho->isEcho()); - $this->assertSame(1517776481860111, $messageEcho->getAppId()); - $this->assertSame('DEVELOPER_DEFINED_METADATA_STRING', $messageEcho->getMetadata()); - $this->assertSame('mid.1457764197618:41d102a3e1ae206a38', $messageEcho->getMessageId()); - } -} diff --git a/tests/TestCase/Model/Callback/MessageTest.php b/tests/TestCase/Model/Callback/MessageTest.php index 89d336f..b83fdab 100644 --- a/tests/TestCase/Model/Callback/MessageTest.php +++ b/tests/TestCase/Model/Callback/MessageTest.php @@ -9,31 +9,6 @@ class MessageTest extends AbstractTestCase { - public function testMessageCallback(): void - { - $message = new Message( - 'mid.1457764197618:41d102a3e1ae206a38', - 'hello, world!', - 'DEVELOPER_DEFINED_PAYLOAD', - [ - [ - 'type' => 'image', - 'payload' => [ - 'url' => 'IMAGE_URL' - ] - ] - ] - ); - - $this->assertSame('mid.1457764197618:41d102a3e1ae206a38', $message->getMessageId()); - $this->assertSame('hello, world!', $message->getText()); - $this->assertSame('DEVELOPER_DEFINED_PAYLOAD', $message->getQuickReply()); - $this->assertSame([['type' => 'image', 'payload' => ['url' => 'IMAGE_URL']]], $message->getAttachments()); - $this->assertTrue($message->hasText()); - $this->assertTrue($message->hasQuickReply()); - $this->assertTrue($message->hasAttachments()); - } - public function testMessageModelWithEmptyStringAndEmptyQuickReply(): void { $message = Message::create([ diff --git a/tests/TestCase/Model/Callback/OptinTest.php b/tests/TestCase/Model/Callback/OptinTest.php deleted file mode 100644 index 44191d5..0000000 --- a/tests/TestCase/Model/Callback/OptinTest.php +++ /dev/null @@ -1,18 +0,0 @@ -assertSame('PASS_THROUGH_PARAM', $optin->getRef()); - } -} diff --git a/tests/TestCase/Model/Callback/PassThreadControlTest.php b/tests/TestCase/Model/Callback/PassThreadControlTest.php deleted file mode 100644 index 981da69..0000000 --- a/tests/TestCase/Model/Callback/PassThreadControlTest.php +++ /dev/null @@ -1,35 +0,0 @@ -passThreadControl = PassThreadControl::create($array['pass_thread_control']); - } - - public function testPassThreadControlCallback(): void - { - $this->assertSame(123456789, $this->passThreadControl->getNewOwnerAppId()); - $this->assertSame('additional content that the caller wants to set', $this->passThreadControl->getMetadata()); - } - - public function tearDown(): void - { - unset($this->passThreadControl); - } -} diff --git a/tests/TestCase/Model/Callback/PaymentTest.php b/tests/TestCase/Model/Callback/PaymentTest.php deleted file mode 100644 index 77720e4..0000000 --- a/tests/TestCase/Model/Callback/PaymentTest.php +++ /dev/null @@ -1,77 +0,0 @@ -payment = Payment::create($array['payment']); - } - - public function testPaymentCallback(): void - { - $this->assertSame('DEVELOPER_DEFINED_PAYLOAD', $this->payment->getPayload()); - $this->assertSame('123', $this->payment->getShippingOptionId()); - $this->assertSame('USD', $this->payment->getCurrency()); - $this->assertSame('29.62', $this->payment->getAmount()); - $this->assertInstanceOf(RequestedUserInfo::class, $this->payment->getRequestedUserInfo()); - $this->assertInstanceOf(PaymentCredential::class, $this->payment->getPaymentCredential()); - $this->assertInstanceOf(Address::class, $this->payment->getShippingAddress()); - } - - public function testPaymentRequestedUserInfo(): void - { - $requestedUserInfo = $this->payment->getRequestedUserInfo(); - - $this->assertSame('Peter Chang', $requestedUserInfo->getContactName()); - $this->assertSame('peter@anemailprovider.com', $requestedUserInfo->getContactEmail()); - $this->assertSame('+15105551234', $requestedUserInfo->getContactPhone()); - } - - public function testPaymentCredential(): void - { - $paymentCredential = $this->payment->getPaymentCredential(); - - $this->assertSame('token', $paymentCredential->getProviderType()); - $this->assertSame('ch_18tmdBEoNIH3FPJHa60ep123', $paymentCredential->getChargeId()); - $this->assertSame('__tokenized_card__', $paymentCredential->getTokenizedCard()); - $this->assertSame('tokenized cvv', $paymentCredential->getTokenizedCvv()); - $this->assertSame('3', $paymentCredential->getTokenExpiryMonth()); - $this->assertSame('2019', $paymentCredential->getTokenExpiryYear()); - $this->assertSame('123456789', $paymentCredential->getFbPaymentId()); - } - - public function testPaymentShippingAddress(): void - { - $shippingAddress = $this->payment->getShippingAddress(); - - $this->assertSame('1 Hacker Way', $shippingAddress->getStreet()); - $this->assertSame('', $shippingAddress->getAdditionalStreet()); - $this->assertSame('MENLO PARK', $shippingAddress->getCity()); - $this->assertSame('CA', $shippingAddress->getState()); - $this->assertSame('US', $shippingAddress->getCountry()); - $this->assertSame('94025', $shippingAddress->getPostalCode()); - } - - public function tearDown(): void - { - unset($this->payment); - } -} diff --git a/tests/TestCase/Model/Callback/PolicyEnforcementTest.php b/tests/TestCase/Model/Callback/PolicyEnforcementTest.php deleted file mode 100644 index 6c45601..0000000 --- a/tests/TestCase/Model/Callback/PolicyEnforcementTest.php +++ /dev/null @@ -1,19 +0,0 @@ -assertSame('block', $policyEnforcement->getAction()); - $this->assertSame('The bot violated our Platform Policies (https://developers.facebook.com/policy/#messengerplatform). Common violations include sending out excessive spammy messages or being non-functional.', $policyEnforcement->getReason()); - } -} diff --git a/tests/TestCase/Model/Callback/PostbackTest.php b/tests/TestCase/Model/Callback/PostbackTest.php deleted file mode 100644 index 5e6120e..0000000 --- a/tests/TestCase/Model/Callback/PostbackTest.php +++ /dev/null @@ -1,38 +0,0 @@ -createMock(Referral::class); - $postback = new Postback('TITLE_FOR_THE_CTA', 'USER_DEFINED_PAYLOAD', $stub); - - $this->assertSame('TITLE_FOR_THE_CTA', $postback->getTitle()); - $this->assertTrue($postback->hasPayload()); - $this->assertSame('USER_DEFINED_PAYLOAD', $postback->getPayload()); - $this->assertTrue($postback->hasReferral()); - $this->assertSame($stub, $postback->getReferral()); - } - - public function testPostbackCallbackFromStandBy(): void - { - $json = file_get_contents(__DIR__ . '/../../../Mocks/Event/postback_from_stand_by.json'); - $array = json_decode($json, true); - - $postback = Postback::create($array['postback']); - - $this->assertSame('TITLE_FOR_THE_CTA', $postback->getTitle()); - $this->assertFalse($postback->hasPayload()); - $this->assertNull($postback->getPayload()); - $this->assertFalse($postback->hasReferral()); - $this->assertNull($postback->getReferral()); - } -} diff --git a/tests/TestCase/Model/Callback/PreCheckoutTest.php b/tests/TestCase/Model/Callback/PreCheckoutTest.php deleted file mode 100644 index 90cffbd..0000000 --- a/tests/TestCase/Model/Callback/PreCheckoutTest.php +++ /dev/null @@ -1,60 +0,0 @@ -preCheckout = PreCheckout::create($array['pre_checkout']); - } - - public function testPreCheckoutCallback(): void - { - $this->assertSame('DEVELOPER_DEFINED_PAYLOAD', $this->preCheckout->getPayload()); - $this->assertSame('USD', $this->preCheckout->getCurrency()); - $this->assertSame('29.62', $this->preCheckout->getAmount()); - $this->assertInstanceOf(RequestedUserInfo::class, $this->preCheckout->getRequestedUserInfo()); - $this->assertInstanceOf(Address::class, $this->preCheckout->getShippingAddress()); - } - - public function testPaymentRequestedUserInfo(): void - { - $requestedUserInfo = $this->preCheckout->getRequestedUserInfo(); - - $this->assertSame('Peter Chang', $requestedUserInfo->getContactName()); - } - - public function testPaymentShippingAddress(): void - { - $shippingAddress = $this->preCheckout->getShippingAddress(); - - $this->assertSame('Peter Chang', $shippingAddress->getName()); - $this->assertSame('1 Hacker Way', $shippingAddress->getStreet()); - $this->assertSame('', $shippingAddress->getAdditionalStreet()); - $this->assertSame('MENLO PARK', $shippingAddress->getCity()); - $this->assertSame('CA', $shippingAddress->getState()); - $this->assertSame('US', $shippingAddress->getCountry()); - $this->assertSame('94025', $shippingAddress->getPostalCode()); - } - - public function tearDown(): void - { - unset($this->payment); - } -} diff --git a/tests/TestCase/Model/Callback/ReadTest.php b/tests/TestCase/Model/Callback/ReadTest.php deleted file mode 100644 index 964609d..0000000 --- a/tests/TestCase/Model/Callback/ReadTest.php +++ /dev/null @@ -1,18 +0,0 @@ -assertSame(1458668856253, $read->getWatermark()); - } -} diff --git a/tests/TestCase/Model/Callback/ReferralTest.php b/tests/TestCase/Model/Callback/ReferralTest.php deleted file mode 100644 index d55ce9b..0000000 --- a/tests/TestCase/Model/Callback/ReferralTest.php +++ /dev/null @@ -1,20 +0,0 @@ -assertSame('REF DATA PASSED IN M.ME PARAM', $referral->getRef()); - $this->assertSame('SHORTLINK', $referral->getSource()); - $this->assertSame('OPEN_THREAD', $referral->getType()); - } -} diff --git a/tests/TestCase/Model/Callback/RequestThreadControlTest.php b/tests/TestCase/Model/Callback/RequestThreadControlTest.php deleted file mode 100644 index ddabc8d..0000000 --- a/tests/TestCase/Model/Callback/RequestThreadControlTest.php +++ /dev/null @@ -1,35 +0,0 @@ -requestThreadControl = RequestThreadControl::create($array['request_thread_control']); - } - - public function testRequestThreadControlCallback(): void - { - $this->assertSame(123456789, $this->requestThreadControl->getRequestedOwnerAppId()); - $this->assertSame('additional content that the caller wants to set', $this->requestThreadControl->getMetadata()); - } - - public function tearDown(): void - { - unset($this->requestThreadControl); - } -} diff --git a/tests/TestCase/Model/Callback/TakeThreadControlTest.php b/tests/TestCase/Model/Callback/TakeThreadControlTest.php deleted file mode 100644 index dc3c39a..0000000 --- a/tests/TestCase/Model/Callback/TakeThreadControlTest.php +++ /dev/null @@ -1,35 +0,0 @@ -takeThreadControl = TakeThreadControl::create($array['take_thread_control']); - } - - public function testPassThreadControlCallback(): void - { - $this->assertSame(123456789, $this->takeThreadControl->getPreviousOwnerAppId()); - $this->assertSame('additional content that the caller wants to set', $this->takeThreadControl->getMetadata()); - } - - public function tearDown(): void - { - unset($this->takeThreadControl); - } -}