Skip to content

Commit

Permalink
Merge branch 'main' into op-266
Browse files Browse the repository at this point in the history
  • Loading branch information
SzymonKostrubiec authored Jul 17, 2024
2 parents 82b40df + f1ea70d commit ce77a9d
Show file tree
Hide file tree
Showing 22 changed files with 606 additions and 100 deletions.
3 changes: 2 additions & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,8 @@
"symfony/browser-kit": "4.1.8",
"symfony/dom-crawler": "4.1.8",
"symfony/routing": "4.1.8",
"symfony/doctrine-bridge": "4.4.16"
"symfony/doctrine-bridge": "4.4.16",
"behat/mink-selenium2-driver": ">=1.7.0"
},
"config": {
"sort-packages": true,
Expand Down
5 changes: 4 additions & 1 deletion doc/known_issues.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,4 +19,7 @@ is issue caused by circular reference between `pagerfantaDefault.css` and it's l

#### Workaround ####

* Use both commands `assets:install` and `sylius:theme:assets:install` without `--symlink` option
* Use both commands `assets:install` and `sylius:theme:assets:install` without `--symlink` option

### Sandbox - Select inPost point ###
* When you place an order in the test environment, make sure that you select a parcel collection point from the map of the Sandbox. You can find the map of available collection points in the test environment at https://sandbox-manager.paczkomaty.pl. Selecting a point that doesn't exist on the test map may result in errors.
8 changes: 4 additions & 4 deletions spec/Api/WebClientSpec.php
Original file line number Diff line number Diff line change
Expand Up @@ -18,11 +18,11 @@

final class WebClientSpec extends ObjectBehavior
{
const ORGANIZATION_ID = '123456';
public const ORGANIZATION_ID = '123456';

const API_ENDPOINT = 'https://api-shipx-pl.easypack24.net/v1';
public const API_ENDPOINT = 'https://api-shipx-pl.easypack24.net/v1';

const POINT_NAME = 'AAA666';
public const POINT_NAME = 'AAA666';

const LABEL_TYPE = 'normal';

Expand All @@ -33,7 +33,7 @@ function let(Client $client): void
$this->beConstructedWith($client, self::LABEL_TYPE, self::PARCEL_TEMPLATE);
}

function it_is_initializable(): void
public function it_is_initializable(): void
{
$this->shouldHaveType(WebClient::class);
$this->shouldImplement(WebClientInterface::class);
Expand Down
8 changes: 4 additions & 4 deletions spec/Checker/ShippingMethodCheckerSpec.php
Original file line number Diff line number Diff line change
Expand Up @@ -22,13 +22,13 @@ class ShippingMethodCheckerSpec extends ObjectBehavior
{
public const NOT_INPOST = 'not_inpost';

function it_is_initializable(): void
public function it_is_initializable(): void
{
$this->shouldHaveType(ShippingMethodChecker::class);
$this->shouldBeAnInstanceOf(ShippingMethodCheckerInterface::class);
}

function it_should_return_true_if_shipping_method_is_inpost(): void
public function it_should_return_true_if_shipping_method_is_inpost(): void
{
$shippingMethod = ShippingMethodBuilder::create()
->withCode(ShippingExportEventListener::INPOST_SHIPPING_GATEWAY_CODE)
Expand All @@ -39,7 +39,7 @@ function it_should_return_true_if_shipping_method_is_inpost(): void
$this->isInPost($order)->shouldReturn(true);
}

function it_should_return_true_if_shipping_method_is_inpost_point(): void
public function it_should_return_true_if_shipping_method_is_inpost_point(): void
{
$shippingMethod = ShippingMethodBuilder::create()
->withCode(ShippingExportEventListener::INPOST_POINT_SHIPPING_GATEWAY_CODE)
Expand All @@ -50,7 +50,7 @@ function it_should_return_true_if_shipping_method_is_inpost_point(): void
$this->isInPost($order)->shouldReturn(true);
}

function it_should_return_false_if_shipping_method_is_not_inpost(): void
public function it_should_return_false_if_shipping_method_is_not_inpost(): void
{
$shippingMethod = ShippingMethodBuilder::create()
->withCode(self::NOT_INPOST)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,20 +20,20 @@ final class InPostShippingExportActionProviderSpec extends ObjectBehavior
{
private const FOO = 'foo';

function let(
public function let(
InPostShippingExportActionInterface $action1,
InPostShippingExportActionInterface $action2
): void {
$this->beConstructedWith([$action1, $action2]);
}

function it_is_initializable(): void
public function it_is_initializable(): void
{
$this->shouldHaveType(InPostShippingExportActionProvider::class);
$this->shouldBeAnInstanceOf(InPostShippingExportActionProviderInterface::class);
}

function it_should_throw_exception_if_no_action_supports_passed_status_code(
public function it_should_throw_exception_if_no_action_supports_passed_status_code(
InPostShippingExportActionInterface $action1,
InPostShippingExportActionInterface $action2
): void {
Expand All @@ -43,7 +43,7 @@ function it_should_throw_exception_if_no_action_supports_passed_status_code(
$this->shouldThrow(\InvalidArgumentException::class)->during('provide', [self::FOO]);
}

function it_should_return_first_supported_action(
public function it_should_return_first_supported_action(
InPostShippingExportActionInterface $action1,
InPostShippingExportActionInterface $action2
): void {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,9 @@
use Prophecy\Argument;
use Sylius\Component\Core\Model\ShipmentInterface;
use Symfony\Component\Filesystem\Filesystem;
use Symfony\Component\HttpFoundation\RequestStack;
use Symfony\Component\HttpFoundation\Session\Flash\FlashBagInterface;
use Symfony\Component\HttpFoundation\Session\SessionInterface;
use Tests\BitBag\SyliusInPostPlugin\Spec\Builder\OrderBuilder;
use Tests\BitBag\SyliusInPostPlugin\Spec\Builder\ShipmentBuilder;
use Tests\BitBag\SyliusInPostPlugin\Spec\Builder\ShippingExportBuilder;
Expand All @@ -39,40 +41,40 @@ class InPostShippingExportConfirmedActionSpec extends ObjectBehavior

private const ORDER_NUMBER = '0000000001';

function let(
public function let(
ShippingExportRepositoryInterface $shippingExportRepository,
WebClientInterface $webClient,
Filesystem $filesystem,
FlashBagInterface $flashBag
RequestStack $requestStack
): void {
$this->beConstructedWith($shippingExportRepository, $webClient, $filesystem, $flashBag, self::SHIPPING_LABELS_PATH);
$this->beConstructedWith($shippingExportRepository, $webClient, $filesystem, $requestStack, self::SHIPPING_LABELS_PATH);
}

function it_is_initializable(): void
public function it_is_initializable(): void
{
$this->shouldHaveType(InPostShippingExportConfirmedAction::class);
$this->shouldBeAnInstanceOf(InPostShippingExportActionInterface::class);
}

function it_should_support_the_correct_status_code(): void
public function it_should_support_the_correct_status_code(): void
{
$this->supports(self::CONFIRMED)->shouldReturn(true);
}

function it_should_not_support_the_incorrect_status_code(): void
public function it_should_not_support_the_incorrect_status_code(): void
{
$this->supports(self::FOO)->shouldReturn(false);
}

function it_should_throw_exception_if_shipment_external_id_is_null(): void
public function it_should_throw_exception_if_shipment_external_id_is_null(): void
{
$shippingExport = ShippingExportBuilder::create()->build();
$this
->shouldThrow(InvalidArgumentException::class)
->during('execute', [$shippingExport]);
}

function it_should_throw_exception_if_shipment_is_null(): void
public function it_should_throw_exception_if_shipment_is_null(): void
{
$shippingExport = ShippingExportBuilder::create()->withExternalId(self::FOO)->build();

Expand All @@ -81,7 +83,7 @@ function it_should_throw_exception_if_shipment_is_null(): void
->during('execute', [$shippingExport]);
}

function it_should_throw_exception_if_order_is_null(): void
public function it_should_throw_exception_if_order_is_null(): void
{
$shipment = ShipmentBuilder::create()->build();
$shippingExport = ShippingExportBuilder::create()
Expand All @@ -94,7 +96,7 @@ function it_should_throw_exception_if_order_is_null(): void
->during('execute', [$shippingExport]);
}

function it_should_throw_exception_if_order_number_is_null(): void
public function it_should_throw_exception_if_order_number_is_null(): void
{
$order = OrderBuilder::create()->build();
$shipment = ShipmentBuilder::create()->withOrder($order)->build();
Expand All @@ -108,10 +110,13 @@ function it_should_throw_exception_if_order_number_is_null(): void
->during('execute', [$shippingExport]);
}

function it_should_save_label_under_the_correct_path(
public function it_should_save_label_under_the_correct_path(
WebClientInterface $webClient,
ShipmentInterface $shipment,
Filesystem $filesystem
Filesystem $filesystem,
RequestStack $requestStack,
SessionInterface $session,
FlashBagInterface $flashBag
): void {
$order = OrderBuilder::create()->withNumber(self::ORDER_NUMBER)->build();
$shipment->getOrder()->willReturn($order);
Expand All @@ -125,15 +130,20 @@ function it_should_save_label_under_the_correct_path(

$expectedPath = sprintf('%s/%s_%s.pdf', self::SHIPPING_LABELS_PATH, self::SHIPMENT_ID, self::ORDER_NUMBER);
$filesystem->dumpFile($expectedPath, self::SHIPPING_LABEL_CONTENT)->shouldBeCalled();
$requestStack->getSession()->willReturn($session);
$session->getBag('flashes')->willReturn($flashBag);

$this->execute($shippingExport);
}

function it_should_update_shipping_export_entity(
public function it_should_update_shipping_export_entity(
WebClientInterface $webClient,
ShippingExportRepositoryInterface $shippingExportRepository,
ShipmentInterface $shipment,
ShippingExportInterface $shippingExport
ShippingExportInterface $shippingExport,
RequestStack $requestStack,
SessionInterface $session,
FlashBagInterface $flashBag
): void {
$webClient->getLabels([self::FOO])->willReturn(self::SHIPPING_LABEL_CONTENT);
$order = OrderBuilder::create()->withNumber(self::ORDER_NUMBER)->build();
Expand All @@ -146,6 +156,8 @@ function it_should_update_shipping_export_entity(
$shippingExport->setState(ShippingExportInterface::STATE_EXPORTED)->shouldBeCalled();
$shippingExport->setExportedAt(Argument::type(\DateTime::class))->shouldBeCalled();
$shippingExportRepository->add($shippingExport)->shouldBeCalled();
$requestStack->getSession()->willReturn($session);
$session->getBag('flashes')->willReturn($flashBag);

$this->execute($shippingExport);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,41 +16,56 @@
use BitBag\SyliusShippingExportPlugin\Repository\ShippingExportRepositoryInterface;
use PhpSpec\ObjectBehavior;
use Prophecy\Argument;
use Symfony\Component\HttpFoundation\RequestStack;
use Symfony\Component\HttpFoundation\Session\Flash\FlashBagInterface;
use Symfony\Component\HttpFoundation\Session\SessionInterface;

class InPostShippingExportDefaultActionSpec extends ObjectBehavior
{
private const FOO = 'foo';

function let(ShippingExportRepositoryInterface $shippingExportRepository, FlashBagInterface $flashBag): void
public function let(ShippingExportRepositoryInterface $shippingExportRepository, RequestStack $requestStack): void
{
$this->beConstructedWith($shippingExportRepository, $flashBag);
$this->beConstructedWith($shippingExportRepository, $requestStack);
}

function it_is_initializable()
public function it_is_initializable()
{
$this->shouldHaveType(InPostShippingExportDefaultAction::class);
$this->shouldBeAnInstanceOf(InPostShippingExportActionInterface::class);
}

function it_should_set_state_and_exported_at_properties(ShippingExportInterface $shippingExport): void
{
public function it_should_set_state_and_exported_at_properties(
ShippingExportInterface $shippingExport,
RequestStack $requestStack,
SessionInterface $session,
FlashBagInterface $flashBag
): void {
$shippingExport->setState(ShippingExportInterface::STATE_PENDING)->shouldBeCalled();
$shippingExport->setExportedAt(Argument::type(\DateTime::class))->shouldBeCalled();

$requestStack->getSession()->willReturn($session);
$session->getBag('flashes')->willReturn($flashBag);

$this->execute($shippingExport);
}

function it_should_save_shipping_export_changes(
public function it_should_save_shipping_export_changes(
ShippingExportInterface $shippingExport,
ShippingExportRepositoryInterface $shippingExportRepository
ShippingExportRepositoryInterface $shippingExportRepository,
RequestStack $requestStack,
SessionInterface $session,
FlashBagInterface $flashBag
): void {
$shippingExportRepository->add($shippingExport)->shouldBeCalled();

$requestStack->getSession()->willReturn($session);
$session->getBag('flashes')->willReturn($flashBag);

$this->execute($shippingExport);
}

function it_should_always_support(): void
public function it_should_always_support(): void
{
$this->supports(self::FOO)->shouldReturn(true);
}
Expand Down
Loading

0 comments on commit ce77a9d

Please sign in to comment.