Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 7aa394d

Browse files
GSadeeAdamKasp
authored andcommitted
[Shipment] Fixes for setting shipped at date feature
1 parent d36d4a4 commit 7aa394d

9 files changed

Lines changed: 22 additions & 44 deletions

File tree

features/shipping/managing_shipments/setting_date_when_a_shipment_has been_shipped.feature

Lines changed: 0 additions & 23 deletions
This file was deleted.

features/shipping/managing_shipments/shipping_a_shipment_from_shipment_list.feature

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,6 @@ Feature: Shipping a shipment from shipment list
1313
And the customer bought a single "Apple"
1414
And the customer "Donald Duck" addressed it to "Elm street", "90802" "Duckburg" in the "United States" with identical billing address
1515
And the customer chose "UPS" shipping method with "Cash on Delivery" payment
16-
And it is "20-02-2020 10:30:05" now
1716
And I am logged in as an administrator
1817

1918
@ui @email
@@ -33,7 +32,7 @@ Feature: Shipping a shipment from shipment list
3332

3433
@ui
3534
Scenario: Setting date when a shipment has been shipped
36-
Given this order has already been shipped
35+
Given it is "20-02-2020 10:30:05" now
3736
When I browse shipments
3837
And I ship the shipment of order "#00000001"
3938
Then I should see the shipment of order "#00000001" as "Shipped"

psalm.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,8 +44,8 @@
4444
<directory name="src/Sylius/Bundle/PromotionBundle/test" />
4545
<directory name="src/Sylius/Bundle/PromotionBundle/Tests" />
4646
<directory name="src/Sylius/Bundle/ReviewBundle/spec" />
47-
<directory name="src/Sylius/Bundle/ShippingBundle/test" />
4847
<directory name="src/Sylius/Bundle/ShippingBundle/spec" />
48+
<directory name="src/Sylius/Bundle/ShippingBundle/test" />
4949
<directory name="src/Sylius/Bundle/ShopBundle/spec" />
5050
<directory name="src/Sylius/Bundle/TaxationBundle/spec" />
5151
<directory name="src/Sylius/Bundle/TaxationBundle/test" />

src/Sylius/Behat/Page/Admin/Order/ShowPage.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -379,7 +379,7 @@ public function resendShipmentConfirmationEmail(): void
379379

380380
public function getShippedAtDate(): string
381381
{
382-
return $this->getElement('shipment_shipping_at_date')->getText();
382+
return $this->getElement('shipment_shipped_at_date')->getText();
383383
}
384384

385385
protected function getDefinedElements(): array
@@ -400,7 +400,7 @@ protected function getDefinedElements(): array
400400
'promotion_total' => '#promotion-total',
401401
'resend_order_confirmation_email' => '[data-test-resend-order-confirmation-email]',
402402
'resend_shipment_confirmation_email' => '[data-test-resend-shipment-confirmation-email]',
403-
'shipment_shipping_at_date' => '#sylius-shipments .shipped-at-date',
403+
'shipment_shipped_at_date' => '#sylius-shipments .shipped-at-date',
404404
'shipments' => '#sylius-shipments',
405405
'shipping_address' => '#shipping-address',
406406
'shipping_adjustment_name' => '#shipping-adjustment-label',

src/Sylius/Behat/Resources/config/suites/ui/shipping/managing_shipments.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@ default:
66
- sylius.behat.context.hook.doctrine_orm
77
- sylius.behat.context.hook.email_spool
88

9-
- sylius.behat.context.setup.calendar
109
- sylius.behat.context.transform.address
1110
- sylius.behat.context.transform.channel
1211
- sylius.behat.context.transform.country
@@ -19,14 +18,15 @@ default:
1918
- sylius.behat.context.transform.zone
2019

2120
- sylius.behat.context.setup.admin_security
21+
- sylius.behat.context.setup.calendar
2222
- sylius.behat.context.setup.channel
2323
- sylius.behat.context.setup.geographical
2424
- sylius.behat.context.setup.order
2525
- sylius.behat.context.setup.payment
2626
- sylius.behat.context.setup.product
2727
- sylius.behat.context.setup.shipping
2828
- sylius.behat.context.setup.zone
29-
29+
3030
- sylius.behat.context.ui.channel
3131
- sylius.behat.context.ui.email
3232

src/Sylius/Behat/Service/Provider/Calendar.php

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -27,11 +27,14 @@ public function __construct(string $projectDirectory)
2727

2828
public function today(): \DateTimeInterface
2929
{
30-
/** @var resource $file */
31-
$file = fopen($this->projectDirectory . '/var/temporaryDate.txt', 'r');
32-
$dateTime = fgets($file);
33-
fclose($file);
30+
if (file_exists($this->projectDirectory . '/var/temporaryDate.txt')) {
31+
$file = fopen($this->projectDirectory . '/var/temporaryDate.txt', 'r');
32+
$dateTime = fgets($file);
33+
fclose($file);
3434

35-
return new \DateTimeImmutable($dateTime);
35+
return new \DateTimeImmutable($dateTime);
36+
}
37+
38+
return new \DateTimeImmutable();
3639
}
3740
}

src/Sylius/Bundle/AdminBundle/Resources/views/Order/Show/_shipment.html.twig

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
<i class="globe icon"></i>{{ shipment.method.zone }}
1616
</div>
1717
{% if shipment.shippedAt is not empty %}
18-
{{ 'sylius.ui.shipped_at'|trans }}: <span class="shipped-at-date">{{ shipment.shippedAt|date('d-m-Y H:i:s') }}</span>
18+
{{ 'sylius.ui.shipped_at'|trans }}: <span class="shipped-at-date">{{ shipment.shippedAt|date('d-m-Y H:i:s') }}</span>
1919
{% endif %}
2020
</div>
2121
{% if sm_can(shipment, 'ship', 'sylius_shipment') %}

src/Sylius/Bundle/ShippingBundle/spec/Assigner/ShipmentShippedAtDateAssignerSpec.php renamed to src/Sylius/Bundle/ShippingBundle/spec/Assigner/ShippingDateAssignerSpec.php

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,10 +11,9 @@
1111

1212
declare(strict_types=1);
1313

14-
namespace spec\Sylius\Bundle\ShippingBundle\DateAssigner;
14+
namespace spec\Sylius\Bundle\ShippingBundle\Assigner;
1515

1616
use PhpSpec\ObjectBehavior;
17-
use Prophecy\Argument;
1817
use Sylius\Bundle\ShippingBundle\Assigner\ShippingDateAssignerInterface;
1918
use Sylius\Bundle\ShippingBundle\Provider\DateTimeProvider;
2019
use Sylius\Component\Shipping\Model\ShipmentInterface;
@@ -31,7 +30,7 @@ function let(DateTimeProvider $calendar): void
3130
$this->beConstructedWith($calendar);
3231
}
3332

34-
function it_assigns_a_shipped_at_date_to_an_shipment(ShipmentInterface $shipment, DateTimeProvider $calendar): void
33+
function it_assigns_a_shipped_at_date_to_a_shipment(ShipmentInterface $shipment, DateTimeProvider $calendar): void
3534
{
3635
$calendar->today()->willReturn(new \DateTime('20-05-2019 20:20:20'));
3736
$shipment->setShippedAt(new \DateTime('20-05-2019 20:20:20'))->shouldBeCalled();

src/Sylius/Bundle/ShippingBundle/spec/Provider/CalendarSpec.php

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -11,20 +11,20 @@
1111

1212
declare(strict_types=1);
1313

14-
namespace Sylius\Bundle\ShippingBundle\spec\Provider;
14+
namespace spec\Sylius\Bundle\ShippingBundle\Provider;
1515

1616
use PhpSpec\ObjectBehavior;
17-
use Sylius\Bundle\ShippingBundle\Assigner\ShippingDateAssignerInterface;
17+
use Sylius\Bundle\ShippingBundle\Provider\DateTimeProvider;
1818

1919
final class CalendarSpec extends ObjectBehavior
2020
{
2121
function it_implements_a_date_time_provider(): void
2222
{
23-
$this->shouldImplement(ShippingDateAssignerInterface::class);
23+
$this->shouldImplement(DateTimeProvider::class);
2424
}
2525

26-
function it_provide_a_date(): void
26+
function it_provides_a_date(): void
2727
{
28-
$this->today()->shouldReturn(typeOf(new \DateTimeImmutable()));
28+
$this->today()->shouldBeAnInstanceOf(\DateTimeImmutable::class);
2929
}
3030
}

0 commit comments

Comments
 (0)