mirror of
https://github.com/Sylius/Sylius.git
synced 2026-07-14 09:02:12 +00:00
cover tests
This commit is contained in:
parent
026094a5b3
commit
3e0183ca52
4 changed files with 52 additions and 2 deletions
|
|
@ -16,14 +16,14 @@ Feature: Resending an order confirmation email for a chosen order
|
||||||
And the customer chose "Free" shipping method with "Cash on Delivery" payment
|
And the customer chose "Free" shipping method with "Cash on Delivery" payment
|
||||||
And I am logged in as an administrator
|
And I am logged in as an administrator
|
||||||
|
|
||||||
@ui @email
|
@ui @email @api
|
||||||
Scenario: Resending a confirmation email for a given order
|
Scenario: Resending a confirmation email for a given order
|
||||||
When I view the summary of the order "#00000666"
|
When I view the summary of the order "#00000666"
|
||||||
And I resend the order confirmation email
|
And I resend the order confirmation email
|
||||||
Then I should be notified that the order confirmation email has been successfully resent to the customer
|
Then I should be notified that the order confirmation email has been successfully resent to the customer
|
||||||
And an email with the confirmation of the order "#00000666" should be sent to "lucy@teamlucifer.com"
|
And an email with the confirmation of the order "#00000666" should be sent to "lucy@teamlucifer.com"
|
||||||
|
|
||||||
@ui @email
|
@ui @email @api
|
||||||
Scenario: Sending a confirmation email after shipping an order in different locale than the default one
|
Scenario: Sending a confirmation email after shipping an order in different locale than the default one
|
||||||
Given the order "#00000666" has been placed in "Polish (Poland)" locale
|
Given the order "#00000666" has been placed in "Polish (Poland)" locale
|
||||||
When I view the summary of the order "#00000666"
|
When I view the summary of the order "#00000666"
|
||||||
|
|
|
||||||
|
|
@ -17,6 +17,7 @@ use ApiPlatform\Api\IriConverterInterface;
|
||||||
use Behat\Behat\Context\Context;
|
use Behat\Behat\Context\Context;
|
||||||
use Sylius\Behat\Client\ApiClientInterface;
|
use Sylius\Behat\Client\ApiClientInterface;
|
||||||
use Sylius\Behat\Client\RequestFactoryInterface;
|
use Sylius\Behat\Client\RequestFactoryInterface;
|
||||||
|
use Sylius\Behat\Client\RequestInterface;
|
||||||
use Sylius\Behat\Client\ResponseCheckerInterface;
|
use Sylius\Behat\Client\ResponseCheckerInterface;
|
||||||
use Sylius\Behat\Context\Api\Resources;
|
use Sylius\Behat\Context\Api\Resources;
|
||||||
use Sylius\Behat\Context\Api\Subresources;
|
use Sylius\Behat\Context\Api\Subresources;
|
||||||
|
|
@ -36,6 +37,7 @@ use Sylius\Component\Currency\Model\CurrencyInterface;
|
||||||
use Sylius\Component\Order\OrderTransitions;
|
use Sylius\Component\Order\OrderTransitions;
|
||||||
use Sylius\Component\Payment\PaymentTransitions;
|
use Sylius\Component\Payment\PaymentTransitions;
|
||||||
use Sylius\Component\Shipping\ShipmentTransitions;
|
use Sylius\Component\Shipping\ShipmentTransitions;
|
||||||
|
use Symfony\Component\HttpFoundation\Request as HttpRequest;
|
||||||
use Symfony\Component\HttpFoundation\Response;
|
use Symfony\Component\HttpFoundation\Response;
|
||||||
use Symfony\Component\Intl\Countries;
|
use Symfony\Component\Intl\Countries;
|
||||||
use Webmozart\Assert\Assert;
|
use Webmozart\Assert\Assert;
|
||||||
|
|
@ -51,6 +53,7 @@ final class ManagingOrdersContext implements Context
|
||||||
private SharedStorageInterface $sharedStorage,
|
private SharedStorageInterface $sharedStorage,
|
||||||
private SharedSecurityServiceInterface $sharedSecurityService,
|
private SharedSecurityServiceInterface $sharedSecurityService,
|
||||||
private SectionAwareIriConverterInterface $sectionAwareIriConverter,
|
private SectionAwareIriConverterInterface $sectionAwareIriConverter,
|
||||||
|
private string $apiUrlPrefix,
|
||||||
) {
|
) {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -139,6 +142,22 @@ final class ManagingOrdersContext implements Context
|
||||||
$this->client->addFilter('checkoutCompletedAt[before]', $dateTime);
|
$this->client->addFilter('checkoutCompletedAt[before]', $dateTime);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @When I resend the order confirmation email
|
||||||
|
*/
|
||||||
|
public function iResendTheOrderConfirmationEmail(): void
|
||||||
|
{
|
||||||
|
/** @var RequestInterface $request */
|
||||||
|
$request = $this->requestFactory->custom(
|
||||||
|
\sprintf('%s/admin/orders/resend-order-confirmation-email', $this->apiUrlPrefix),
|
||||||
|
HttpRequest::METHOD_POST,
|
||||||
|
);
|
||||||
|
|
||||||
|
$request->setContent(['orderToken' => $this->sharedStorage->get('order')->getTokenValue()]);
|
||||||
|
|
||||||
|
$this->client->executeCustomRequest($request);
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @When I filter by product :productName
|
* @When I filter by product :productName
|
||||||
* @When I filter by products :firstProduct and :secondProduct
|
* @When I filter by products :firstProduct and :secondProduct
|
||||||
|
|
@ -312,6 +331,14 @@ final class ManagingOrdersContext implements Context
|
||||||
Assert::same($this->responseChecker->countCollectionItems($this->client->getLastResponse()), $number);
|
Assert::same($this->responseChecker->countCollectionItems($this->client->getLastResponse()), $number);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @Then /^I should be notified that the (order|shipment) confirmation email has been successfully resent to the customer$/
|
||||||
|
*/
|
||||||
|
public function iShouldBeNotifiedThatTheOrderConfirmationEmailHasBeenSuccessfullyResentToTheCustomer(string $type): void
|
||||||
|
{
|
||||||
|
$this->responseChecker->isCreationSuccessful($this->client->getLastResponse());
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @Then I should be notified that it has been successfully updated
|
* @Then I should be notified that it has been successfully updated
|
||||||
*/
|
*/
|
||||||
|
|
|
||||||
|
|
@ -228,6 +228,7 @@
|
||||||
<argument type="service" id="sylius.behat.shared_storage" />
|
<argument type="service" id="sylius.behat.shared_storage" />
|
||||||
<argument type="service" id="sylius.behat.api.shared_security" />
|
<argument type="service" id="sylius.behat.api.shared_security" />
|
||||||
<argument type="service" id="sylius.behat.section_iri_converter" />
|
<argument type="service" id="sylius.behat.section_iri_converter" />
|
||||||
|
<argument>%sylius.security.new_api_route%</argument>
|
||||||
</service>
|
</service>
|
||||||
|
|
||||||
<service id="Sylius\Behat\Context\Api\Admin\ManagingPaymentMethodsContext">
|
<service id="Sylius\Behat\Context\Api\Admin\ManagingPaymentMethodsContext">
|
||||||
|
|
|
||||||
|
|
@ -290,6 +290,28 @@ final class OrdersTest extends JsonApiTestCase
|
||||||
$this->assertSame('/api/v2/admin/customers/' . $customerTony->getId(), json_decode($content)->customer);
|
$this->assertSame('/api/v2/admin/customers/' . $customerTony->getId(), json_decode($content)->customer);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/** @test */
|
||||||
|
public function it_resends_order_confirmation_email(): void
|
||||||
|
{
|
||||||
|
$this->loadFixturesFromFiles(['authentication/api_administrator.yaml', 'channel.yaml', 'cart.yaml', 'country.yaml', 'shipping_method.yaml', 'payment_method.yaml']);
|
||||||
|
|
||||||
|
$tokenValue = 'nAWw2jewpA';
|
||||||
|
|
||||||
|
$this->placeOrder($tokenValue);
|
||||||
|
|
||||||
|
$this->client->request(
|
||||||
|
method: 'POST',
|
||||||
|
uri: '/api/v2/admin/orders/resend-order-confirmation-email',
|
||||||
|
server: $this->buildHeaders('api@example.com'),
|
||||||
|
content: json_encode([
|
||||||
|
'orderToken' => $tokenValue,
|
||||||
|
]),
|
||||||
|
);
|
||||||
|
|
||||||
|
$this->assertResponseCode($this->client->getResponse(), Response::HTTP_ACCEPTED);
|
||||||
|
$this->assertEmailCount(2);
|
||||||
|
}
|
||||||
|
|
||||||
/** @return array<string, string> */
|
/** @return array<string, string> */
|
||||||
private function buildHeaders(string $adminEmail): array
|
private function buildHeaders(string $adminEmail): array
|
||||||
{
|
{
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue