Skip to content

Commit

Permalink
Add behat implementation and configuration
Browse files Browse the repository at this point in the history
  • Loading branch information
Tomanhez committed Mar 29, 2021
1 parent f11bfb5 commit bc19b70
Show file tree
Hide file tree
Showing 3 changed files with 75 additions and 0 deletions.
48 changes: 48 additions & 0 deletions src/Sylius/Behat/Context/Api/Shop/ProductReviewContext.php
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
use Sylius\Behat\Client\ResponseCheckerInterface;
use Sylius\Behat\Service\SharedStorageInterface;
use Sylius\Component\Product\Model\ProductInterface;
use Sylius\Component\Review\Model\ReviewInterface;
use Webmozart\Assert\Assert;

final class ProductReviewContext implements Context
Expand Down Expand Up @@ -78,4 +79,51 @@ public function iShouldNotSeeReviewTitledInTheList(string $title): void
{
Assert::isEmpty($this->responseChecker->getCollectionItemsWithValue($this->client->getLastResponse(), 'title', $title));
}

/**
* @When I add it
*/
public function iAddIt(): void
{
$this->client->create();
}

/**
* @When I want to review product :product
*/
public function iWantToReviewProduct(ProductInterface $product): void
{
$this->client->buildCreateRequest();
$this->client->addRequestData('productCode', $product->getCode());
}

/**
* @When I leave a comment :comment, titled :title as :email
* @When I leave a comment :comment, titled :title
*/
public function iLeaveACommentTitled(string $comment, string $title, ?string $email = null): void
{
$this->client->addRequestData('title', $title);
$this->client->addRequestData('comment', $comment);
$this->client->addRequestData('email', $email);
}

/**
* @When I rate it with :rating point(s)
*/
public function iRateItWithPoints(int $rating): void
{
$this->client->addRequestData('rating', $rating);
}

/**
* @Then I should be notified that my review is waiting for the acceptation
*/
public function iShouldBeNotifiedThatMyReviewIsWaitingForTheAcceptation(): void
{
Assert::same(
$this->responseChecker->getValue($this->client->getLastResponse(), 'status'),
ReviewInterface::STATUS_NEW
);
}
}
1 change: 1 addition & 0 deletions src/Sylius/Behat/Resources/config/suites.yml
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ imports:
- suites/api/locale/managing_locales.yml
- suites/api/order/managing_orders.yml
- suites/api/payment/managing_payments.yml
- suites/api/product/adding_product_review.yml
- suites/api/product/managing_product_association_types.yml
- suites/api/product/managing_product_options.yml
- suites/api/product/managing_product_reviews.yml
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
# This file is part of the Sylius package.
# (c) Paweł Jędrzejewski

default:
suites:
api_adding_product_review:
contexts:
- sylius.behat.context.hook.doctrine_orm

- sylius.behat.context.transform.channel
- sylius.behat.context.transform.customer
- sylius.behat.context.transform.lexical
- sylius.behat.context.transform.product
- sylius.behat.context.transform.shared_storage

- sylius.behat.context.setup.channel
- sylius.behat.context.setup.customer
- sylius.behat.context.setup.product
- sylius.behat.context.setup.product_review
- sylius.behat.context.setup.shop_api_security

- sylius.behat.context.api.shop.product
- sylius.behat.context.api.shop.product_review

filters:
tags: "@adding_product_review && @api"

0 comments on commit bc19b70

Please sign in to comment.