mirror of
https://github.com/Sylius/Sylius.git
synced 2026-07-14 17:10:53 +00:00
Adding new Behat scenario
Fixing last glitches
This commit is contained in:
parent
09ea0f16ac
commit
4df1557fa5
8 changed files with 71 additions and 14 deletions
|
|
@ -27,8 +27,8 @@ Feature: User account orders page
|
|||
| Sticker | 10.00 | 213 |
|
||||
| Book | 22.50 | 948 |
|
||||
And the following orders exist:
|
||||
| user | shipment | address |
|
||||
| email@foo.com | UPS | Théophile Morel, 17 avenue Jean Portalis, 33000, Bordeaux, France |
|
||||
| user | shipment | address |
|
||||
| email@foo.com | UPS, shipped, DTBHH380HG | Théophile Morel, 17 avenue Jean Portalis, 33000, Bordeaux, France |
|
||||
| ianmurdock@debian.org | FedEx | Ian Murdock, 3569 New York Avenue, CA 92801, San Francisco, USA |
|
||||
| ianmurdock@debian.org | | Ian Murdock, 3569 New York Avenue, CA 92801, San Francisco, USA |
|
||||
| linustorvalds@linux.com | DHL | Linus Torvalds, Väätäjänniementie 59, 00440, Helsinki, Finland |
|
||||
|
|
@ -97,21 +97,41 @@ Feature: User account orders page
|
|||
|
||||
Scenario: Tracking an order that has been sent
|
||||
Given I am on my account orders page
|
||||
Then I should see "Tracking number" in the "order-000001" element
|
||||
And I should see an "order-000001-trackingNumber" element
|
||||
Then I should see "Tracking number DTBHH380HG" in the "#order-000001" element
|
||||
And I should see "Shipped" in the "#order-000001" element
|
||||
|
||||
Scenario: Trying to track an order that has not been sent
|
||||
Scenario Outline: Trying to track an order that has not been sent
|
||||
Given I am on my account orders page
|
||||
Then I should not see "Tracking number" in the "order-000007" element
|
||||
And I should not see an "order-000007-trackingNumber" element
|
||||
Then I should not see "Tracking number" in the "#order-<order>" element
|
||||
And I should see "<state>" in the "#order-<order>" element
|
||||
|
||||
Examples:
|
||||
| order | state |
|
||||
| 000006 | Placed at |
|
||||
| 000007 | Ready since |
|
||||
|
||||
Scenario: Tracking an order that has been sent in its details page
|
||||
Given I go to the order show page for 000001
|
||||
Then I should see "Tracking number DTBHH380HG" in the "#information" element
|
||||
And I should see "Shipped" in the "#information" element
|
||||
|
||||
Scenario Outline: Trying to track an order that has not been sent in its details page
|
||||
Given I go to the order show page for <order>
|
||||
Then I should not see "Tracking number" in the "#information" element
|
||||
And I should see "<state>" in the "#information" element
|
||||
|
||||
Examples:
|
||||
| order | state |
|
||||
| 000006 | Placed at |
|
||||
| 000007 | Ready since |
|
||||
|
||||
Scenario: Checking that an invoice is available for an order that has been sent
|
||||
Given I am on my account orders page
|
||||
Then I should see an "order-000001-invoice" element
|
||||
Then I should see an "#order-000001-invoice" element
|
||||
|
||||
Scenario: Checking that an invoice is not available for an order that has not been sent
|
||||
Given I am on my account orders page
|
||||
Then I should not see an "order-000007-invoice" element
|
||||
Then I should not see an "#order-000007-invoice" element
|
||||
|
||||
Scenario: Generating an invoice for an order that has been sent
|
||||
Given I go to the order invoice page for 000001
|
||||
|
|
@ -134,8 +154,7 @@ Feature: User account orders page
|
|||
| 000008 |
|
||||
| 000011 |
|
||||
|
||||
Scenario: Accessing an item from the detail of an order
|
||||
Scenario: Trying to access an inactive or deleted item from the detail of an order
|
||||
|
||||
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -375,4 +375,22 @@ class Order extends BaseOrder implements OrderInterface
|
|||
|
||||
return $last;
|
||||
}
|
||||
|
||||
/**
|
||||
* Tells is the invoice of the order can be generated.
|
||||
* @return bool
|
||||
*/
|
||||
public function isInvoiceAvailable()
|
||||
{
|
||||
if (null !== $lastShipment = $this->getLastShipment()) {
|
||||
if (in_array(
|
||||
$lastShipment->getState(),
|
||||
array(ShipmentInterface::STATE_RETURNED, ShipmentInterface::STATE_SHIPPED))
|
||||
) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -379,6 +379,10 @@ class DataContext extends BehatContext implements KernelAwareInterface
|
|||
$product->setTaxons($taxons);
|
||||
}
|
||||
|
||||
if (isset($data['deleted']) && 'yes' === $data['deleted']) {
|
||||
$product->setDeletedAt(new \DateTime());
|
||||
}
|
||||
|
||||
$manager->persist($product);
|
||||
}
|
||||
|
||||
|
|
@ -874,6 +878,12 @@ class DataContext extends BehatContext implements KernelAwareInterface
|
|||
$shipmentData = array_map('trim', $shipmentData);
|
||||
|
||||
$shipment->setMethod($this->getRepository('shipping_method')->findOneByName($shipmentData[0]));
|
||||
if (isset($shipmentData[1])) {
|
||||
$shipment->setState($shipmentData[1]);
|
||||
}
|
||||
if (isset($shipmentData[2])) {
|
||||
$shipment->setTracking($shipmentData[2]);
|
||||
}
|
||||
|
||||
return $shipment;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -74,6 +74,10 @@ class AccountController extends Controller
|
|||
$order = $this->findOrderOr404($number);
|
||||
$this->accessOrderOr403($order);
|
||||
|
||||
if (!$order->isInvoiceAvailable()) {
|
||||
throw $this->createNotFoundException('The invoice can not yet be generated');
|
||||
}
|
||||
|
||||
$html = $this->renderView('SyliusWebBundle:Frontend/Account:Order/invoice.html.twig', array(
|
||||
'order' => $order
|
||||
));
|
||||
|
|
|
|||
|
|
@ -56,7 +56,7 @@
|
|||
</trans-unit>
|
||||
<trans-unit id="c8ef7d21deddd3af65b3133e90259a0a28280b31" resname="sylius.account.order.placed_at">
|
||||
<source>sylius.account.order.placed_at</source>
|
||||
<target state="new">Placed at</target>
|
||||
<target state="new">Placed at %at%</target>
|
||||
</trans-unit>
|
||||
<trans-unit id="981296390775f985bda4c885accf8a3e131aa364" resname="sylius.account.order.shipment_mode">
|
||||
<source>sylius.account.order.shipment_mode</source>
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
<div class="row-fluid well well-small">
|
||||
<div class="row-fluid well well-small" id="information">
|
||||
<div class="span6">
|
||||
<strong>{{ 'sylius.account.order.created_at'|trans }} {{ order.createdAt|date() }}</strong><br><br>
|
||||
{#{{ 'sylius.account.order.shipment_mode'|trans }} <strong>TODO</strong><br>#}
|
||||
|
|
|
|||
|
|
@ -19,7 +19,7 @@
|
|||
</thead>
|
||||
<tbody>
|
||||
{% for order in orders %}
|
||||
<tr class="order">
|
||||
<tr class="order" id="order-{{ order.number }}">
|
||||
<td>{{ order.createdAt|date }}</td>
|
||||
<td>{{ order.number }}</td>
|
||||
<td>{{ order.total|sylius_money }}</td>
|
||||
|
|
@ -27,12 +27,16 @@
|
|||
{% include "SyliusWebBundle:Frontend/Account:Order/_state.html.twig" %}
|
||||
</td>
|
||||
<td>
|
||||
{% if order.isInvoiceAvailable %}
|
||||
{{ buttons.btn(
|
||||
path('sylius_account_order_invoice', {'number': order.number}),
|
||||
'',
|
||||
'order-' ~ order.number ~ '-invoice',
|
||||
'file'
|
||||
) }}
|
||||
{% else %}
|
||||
-
|
||||
{% endif %}
|
||||
</td>
|
||||
<td>
|
||||
{{ buttons.show(path('sylius_account_order_show', {'number': order.number}), '', 'order-' ~ order.number ~ '-details') }}
|
||||
|
|
|
|||
|
|
@ -6,10 +6,12 @@
|
|||
|
||||
{% include "SyliusWebBundle:Frontend/Account:Order/_detail.html.twig" %}
|
||||
|
||||
{% if order.isInvoiceAvailable %}
|
||||
{{ buttons.btn(
|
||||
path('sylius_account_order_invoice', {'number': order.number}),
|
||||
'sylius.account.order.download_invoice',
|
||||
'order-' ~ order.number ~ '-invoice',
|
||||
'file'
|
||||
) }}
|
||||
{% endif %}
|
||||
{% endblock %}
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue