-
Notifications
You must be signed in to change notification settings - Fork 89
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[Tests] Enable test for addressing order with a wrong token
- Loading branch information
Showing
7 changed files
with
141 additions
and
13 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
namespace Sylius\ShopApiPlugin\Request\Checkout; | ||
|
||
use Sylius\ShopApiPlugin\Command\Cart\AddressOrder; | ||
use Sylius\ShopApiPlugin\Model\Address; | ||
use Symfony\Component\HttpFoundation\Request; | ||
|
||
class AddressOrderRequest | ||
{ | ||
/** @var string|null */ | ||
protected $token; | ||
|
||
/** @var array|null */ | ||
protected $shippingAddress; | ||
|
||
/** @var array|null */ | ||
protected $billingAddress; | ||
|
||
public function __construct(Request $request) | ||
{ | ||
$this->token = $request->attributes->get('token'); | ||
$this->shippingAddress = $request->request->get('shippingAddress'); | ||
$this->billingAddress = $request->request->get('billingAddress') ?: $request->request->get('shippingAddress'); | ||
} | ||
|
||
public function getCommand(): AddressOrder | ||
{ | ||
return new AddressOrder( | ||
$this->token, | ||
Address::createFromArray($this->shippingAddress), | ||
Address::createFromArray($this->billingAddress) | ||
); | ||
} | ||
|
||
public function getToken(): ?string | ||
{ | ||
return $this->token; | ||
} | ||
|
||
public function getShippingAddress(): ?array | ||
{ | ||
return $this->shippingAddress; | ||
} | ||
|
||
public function getBillingAddress(): ?array | ||
{ | ||
return $this->billingAddress; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
26 changes: 26 additions & 0 deletions
26
src/Resources/config/validation/checkout/AddressOrderRequest.xml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
|
||
<!-- | ||
This file is part of the Sylius package. | ||
(c) Paweł Jędrzejewski | ||
For the full copyright and license information, please view the LICENSE | ||
file that was distributed with this source code. | ||
--> | ||
|
||
<constraint-mapping xmlns="http://symfony.com/schema/dic/constraint-mapping" | ||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" | ||
xsi:schemaLocation="http://symfony.com/schema/dic/constraint-mapping http://symfony.com/schema/dic/services/constraint-mapping-1.0.xsd" | ||
> | ||
<class name="Sylius\ShopApiPlugin\Request\Checkout\AddressOrderRequest"> | ||
<property name="token"> | ||
<constraint name="NotNull"> | ||
<option name="message">sylius.shop_api.token.not_null</option> | ||
</constraint> | ||
<constraint name="Sylius\ShopApiPlugin\Validator\Constraints\CartExists" /> | ||
</property> | ||
</class> | ||
</constraint-mapping> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters