Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: Not allow empty string for order confirmed business event construct #160

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -128,8 +128,8 @@ protected function validateData()
!is_bool($this->almaP1XStatus) ||
!is_bool($this->almaBNPLStatus) ||
!is_bool($this->wasBNPLEligible) ||
!is_string($this->orderId) ||
!is_string($this->cartId) ||
(!is_string($this->orderId) || empty($this->orderId)) ||
(!is_string($this->cartId) || empty($this->cartId)) ||
// Alma payment id should be absent for non Alma payments
(!$this->isAlmaPayment() && !is_null($this->almaPaymentId))
)
Expand All @@ -140,7 +140,7 @@ protected function validateData()
//Alma payment id for Alma payment, Must be a string
if(
$this->isAlmaPayment() &&
!is_string($this->almaPaymentId)
(!is_string($this->almaPaymentId) || empty($this->almaPaymentId))
)
{
throw new ParametersException('Alma payment id is mandatory for Alma payment');
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,11 @@ public function testAlmaPaymentIdIsMandatoryForBnplAlmaPayment()
$this->expectException(ParametersException::class);
new OrderConfirmedBusinessEvent(false, true, true, "42", "54");
}
public function testAlmaPaymentIdCanNotBeAnEmptyStringForAnAlmaPayment()
{
$this->expectException(ParametersException::class);
new OrderConfirmedBusinessEvent(false, true, true, "42", "54", "");
}

public function testAlmaPaymentIdShouldBeAbsentForNonAlmaPayments()
{
Expand Down Expand Up @@ -201,6 +206,13 @@ public static function invalidDataForBusinessEventDataProvider()
'orderId' => "1",
'cartId' => "1"
],
"Order id is empty string" => [
'isP1X' => false,
'isBNPL' => false,
'wasEligible' => true,
'orderId' => "",
'cartId' => "14"
],
"Order id is an int" => [
'isP1X' => false,
'isBNPL' => false,
Expand Down Expand Up @@ -271,6 +283,13 @@ public static function invalidDataForBusinessEventDataProvider()
'orderId' => '1',
'cartId' => new \stdClass()
],
"Cart id is empty string" => [
'isP1X' => false,
'isBNPL' => false,
'wasEligible' => true,
'orderId' => "1",
'cartId' => ""
],
];
}
}