Skip to content

Commit

Permalink
fix: CartInitiated throw error for empty string
Browse files Browse the repository at this point in the history
  • Loading branch information
Francois-Gomis committed Jan 24, 2025
1 parent 990eb0a commit aa609bb
Show file tree
Hide file tree
Showing 3 changed files with 3 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ class CartInitiatedBusinessEvent extends AbstractBusinessEvent
public function __construct($cartId)
{
$this->eventType = 'cart_initiated';
if(!is_string($cartId)){
if(empty($cartId) || !is_string($cartId)) {
throw new ParametersException('CartId must be a string');
}
$this->cartId = $cartId;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ class OrderConfirmedBusinessEvent extends AbstractBusinessEvent
* @param bool $wasBNPLEligible
* @param string $orderId
* @param string $cartId
* @param string | null $almaPaymentId
* @throws ParametersException
*/
public function __construct($isAlmaP1X, $isAlmaBNPL, $wasBNPLEligible, $orderId, $cartId, $almaPaymentId = null)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ public function testInvalidDataForBusinessEvent($cartId)
public static function invalidDataForBusinessEventDataProvider()
{
return [
"cartId is an empty string" => [''],
"cartId is an int" => [1],
"cartId is a float" => [1.1],
"cartId is an array" => [[]],
Expand Down

0 comments on commit aa609bb

Please sign in to comment.