Skip to content

Commit 470e79f

Browse files
Add behat scenario to test no generation invoice for order without number (#396)
| Q | A |-----------------|----- | Branch? | 2.1 | Bug fix? | no | New feature? | yes | BC breaks? | no | Deprecations? | no | Related tickets | #159 | License | MIT
2 parents 31765e1 + 88d1443 commit 470e79f

3 files changed

Lines changed: 67 additions & 14 deletions

File tree

features/managing_invoices/generating_invoices_for_previously_placed_orders.feature

Lines changed: 25 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -4,20 +4,26 @@ Feature: Generating invoices for previously placed orders
44
As a Shop Owner
55
I want to easily generate invoices for orders placed before installation of the plugin
66

7-
Background:
8-
Given the store operates on a single channel in "United States"
9-
And the store has "VAT" tax rate of 10% for "Clothes" within the "US" zone
10-
And the store has a product "Angel T-Shirt" priced at "$60.00"
11-
And it belongs to "Clothes" tax category
12-
And the store has "UPS" shipping method with "$10.00" fee
13-
And the store allows paying with "Cash on Delivery"
14-
And there is a customer "lucy@teamlucifer.com" that placed an order "#00000777"
15-
And the customer bought 2 "Angel T-Shirt" products
16-
And the customer "Lucifer Morningstar" addressed it to "Seaside Fwy", "90802" "Los Angeles" in the "United States"
17-
And for the billing address of "Mazikeen Lilim" in the "Pacific Coast Hwy", "90806" "Los Angeles", "United States"
18-
And the customer chose "UPS" shipping method with "Cash on Delivery" payment
19-
And the order "#00000777" has lost all of its invoices
20-
And I am logged in as an administrator
7+
Background:
8+
Given the store operates on a single channel in "United States"
9+
And the store has "VAT" tax rate of 10% for "Clothes" within the "US" zone
10+
And the store has a product "Angel T-Shirt" priced at "$60.00"
11+
And it belongs to "Clothes" tax category
12+
And the store has "UPS" shipping method with "$10.00" fee
13+
And the store allows paying with "Cash on Delivery"
14+
And there is a customer "lucy@teamlucifer.com" that placed an order "#00000777"
15+
And the customer bought 2 "Angel T-Shirt" products
16+
And the customer "Lucifer Morningstar" addressed it to "Seaside Fwy", "90802" "Los Angeles" in the "United States"
17+
And for the billing address of "Mazikeen Lilim" in the "Pacific Coast Hwy", "90806" "Los Angeles", "United States"
18+
And the customer chose "UPS" shipping method with "Cash on Delivery" payment
19+
And there is a customer "chloe@lapd.com" that placed an order
20+
And the customer bought 1 "Angel T-Shirt" products
21+
And the customer "Chloe Decker" addressed it to "Wilshire Blvd", "90010" "Los Angeles" in the "United States"
22+
And for the billing address of "Chloe Decker" in the "Wilshire Blvd", "90010" "Los Angeles", "United States"
23+
And the customer chose "UPS" shipping method with "Cash on Delivery" payment
24+
And this order has no number assigned
25+
And all invoices have been deleted
26+
And I am logged in as an administrator
2127

2228
Scenario: Having no previous invoices
2329
When I browse invoices
@@ -27,3 +33,8 @@ Feature: Generating invoices for previously placed orders
2733
When I generate invoices for previously placed orders
2834
And I browse invoices
2935
Then I should see a single invoice for order "#00000777"
36+
37+
Scenario: Not generating invoices for orders without number
38+
When I generate invoices for previously placed orders
39+
And I browse invoices
40+
Then there should be 1 invoice generated

tests/Behat/Context/Domain/GeneratingInvoiceContext.php

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,14 @@
11
<?php
22

3+
/*
4+
* This file is part of the Sylius package.
5+
*
6+
* (c) Sylius Sp. z o.o.
7+
*
8+
* For the full copyright and license information, please view the LICENSE
9+
* file that was distributed with this source code.
10+
*/
11+
312
declare(strict_types=1);
413

514
namespace Tests\Sylius\InvoicingPlugin\Behat\Context\Domain;
@@ -29,4 +38,18 @@ public function orderHasLostAllOfItsInvoices(string $orderNumber): void
2938

3039
$this->invoiceManager->remove($invoice);
3140
}
41+
42+
/**
43+
* @Given all invoices have been deleted
44+
*/
45+
public function allInvoicesHaveBeenDeleted(): void
46+
{
47+
$invoices = $this->invoiceRepository->findAll();
48+
49+
foreach ($invoices as $invoice) {
50+
$this->invoiceManager->remove($invoice);
51+
}
52+
53+
$this->invoiceManager->flush();
54+
}
3255
}

tests/Behat/Context/Setup/OrderContext.php

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,14 @@
11
<?php
22

3+
/*
4+
* This file is part of the Sylius package.
5+
*
6+
* (c) Sylius Sp. z o.o.
7+
*
8+
* For the full copyright and license information, please view the LICENSE
9+
* file that was distributed with this source code.
10+
*/
11+
312
declare(strict_types=1);
413

514
namespace Tests\Sylius\InvoicingPlugin\Behat\Context\Setup;
@@ -27,4 +36,14 @@ public function orderHasBeenPlacedInChannel(OrderInterface $order, ChannelInterf
2736

2837
$this->orderManager->flush();
2938
}
39+
40+
/**
41+
* @Given /^(this order) has no number assigned$/
42+
*/
43+
public function orderHasNoNumberAssigned(OrderInterface $order): void
44+
{
45+
$order->setNumber(null);
46+
47+
$this->orderManager->flush();
48+
}
3049
}

0 commit comments

Comments
 (0)