-
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] Fix placed order creation in test env
- Loading branch information
1 parent
1cc6ac6
commit 0e445e4
Showing
8 changed files
with
128 additions
and
135 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
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,51 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
namespace Tests\Sylius\ShopApiPlugin\Controller\Utils; | ||
|
||
use Sylius\ShopApiPlugin\Command\Cart\AddressOrder; | ||
use Sylius\ShopApiPlugin\Command\Cart\ChoosePaymentMethod; | ||
use Sylius\ShopApiPlugin\Command\Cart\ChooseShippingMethod; | ||
use Sylius\ShopApiPlugin\Command\Cart\CompleteOrder; | ||
use Sylius\ShopApiPlugin\Command\Cart\PickupCart; | ||
use Sylius\ShopApiPlugin\Command\Cart\PutSimpleItemToCart; | ||
use Sylius\ShopApiPlugin\Model\Address; | ||
use Symfony\Component\Messenger\MessageBusInterface; | ||
|
||
trait OrderPlacerTrait | ||
{ | ||
protected function placeOrderForCustomerWithEmail(string $email, string $token): void | ||
{ | ||
/** @var MessageBusInterface $bus */ | ||
$bus = $this->get('sylius_shop_api_plugin.command_bus'); | ||
$bus->dispatch(new PickupCart($token, 'WEB_GB')); | ||
$bus->dispatch(new PutSimpleItemToCart($token, 'LOGAN_MUG_CODE', 5)); | ||
$bus->dispatch(new AddressOrder( | ||
$token, | ||
Address::createFromArray([ | ||
'firstName' => 'Sherlock', | ||
'lastName' => 'Holmes', | ||
'city' => 'London', | ||
'street' => 'Baker Street 221b', | ||
'countryCode' => 'GB', | ||
'postcode' => 'NWB', | ||
'provinceName' => 'Greater London', | ||
]), Address::createFromArray([ | ||
'firstName' => 'Sherlock', | ||
'lastName' => 'Holmes', | ||
'city' => 'London', | ||
'street' => 'Baker Street 221b', | ||
'countryCode' => 'GB', | ||
'postcode' => 'NWB', | ||
'provinceName' => 'Greater London', | ||
]) | ||
)); | ||
$bus->dispatch(new ChooseShippingMethod($token, 0, 'DHL')); | ||
$bus->dispatch(new ChoosePaymentMethod($token, 0, 'PBC')); | ||
$bus->dispatch(new CompleteOrder($token, $email)); | ||
} | ||
|
||
/** Function is not typehinted because has to be compatible with \ApiTestCase\ApiTestCase::get($id) */ | ||
abstract protected function get($id); | ||
} |
This file was deleted.
Oops, something went wrong.
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
Oops, something went wrong.