diff --git a/CHANGELOG.md b/CHANGELOG.md index f972dc7b..68e65606 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,6 +1,12 @@ CHANGELOG ========= +v2.0.3 +------- +* Added order_id in subscription model +* Added sendCustomerCart endpoint Insurance +* Added cancelSubscription endpoint Insurance + v2.0.2 ------- * Added getSubscription endpoint Insurance diff --git a/composer.json b/composer.json index ae271b5d..115842e0 100644 --- a/composer.json +++ b/composer.json @@ -1,7 +1,7 @@ { "name": "alma/alma-php-client", "description": "PHP API client for the Alma payments API", - "version": "2.0.2", + "version": "2.0.3", "type": "library", "require": { "php": "^5.6 || ~7.0 || ~7.1 || ~7.2 || ~7.3 || ~7.4 || ~8.0 || ~8.1 || ~8.2", diff --git a/src/Client.php b/src/Client.php index 54a4f244..51a65f81 100644 --- a/src/Client.php +++ b/src/Client.php @@ -30,7 +30,7 @@ class Client { - const VERSION = '2.0.2'; + const VERSION = '2.0.3'; const LIVE_MODE = 'live'; const TEST_MODE = 'test'; diff --git a/src/Endpoints/Base.php b/src/Endpoints/Base.php index b15dfba0..e64acfba 100644 --- a/src/Endpoints/Base.php +++ b/src/Endpoints/Base.php @@ -41,7 +41,6 @@ class Base public function __construct($client_context) { $this->setClientContext($client_context); - $this->logger = $client_context->logger; } /** @@ -60,5 +59,6 @@ public function request($path) public function setClientContext($clientContext) { $this->clientContext = $clientContext; + $this->logger = $clientContext->logger; } } diff --git a/src/Endpoints/Insurance.php b/src/Endpoints/Insurance.php index c9777c02..0ca25a33 100644 --- a/src/Endpoints/Insurance.php +++ b/src/Endpoints/Insurance.php @@ -102,6 +102,7 @@ public function checkParameters($cmsReference, $insuranceContractExternalId, $pr /** * @param $subscriptionArray + * @param string $orderId * @param null $paymentId * @param string | null $customerSessionId * @param string | null $cartId @@ -110,7 +111,13 @@ public function checkParameters($cmsReference, $insuranceContractExternalId, $pr * @throws RequestError * @throws RequestException */ - public function subscription($subscriptionArray, $paymentId = null, $customerSessionId = null, $cartId = null) + public function subscription( + $subscriptionArray, + $orderId, + $paymentId = null, + $customerSessionId = null, + $cartId = null + ) { if (!is_array($subscriptionArray)) { @@ -122,7 +129,7 @@ public function subscription($subscriptionArray, $paymentId = null, $customerSes ); } - $subscriptionData = $this->buildSubscriptionData($subscriptionArray, $paymentId); + $subscriptionData = $this->buildSubscriptionData($subscriptionArray, $orderId, $paymentId); $request = $this->request(self::INSURANCE_PATH . 'subscriptions') ->setRequestBody($subscriptionData); @@ -137,15 +144,15 @@ public function subscription($subscriptionArray, $paymentId = null, $customerSes } /** - * @throws RequestError + * @return array json_decode in response constructor * @throws RequestException * @throws ParametersException - * @return array json_decode in response constructor + * @throws RequestError */ public function getSubscription($subscriptionIds) { $this->insuranceValidator->checkSubscriptionIds($subscriptionIds); - $response = $this->request( + $response = $this->request( self::INSURANCE_PATH . 'subscriptions' )->setQueryParams( $subscriptionIds @@ -158,15 +165,41 @@ public function getSubscription($subscriptionIds) return $response->json; } + /** + * @param $cmsReferenceArray + * @param $cartId + * @return void + * @throws RequestError + */ + public function sendCustomerCart($cmsReferenceArray, $cartId) + { + try { + $this->insuranceValidator->checkCmsReference($cmsReferenceArray); + $request = $this->request(self::INSURANCE_PATH . 'customer-cart') + ->setRequestBody( + [ + 'cms_references' => $cmsReferenceArray + ] + ); + + $this->addCustomerSessionToRequest($request, null, $cartId); + $request->post(); + } catch (ParametersException $e) { + $this->logger->error('Impossible to send customer cart data', [$e->getMessage()]); + } + } + /** * @param array $subscriptionArray + * @param string $orderId * @param string|null $paymentId * @return array * @throws ParametersException */ - protected function buildSubscriptionData($subscriptionArray, $paymentId = null) + protected function buildSubscriptionData($subscriptionArray, $orderId, $paymentId = null) { $subscriptionData = ['subscriptions' => []]; + $subscriptionData['order_id'] = $orderId; /** * @var Subscription $subscription @@ -209,7 +242,6 @@ protected function buildSubscriptionData($subscriptionArray, $paymentId = null) ) { $subscriptionData['payment_id'] = $paymentId; } - return $subscriptionData; } @@ -273,4 +305,37 @@ public function addCustomerSessionToRequest($request, $customerSessionId = null, $request->addCartIdToHeader($cartId); } } + + /** + * @param string $subscriptionId + * @return void + * @throws ParametersException + * @throws RequestError + * @throws RequestException + */ + public function cancelSubscription($subscriptionId) + { + $subscriptionId = trim($subscriptionId); + $this->checkSubscriptionIdFormat($subscriptionId); + + $request = $this->request(self::INSURANCE_PATH . 'subscriptions/' . $subscriptionId . '/void'); + $response = $request->post(); + + if ($response->isError()) { + throw new RequestException($response->errorMessage, $request, $response); + } + } + + /** + * @param string $subscriptionId + * @return void + * @throws ParametersException + */ + public function checkSubscriptionIdFormat($subscriptionId) + { + if (!is_string($subscriptionId) || empty($subscriptionId)) { + throw new ParametersException('Invalid subscriptions Array'); + } + + } } diff --git a/src/Lib/InsuranceValidator.php b/src/Lib/InsuranceValidator.php index e55099ee..250a39a0 100644 --- a/src/Lib/InsuranceValidator.php +++ b/src/Lib/InsuranceValidator.php @@ -78,4 +78,26 @@ public function checkSubscriptionIds($subscriptionIds) )); } } + + /** + * Throw Exception if payload isn't valid + * @throws ParametersException + */ + public function checkCmsReference($cmsReferenceArray) + { + if (!is_array($cmsReferenceArray) || empty($cmsReferenceArray)) { + throw new ParametersException(sprintf( + 'Invalid parameters must be an array with strings : %s', + gettype($cmsReferenceArray) + )); + } + foreach ($cmsReferenceArray as $cmsReference) { + if (!is_string($cmsReference)) { + throw new ParametersException(sprintf( + 'Cms references must be a string : %s', + json_encode($cmsReference) + )); + } + } + } } diff --git a/tests/Unit/Legacy/Endpoints/InsuranceTest.php b/tests/Unit/Legacy/Endpoints/InsuranceTest.php index d69d6b2c..48e3d91e 100644 --- a/tests/Unit/Legacy/Endpoints/InsuranceTest.php +++ b/tests/Unit/Legacy/Endpoints/InsuranceTest.php @@ -18,19 +18,33 @@ use Alma\API\Response; use Mockery; use PHPUnit\Framework\TestCase; +use Psr\Log\LoggerInterface; class InsuranceTest extends TestCase { const INSURANCE_SUBSCRIPTIONS_PATH = '/v1/insurance/subscriptions'; const INSURANCE_CONTRACTS_PATH = '/v1/insurance/insurance-contracts/'; + const TEST_PHONENUMBER = '+33601010101'; + const TEST_EMAIL = 'test@almapay.com'; + const TEST_CMSREFERENCE = '17-35'; + const TEST_BIRTHDATE = '1988-08-22'; + const INSURANCE_CUSTOMER_CART_PATH = '/v1/insurance/customer-cart'; /** - * @var ClientContext - */ - private $clientContext; + * @var ClientContext + */ + private $clientContext; /** * @var Response */ private $responseMock; + /** + * @var Request + */ + private $requestObject; + /** + * @var Insurance + */ + private $insuranceMock; /** * @return array @@ -67,15 +81,15 @@ public function subscriptionDataProvider() '19', 1312, new Subscriber( - 'mathis.dupuy@almapay.com', - '+33622484646', - 'sub1', - 'sub1', - 'adr1', - 'adr1', - 'adr1', - 'adr1', - 'adr1', + self::TEST_EMAIL, + self::TEST_PHONENUMBER, + 'lastname', + 'firstname', + 'address1', + 'address2', + 'zipcode', + 'city', + 'country', null ), 'cancelUrl' @@ -83,24 +97,70 @@ public function subscriptionDataProvider() new Subscription( 'insurance_contract_3vt2jyvWWQc9wZCmWd1KtI', 1568, - '17-35', + self::TEST_CMSREFERENCE, 1312, new Subscriber( - 'mathis.dupuy@almapay.com', - '+33622484646', - 'sub2', - 'sub2', - 'adr2', - 'adr2', - 'adr2', - 'adr2', + self::TEST_EMAIL, + self::TEST_PHONENUMBER, + 'last', + 'first', + 'adr1', 'adr2', - '1988-08-22' + 'zip', + 'city', + 'country', + self::TEST_BIRTHDATE ), 'cancelUrl' ) ], - null + null, + [ + 'subscriptions' => [ + [ + 'insurance_contract_id' => 'insurance_contract_6VU1zZ5AKfy6EejiNxmLXh', + 'amount' => 1235, + 'cms_reference' => '19', + 'product_price' => 1312, + 'cms_callback_url' => 'cancelUrl', + 'subscriber' => [ + 'email' => self::TEST_EMAIL, + 'phone_number' => self::TEST_PHONENUMBER, + 'last_name' => 'lastname', + 'first_name' => 'firstname', + 'birthdate' => null, + 'address' => [ + 'address_line_1' => 'address1', + 'address_line_2' => 'address2', + 'zip_code' => 'zipcode', + 'city' => 'city', + 'country' => 'country', + ] + ], + ], + [ + 'insurance_contract_id' => 'insurance_contract_3vt2jyvWWQc9wZCmWd1KtI', + 'amount' => 1568, + 'cms_reference' => self::TEST_CMSREFERENCE, + 'product_price' => 1312, + 'cms_callback_url' => 'cancelUrl', + 'subscriber' => [ + 'email' => self::TEST_EMAIL, + 'phone_number' => self::TEST_PHONENUMBER, + 'last_name' => 'last', + 'first_name' => 'first', + 'birthdate' => self::TEST_BIRTHDATE, + 'address' => [ + 'address_line_1' => 'adr1', + 'address_line_2' => 'adr2', + 'zip_code' => 'zip', + 'city' => 'city', + 'country' => 'country', + ] + ], + ] + ] + ] ], 'Test with right data and payment id' => [ [ @@ -110,15 +170,15 @@ public function subscriptionDataProvider() '19', 1312, new Subscriber( - 'mathis.dupuy@almapay.com', - '+33622484646', - 'sub1', - 'sub1', - 'adr1', - 'adr1', - 'adr1', - 'adr1', - 'adr1', + self::TEST_EMAIL, + self::TEST_PHONENUMBER, + 'lastname', + 'firstname', + 'address1', + 'address2', + 'zipcode', + 'city', + 'country', null ), 'cancelUrl' @@ -126,24 +186,70 @@ public function subscriptionDataProvider() new Subscription( 'insurance_contract_3vt2jyvWWQc9wZCmWd1KtI', 1568, - '17-35', + self::TEST_CMSREFERENCE, 1312, new Subscriber( - 'mathis.dupuy@almapay.com', - '+33622484646', - 'sub2', - 'sub2', - 'adr2', - 'adr2', - 'adr2', - 'adr2', + self::TEST_EMAIL, + self::TEST_PHONENUMBER, + 'last', + 'first', + 'adr1', 'adr2', - '1988-08-22' + 'zip', + 'city', + 'country', + self::TEST_BIRTHDATE ), 'cancelUrl' ) ], - 'payment_id' => 'payment_11xlpX9QQYhd3xZVzNMrtdKw4myV7QET7X' + 'payment_id' => 'payment_11xlpX9QQYhd3xZVzNMrtdKw4myV7QET7X', + [ + 'subscriptions' => [ + [ + 'insurance_contract_id' => 'insurance_contract_6VU1zZ5AKfy6EejiNxmLXh', + 'amount' => 1235, + 'cms_reference' => '19', + 'product_price' => 1312, + 'cms_callback_url' => 'cancelUrl', + 'subscriber' => [ + 'email' => self::TEST_EMAIL, + 'phone_number' => self::TEST_PHONENUMBER, + 'last_name' => 'lastname', + 'first_name' => 'firstname', + 'birthdate' => null, + 'address' => [ + 'address_line_1' => 'address1', + 'address_line_2' => 'address2', + 'zip_code' => 'zipcode', + 'city' => 'city', + 'country' => 'country', + ] + ], + ], + [ + 'insurance_contract_id' => 'insurance_contract_3vt2jyvWWQc9wZCmWd1KtI', + 'amount' => 1568, + 'cms_reference' => self::TEST_CMSREFERENCE, + 'product_price' => 1312, + 'cms_callback_url' => 'cancelUrl', + 'subscriber' => [ + 'email' => self::TEST_EMAIL, + 'phone_number' => self::TEST_PHONENUMBER, + 'last_name' => 'last', + 'first_name' => 'first', + 'birthdate' => self::TEST_BIRTHDATE, + 'address' => [ + 'address_line_1' => 'adr1', + 'address_line_2' => 'adr2', + 'zip_code' => 'zip', + 'city' => 'city', + 'country' => 'country', + ] + ], + ] + ] + ] ] ]; } @@ -166,7 +272,7 @@ public static function requestDataProvider() ], 'Throw exception with cms reference array' => [ 'insurance_contract_external_id' => 'insurance_contract_6XxGHbjr51CE5Oly8E2Amx', - 'cms_reference' => ['10','13'], + 'cms_reference' => ['10', '13'], 'product_price' => 10000 ], 'Throw exception with cms reference class' => [ @@ -336,9 +442,9 @@ public function getSubscriptionsRightParamDataProvider() /** * @return void */ - protected function setUp() - { - $this->clientContext = Mockery::mock(ClientContext::class); + protected function setUp() + { + $this->clientContext = Mockery::mock(ClientContext::class); $this->responseMock = Mockery::mock(Response::class); $this->requestObject = Mockery::mock(Request::class); $this->insuranceMock = Mockery::mock(Insurance::class)->makePartial(); @@ -346,7 +452,7 @@ protected function setUp() $this->insuranceMock->insuranceValidator = $this->insuranceValidatorMock; $this->arrayUtilsMock = Mockery::mock(ArrayUtils::class); - } + } protected function tearDown() { @@ -361,11 +467,11 @@ protected function tearDown() /** * @return void */ - public function testInsuranceEligibilityMethodExist() - { - $insurance = new Insurance($this->clientContext); - $this->assertTrue(method_exists($insurance, 'getInsuranceContract')); - } + public function testInsuranceEligibilityMethodExist() + { + $insurance = new Insurance($this->clientContext); + $this->assertTrue(method_exists($insurance, 'getInsuranceContract')); + } /** * @dataProvider requestDataProviderRightParams @@ -378,8 +484,8 @@ public function testInsuranceEligibilityMethodExist() * @throws RequestException * @throws RequestError */ - public function testGetRequestIsCalled($insuranceContractExternalId, $cmsReference, $productPrice) - { + public function testGetRequestIsCalled($insuranceContractExternalId, $cmsReference, $productPrice) + { $this->responseMock->shouldReceive('isError')->once()->andReturn(false); $this->requestObject->shouldReceive('get')->once()->andReturn($this->responseMock); @@ -393,7 +499,7 @@ public function testGetRequestIsCalled($insuranceContractExternalId, $cmsReferen ->with($cmsReference, $insuranceContractExternalId, $productPrice); $this->insuranceMock->getInsuranceContract($insuranceContractExternalId, $cmsReference, $productPrice); - } + } /** * @dataProvider requestDataProvider @@ -423,29 +529,28 @@ public function testThrowParametersExceptionWithWrongParams($insuranceContractEx * @throws RequestError * @throws RequestException */ - public function testApiResponseErrorThrowRequestException() - { + public function testApiResponseErrorThrowRequestException() + { $insuranceContractExternalId = 'insurance_contract_6XxGHbjr51CE5Oly8E2Amx'; - $cmsReference = '18-24'; + $cmsReference = '18-24'; $productPrice = 10000; $this->responseMock->shouldReceive('isError')->once()->andReturn(true); - $requestObject = Mockery::mock(Request::class)->shouldAllowMockingProtectedMethods(); - $requestObject->shouldReceive('get')->once()->andReturn($this->responseMock); + $requestObject = Mockery::mock(Request::class)->shouldAllowMockingProtectedMethods(); + $requestObject->shouldReceive('get')->once()->andReturn($this->responseMock); $requestObject->shouldReceive('setQueryParams')->once()->andReturn($requestObject); $this->insuranceMock->shouldReceive('request') - ->with(self::INSURANCE_CONTRACTS_PATH . $insuranceContractExternalId) - ->once() - ->andReturn($requestObject) - ; + ->with(self::INSURANCE_CONTRACTS_PATH . $insuranceContractExternalId) + ->once() + ->andReturn($requestObject); $this->insuranceMock->setClientContext($this->clientContext); $this->insuranceMock->shouldReceive('checkParameters')->once(); - $this->expectException(RequestException::class); + $this->expectException(RequestException::class); $this->insuranceMock->getInsuranceContract($insuranceContractExternalId, $cmsReference, $productPrice); - } + } /** * @dataProvider requestDataProviderRightParams @@ -548,7 +653,7 @@ public function testSubscriptionThrowExceptionIfNotArrayInParam($nonArrayParam, { $insurance = new Insurance($this->clientContext); $this->expectException(ParametersException::class); - $insurance->subscription($nonArrayParam, $nonStringPaymentId); + $insurance->subscription($nonArrayParam, 'orderID', $nonStringPaymentId); } /** @@ -575,21 +680,29 @@ public function testSubscriptionThrowExceptionRequestError($subscriptionArray) ->andReturn($requestObject); $insurance->setClientContext($this->clientContext); $this->expectException(RequestException::class); - $insurance->subscription($subscriptionArray); + $insurance->subscription($subscriptionArray, 'orderId'); } /** * @dataProvider subscriptionDataProvider * @param $subscriptionArray * @param $paymentId + * @param $expectedSubscriptionPayload * @throws ParametersException * @throws RequestError * @throws RequestException */ - public function testSubscriptionGetRequestCall($subscriptionArray, $paymentId) + public function testSubscriptionGetRequestCall($subscriptionArray, $paymentId, $expectedSubscriptionPayload) { + $expectedSubscriptionPayload['order_id'] = 'myOrderId'; + + if ($paymentId) { + $expectedSubscriptionPayload['payment_id'] = $paymentId; + } $this->responseMock->shouldReceive('isError')->once()->andReturn(false); - $this->requestObject->shouldReceive('setRequestBody')->andReturn($this->requestObject); + $this->requestObject->shouldReceive('setRequestBody')->once() + ->with($expectedSubscriptionPayload) + ->andReturn($this->requestObject); $this->requestObject->shouldReceive('post')->once()->andReturn($this->responseMock); $insurance = Mockery::mock(Insurance::class)->shouldAllowMockingProtectedMethods()->makePartial(); @@ -598,7 +711,7 @@ public function testSubscriptionGetRequestCall($subscriptionArray, $paymentId) ->once() ->andReturn($this->requestObject); $insurance->setClientContext($this->clientContext); - $insurance->subscription($subscriptionArray, $paymentId); + $insurance->subscription($subscriptionArray, 'myOrderId', $paymentId); } /** @@ -694,4 +807,114 @@ public function testGetSubscriptionsReturnApiResponse($subscriptionIds, $json) $this->assertEquals($json, $this->insuranceMock->getSubscription($subscriptionIds)); } + + /** + * @return void + * @throws RequestError + */ + public function testGivenInvalidCmsReferenceArrayNoCallEndpointAndReturnFalse() + { + $this->insuranceValidatorMock->shouldReceive('checkCmsReference') + ->once() + ->andThrow(ParametersException::class); + $loggerMock = Mockery::mock(LoggerInterface::class); + $loggerMock->shouldReceive('error')->once(); + $this->clientContext->logger = $loggerMock; + $this->insuranceMock->setClientContext($this->clientContext); + $this->assertNull($this->insuranceMock->sendCustomerCart(['123','456'], 42)); + } + + /** + * @return void + * @throws ParametersException + * @throws RequestError + * @throws RequestException + */ + public function testCancelSubscriptionCallRequestWithSubscriptionArrayPayloadAndNoThrowExceptionForResponse200() + { + $subscriptionCancelPayload = ' subscriptionId1 '; + $this->responseMock->shouldReceive('isError')->once()->andReturn(false); + $this->requestObject->shouldReceive('post')->once()->andReturn($this->responseMock); + $this->insuranceMock->shouldReceive('request') + ->with(self::INSURANCE_SUBSCRIPTIONS_PATH . '/subscriptionId1/void') + ->once() + ->andReturn($this->requestObject); + $this->insuranceMock->cancelSubscription($subscriptionCancelPayload); + } + + /** + * @return void + * @throws RequestError + */ + public function testSendCustomerCartCallApiPostCustomerCartWithCmsReferencesArray() + { + $cartId = 42; + $this->insuranceValidatorMock->shouldReceive('checkCmsReference') + ->once(); + $this->requestObject->shouldReceive('setRequestBody')->once()->with( + [ + 'cms_references' => ['123','456'] + ] + )->andReturn($this->requestObject); + $this->insuranceMock->shouldReceive('request') + ->with(self::INSURANCE_CUSTOMER_CART_PATH) + ->once() + ->andReturn($this->requestObject); + $this->insuranceMock->shouldReceive('addCustomerSessionToRequest')->once()->with( + $this->requestObject, + null, + $cartId + ); + $this->requestObject->shouldReceive('post')->once(); + $this->assertNull($this->insuranceMock->sendCustomerCart(['123','456'], $cartId)); + } + + /** + * @return void + * @throws ParametersException + * @throws RequestError + * @throws RequestException + */ + public function testCancelSubscriptionCallRequestWithSubscriptionArrayPayloadAndThrowExceptionForResponseUpperThan400() + { + $this->expectException(RequestException::class); + $subscriptionCancelPayload = 'subscriptionId1'; + $this->responseMock->shouldReceive('isError')->once()->andReturn(true); + $this->requestObject->shouldReceive('post')->once()->andReturn($this->responseMock); + $this->insuranceMock->shouldReceive('request') + ->with(self::INSURANCE_SUBSCRIPTIONS_PATH . '/subscriptionId1/void') + ->once() + ->andReturn($this->requestObject); + $this->insuranceMock->cancelSubscription($subscriptionCancelPayload); + } + + /** + * @dataProvider cancelSubscriptionErrorPayloadDataProvider + * @param $payload + * @return void + * @throws ParametersException + */ + public function testCheckSubscriptionIdFormatThrowParamsErrorForBadPayload($payload) + { + $this->expectException(ParametersException::class); + $this->insuranceMock->checkSubscriptionIdFormat($payload); + } + + public function cancelSubscriptionErrorPayloadDataProvider() + { + return [ + 'Null payload' => [ + 'subscriptionIdsArray' => null + ], + 'empty string payload' => [ + 'subscriptionIdsArray' => '' + ], + 'empty array payload' => [ + 'subscriptionIdsArray' => [] + ], + 'Subscription Object payload' => [ + 'subscriptionIdsArray' => $this->createMock(Subscription::class) + ], + ]; + } } diff --git a/tests/Unit/Legacy/Lib/InsuranceValidatorTest.php b/tests/Unit/Legacy/Lib/InsuranceValidatorTest.php new file mode 100644 index 00000000..3fa266a8 --- /dev/null +++ b/tests/Unit/Legacy/Lib/InsuranceValidatorTest.php @@ -0,0 +1,77 @@ +insuranceValidator = new InsuranceValidator(); + } + + /** + * @dataProvider checkCmsReferenceInvalidPayloadDataProvider + * @param $invalidPayload + * @return void + * @throws ParametersException + */ + public function testCheckCmsReferenceWithInvalidPayloadThrowParameterException($invalidPayload) + { + $this->expectException(ParametersException::class); + $this->insuranceValidator->checkCmsReference($invalidPayload); + } + + /** + * @throws ParametersException + */ + public function testCheckCmsReferenceWithValidPayload() + { + $this->assertNull($this->insuranceValidator->checkCmsReference(['123', '456'])); + } + + /** + * @return array + */ + public function checkCmsReferenceInvalidPayloadDataProvider() + { + return [ + 'String payload' => + [ + 'payload' => 'mb-024, mb-048' + ], + 'Empty string payload' => + [ + 'payload' => '' + ], + 'Object payload' => + [ + 'payload' => new \stdClass() + ], + 'Empty array' => + [ + 'payload' => [] + ], + 'Int payload' => + [ + 'payload' => 123 + ], + 'Bool payload' => [ + 'payload' => true + ], + 'Object payload in array' => [ + 'payload' => ['1236', new \stdClass()] + ], + ]; + } +}