-
Notifications
You must be signed in to change notification settings - Fork 42
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #149 from Setono/add-api-behat
Add first Behat scenario for API
- Loading branch information
Showing
15 changed files
with
223 additions
and
56 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
@managing_gift_cards | ||
Feature: Browsing existing gift cards | ||
In order to manage the existing gift cards | ||
As an Administrator | ||
I want to browse existing gift cards | ||
|
||
Background: | ||
Given the store operates on a single channel in "United States" | ||
And I am logged in as an administrator | ||
And the store has a gift card with code "GIFT-CARD-100" valued at "$100" | ||
And the store has a gift card with code "GIFT-CARD-200" valued at "$200" | ||
|
||
@api | ||
Scenario: Browsing gift cards | ||
When I browse gift cards | ||
Then I should see a gift card with code "GIFT-CARD-100" valued at "$100" | ||
And I should see a gift card with code "GIFT-CARD-200" valued at "$200" |
42 changes: 42 additions & 0 deletions
42
tests/Behat/Context/Api/Admin/ManagingGiftCardsContext.php
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,42 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
namespace Tests\Setono\SyliusGiftCardPlugin\Behat\Context\Api\Admin; | ||
|
||
use Behat\Behat\Context\Context; | ||
use Sylius\Behat\Client\ApiClientInterface; | ||
use Sylius\Behat\Client\ResponseCheckerInterface; | ||
use Webmozart\Assert\Assert; | ||
|
||
final class ManagingGiftCardsContext implements Context | ||
{ | ||
private ApiClientInterface $client; | ||
|
||
private ResponseCheckerInterface $responseChecker; | ||
|
||
public function __construct(ApiClientInterface $client, ResponseCheckerInterface $responseChecker) | ||
{ | ||
$this->client = $client; | ||
$this->responseChecker = $responseChecker; | ||
} | ||
|
||
/** | ||
* @When I browse gift cards | ||
*/ | ||
public function iBrowseGiftCards(): void | ||
{ | ||
$this->client->index(); | ||
} | ||
|
||
/** | ||
* @Then /^I should see a gift card with code "([^"]+)" valued at ("[^"]+")$/ | ||
*/ | ||
public function iShouldSeeGiftCardPricedAt(string $code, int $price): void | ||
{ | ||
$response = $this->client->show($code); | ||
|
||
$giftCardPrice = $this->responseChecker->getValue($response, 'amount'); | ||
Assert::same($price, $giftCardPrice); | ||
} | ||
} |
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,8 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
|
||
<container xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://symfony.com/schema/dic/services" | ||
xsi:schemaLocation="http://symfony.com/schema/dic/services http://symfony.com/schema/dic/services/services-1.0.xsd"> | ||
<imports> | ||
<import resource="api/clients.xml" /> | ||
</imports> | ||
</container> |
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,12 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
|
||
<container xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://symfony.com/schema/dic/services" | ||
xsi:schemaLocation="http://symfony.com/schema/dic/services http://symfony.com/schema/dic/services/services-1.0.xsd"> | ||
<services> | ||
<service id="setono_sylius_gift_card.behat.api_platform_client.admin.gift_card" | ||
class="Sylius\Behat\Client\ApiPlatformClient" parent="sylius.behat.api_platform_client"> | ||
<argument>gift-cards</argument> | ||
<argument>admin</argument> | ||
</service> | ||
</services> | ||
</container> |
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,14 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
|
||
<container xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://symfony.com/schema/dic/services" | ||
xsi:schemaLocation="http://symfony.com/schema/dic/services http://symfony.com/schema/dic/services/services-1.0.xsd"> | ||
<services> | ||
<defaults public="true"/> | ||
|
||
<service id="setono_sylius_gift_card.behat.context.api.admin.managing_gift_cards" | ||
class="Tests\Setono\SyliusGiftCardPlugin\Behat\Context\Api\Admin\ManagingGiftCardsContext"> | ||
<argument type="service" id="setono_sylius_gift_card.behat.api_platform_client.admin.gift_card" /> | ||
<argument type="service" id="Sylius\Behat\Client\ResponseCheckerInterface" /> | ||
</service> | ||
</services> | ||
</container> |
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,17 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
|
||
<container xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://symfony.com/schema/dic/services" | ||
xsi:schemaLocation="http://symfony.com/schema/dic/services http://symfony.com/schema/dic/services/services-1.0.xsd"> | ||
<services> | ||
<defaults public="true"/> | ||
|
||
<service id="setono_sylius_gift_card.behat.context.setup.gift_card" | ||
class="Tests\Setono\SyliusGiftCardPlugin\Behat\Context\Setup\GiftCardContext"> | ||
<argument type="service" id="sylius.behat.shared_storage"/> | ||
<argument type="service" id="setono_sylius_gift_card.repository.gift_card"/> | ||
<argument type="service" id="setono_sylius_gift_card.factory.gift_card"/> | ||
<argument type="service" id="setono_sylius_gift_card.manager.gift_card"/> | ||
<argument type="service" id="sylius.manager.product"/> | ||
</service> | ||
</services> | ||
</container> |
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,13 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
|
||
<container xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://symfony.com/schema/dic/services" | ||
xsi:schemaLocation="http://symfony.com/schema/dic/services http://symfony.com/schema/dic/services/services-1.0.xsd"> | ||
<services> | ||
<defaults public="true"/> | ||
|
||
<service id="setono_sylius_gift_card.behat.context.transform.gift_card" | ||
class="Tests\Setono\SyliusGiftCardPlugin\Behat\Context\Transform\GiftCardContext"> | ||
<argument type="service" id="setono_sylius_gift_card.repository.gift_card"/> | ||
</service> | ||
</services> | ||
</container> |
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,33 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
|
||
<container xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://symfony.com/schema/dic/services" | ||
xsi:schemaLocation="http://symfony.com/schema/dic/services http://symfony.com/schema/dic/services/services-1.0.xsd"> | ||
<services> | ||
<defaults public="true"/> | ||
|
||
<service id="setono_sylius_gift_card.behat.context.ui.admin.managing_gift_cards" | ||
class="Tests\Setono\SyliusGiftCardPlugin\Behat\Context\Ui\Admin\ManagingGiftCardsContext"> | ||
<argument type="service" id="setono_sylius_gift_card.behat.page.admin.product.create"/> | ||
</service> | ||
|
||
<service id="setono_sylius_gift_card.behat.context.ui.shop.checkout" | ||
class="Tests\Setono\SyliusGiftCardPlugin\Behat\Context\Ui\Shop\CheckoutContext"> | ||
<argument type="service" id="sylius.behat.context.ui.shop.checkout.complete"/> | ||
<argument type="service" id="sylius.behat.context.setup.order"/> | ||
<argument type="service" id="sylius.repository.order"/> | ||
<argument type="service" id="setono_sylius_gift_card.manager.gift_card"/> | ||
</service> | ||
|
||
<service id="setono_sylius_gift_card.behat.context.ui.shop.cart" | ||
class="Tests\Setono\SyliusGiftCardPlugin\Behat\Context\Ui\Shop\CartContext"> | ||
<argument type="service" id="setono_sylius_gift_card.behat.page.shop.cart.cart_summary"/> | ||
</service> | ||
|
||
<service id="setono_sylius_gift_card.behat.context.ui.email" | ||
class="Tests\Setono\SyliusGiftCardPlugin\Behat\Context\Ui\EmailContext"> | ||
<argument type="service" id="sylius.behat.email_checker"/> | ||
<argument type="service" id="sylius.repository.order"/> | ||
<argument type="service" id="setono_sylius_gift_card.repository.gift_card"/> | ||
</service> | ||
</services> | ||
</container> |
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,11 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
|
||
<container xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://symfony.com/schema/dic/services" | ||
xsi:schemaLocation="http://symfony.com/schema/dic/services http://symfony.com/schema/dic/services/services-1.0.xsd"> | ||
<imports> | ||
<import resource="context/api.xml" /> | ||
<import resource="context/setup.xml" /> | ||
<import resource="context/transform.xml" /> | ||
<import resource="context/ui.xml" /> | ||
</imports> | ||
</container> |
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,12 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
|
||
<container xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://symfony.com/schema/dic/services" | ||
xsi:schemaLocation="http://symfony.com/schema/dic/services http://symfony.com/schema/dic/services/services-1.0.xsd"> | ||
<services> | ||
<service id="setono_sylius_gift_card.behat.page.admin.product.create" | ||
class="Tests\Setono\SyliusGiftCardPlugin\Behat\Page\Admin\Product\CreateSimpleProductPage" | ||
parent="sylius.behat.page.admin.crud.create" public="false"> | ||
<argument type="string">setono_sylius_gift_card_admin_product_create_gift_card</argument> | ||
</service> | ||
</services> | ||
</container> |
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,10 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
|
||
<container xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://symfony.com/schema/dic/services" | ||
xsi:schemaLocation="http://symfony.com/schema/dic/services http://symfony.com/schema/dic/services/services-1.0.xsd"> | ||
<services> | ||
<service id="setono_sylius_gift_card.behat.page.shop.cart.cart_summary" | ||
class="Tests\Setono\SyliusGiftCardPlugin\Behat\Page\Shop\Cart\SummaryPage" | ||
parent="sylius.behat.page.shop.cart_summary" public="false"/> | ||
</services> | ||
</container> |
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,9 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
|
||
<container xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://symfony.com/schema/dic/services" | ||
xsi:schemaLocation="http://symfony.com/schema/dic/services http://symfony.com/schema/dic/services/services-1.0.xsd"> | ||
<imports> | ||
<import resource="page/admin.xml" /> | ||
<import resource="page/shop.xml" /> | ||
</imports> | ||
</container> |
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,18 @@ | ||
default: | ||
suites: | ||
api_managing_gift_cards: | ||
contexts: | ||
- sylius.behat.context.hook.doctrine_orm | ||
|
||
- sylius.behat.context.transform.lexical | ||
- sylius.behat.context.transform.shared_storage | ||
|
||
- sylius.behat.context.setup.admin_api_security | ||
- sylius.behat.context.setup.channel | ||
|
||
- setono_sylius_gift_card.behat.context.setup.gift_card | ||
- setono_sylius_gift_card.behat.context.transform.gift_card | ||
|
||
- setono_sylius_gift_card.behat.context.api.admin.managing_gift_cards | ||
filters: | ||
tags: "@managing_gift_cards && @api" |