Skip to content

Commit

Permalink
Remove old services and fix PHPStan (#123)
Browse files Browse the repository at this point in the history
  • Loading branch information
lruozzi9 committed Jun 20, 2022
1 parent b6a7435 commit 8c32f6c
Show file tree
Hide file tree
Showing 7 changed files with 13 additions and 256 deletions.
37 changes: 13 additions & 24 deletions tests/Behat/Context/Messenger/MessengerContext.php
Original file line number Diff line number Diff line change
Expand Up @@ -23,15 +23,6 @@ public function __construct(
) {
}

/**
* @Given /^the queue item with identifier "([^"]*)" for the "([^"]*)" importer has an error message containing "([^"]*)"$/
*/
public function theQueueItemHasAnErrorMessageContaining(string $identifier, string $importer, string $message): void
{
$queueItem = $this->getQueueItemByImporterAndIdentifier($importer, $identifier);
Assert::contains((string) $queueItem->getErrorMessage(), $message);
}

/**
* @Then the queue item with identifier :identifier for the :importer importer should not be in the Akeneo queue
*/
Expand All @@ -47,8 +38,10 @@ public function theQueueItemWithIdentifierForTheImporterShouldNotBeInTheAkeneoQu
*/
public function theQueueItemWithIdentifierForTheImporterShouldBeInTheAkeneoQueue(string $identifier, string $importer): void
{
$envelope = $this->getEnvelopeByImporterAndIdentifier($importer, $identifier);
Assert::notNull($envelope);
Assert::isInstanceOf(
$this->getEnvelopeByImporterAndIdentifier($importer, $identifier)->getMessage(),
$envelope->getMessage(),
ItemImport::class,
);
}
Expand All @@ -69,17 +62,6 @@ public function thereShouldBeNoItemInTheAkeneoQueue(): void
Assert::isEmpty($this->transport->get());
}

/**
* @Then /^there should be only one queue item with identifier "([^"]*)" for the "([^"]*)" importer in the Akeneo queue$/
*/
public function thereShouldBeOnlyOneProductQueueItemForInTheAkeneoQueue(string $identifier, string $importer): void
{
$items = $this->queueItemRepository->findBy(
['akeneoEntity' => $importer, 'akeneoIdentifier' => $identifier],
);
Assert::count($items, 1);
}

/**
* @Then /^there should be (\d+) items for the "([^"]*)" importer in the Akeneo queue$/
*/
Expand All @@ -94,8 +76,10 @@ public function thereShouldBeItemsForTheImporterInTheAkeneoQueue(int $count, str
*/
public function thereShouldBeItemsForTheImporterOnlyInTheAkeneoQueue(string $importer): void
{
/** @var Envelope[] $envelopes */
$envelopes = $this->transport->get();
$importerItems = $this->getEnvelopesByImporter($importer);
Assert::count($this->transport->get(), count($importerItems));
Assert::count($envelopes, count($importerItems));
}

private function getQueueItemByImporterAndIdentifier(string $importer, string $identifier): ItemImport
Expand Down Expand Up @@ -146,7 +130,10 @@ public function theItemImportMessageForProductShouldHaveFailed(string $identifie

private function getEnvelopesByImporter(string $importer): array
{
return array_filter($this->transport->get(), static function (Envelope $envelope) use ($importer): bool {
/** @var Envelope[] $envelopes */
$envelopes = $this->transport->get();

return array_filter($envelopes, static function (Envelope $envelope) use ($importer): bool {
/** @var ItemImport|mixed $message */
$message = $envelope->getMessage();

Expand All @@ -156,7 +143,9 @@ private function getEnvelopesByImporter(string $importer): array

private function getEnvelopeByImporterAndIdentifier(string $importer, string $identifier): ?Envelope
{
$envelopes = array_filter($this->transport->get(), static function (Envelope $envelope) use ($importer, $identifier): bool {
/** @var Envelope[] $envelopes */
$envelopes = $this->transport->get();
$envelopes = array_filter($envelopes, static function (Envelope $envelope) use ($importer, $identifier): bool {
/** @var ItemImport|mixed $message */
$message = $envelope->getMessage();

Expand Down
34 changes: 0 additions & 34 deletions tests/Behat/Context/Setup/QueueContext.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@
use Behat\Behat\Context\Context;
use Sylius\Behat\Service\SharedStorageInterface;
use Symfony\Component\Messenger\MessageBusInterface;
use Webgriffe\SyliusAkeneoPlugin\Entity\QueueItemInterface;
use Webgriffe\SyliusAkeneoPlugin\Message\ItemImport;

final class QueueContext implements Context
Expand Down Expand Up @@ -40,37 +39,4 @@ public function thereIsOneProductAssociationsToImportWithIdentifierInTheAkeneoQu

$this->sharedStorage->set('item', $itemImport);
}

/**
* @Given /^there is an already imported item with identifier "([^"]*)" for the "([^"]*)" importer in the Akeneo queue$/
*/
public function thereIsAnAlreadyImportedItemWithIdentifierForTheImporterInTheAkeneoQueue(string $identifier, string $importer): void
{
/** @var QueueItemInterface $queueItem */
$queueItem = $this->queueItemFactory->createNew();
$queueItem->setAkeneoEntity($importer);
$queueItem->setAkeneoIdentifier($identifier);
$queueItem->setCreatedAt(new \DateTime());
$queueItem->setImportedAt(new \DateTime());
$this->queueItemRepository->add($queueItem);
$this->sharedStorage->set('item', $queueItem);
}

/**
* @Given /^(this item) has been imported (\d+) days ago$/
*/
public function thisItemHasBeenImportedDaysAgo(QueueItemInterface $queueItem, int $days): void
{
$queueItem->setImportedAt(new \DateTime("$days days ago"));
$this->queueItemRepository->add($queueItem);
}

/**
* @Given /^(this item) has been imported now$/
*/
public function thisItemHasBeenImportedNow(QueueItemInterface $queueItem): void
{
$queueItem->setImportedAt(new \DateTime());
$this->queueItemRepository->add($queueItem);
}
}
32 changes: 0 additions & 32 deletions tests/Behat/Context/Transform/QueueItemContext.php

This file was deleted.

13 changes: 0 additions & 13 deletions tests/Behat/Context/Ui/Admin/ManagingProductsContext.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@
use Sylius\Behat\Service\Helper\JavaScriptTestHelperInterface;
use Sylius\Behat\Service\NotificationCheckerInterface;
use Sylius\Component\Core\Model\ProductInterface;
use Webmozart\Assert\Assert;

final class ManagingProductsContext implements Context
{
Expand Down Expand Up @@ -58,16 +57,4 @@ public function iShouldBeNotifiedThatItHasBeenAlreadyEnqueued(): void
'Akeneo PIM import for this product has been already scheduled before',
);
}

/**
* @Then /^I should see (\d+), not imported, items? in the Akeneo queue items list$/
*/
public function iShouldSeeNotImportedItemInTheAkeneoQueueItemsList(int $numberOfItems): void
{
$this->queueItemsIndexPage->open();
Assert::same($this->queueItemsIndexPage->countItems(), $numberOfItems);
foreach ($this->indexPage->getColumnFields('importedAt') as $columnField) {
Assert::eq($columnField, 'No');
}
}
}
144 changes: 0 additions & 144 deletions tests/Behat/Context/Ui/Admin/ManagingQueueItems.php

This file was deleted.

7 changes: 0 additions & 7 deletions tests/Behat/Resources/services.xml
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,6 @@
<services>
<defaults public="true" />

<service id="webgriffe_sylius_akeneo.behat.context.transform.queue_item" class="Tests\Webgriffe\SyliusAkeneoPlugin\Behat\Context\Transform\QueueItemContext">
</service>

<service id="webgriffe_sylius_akeneo.behat.context.setup.queue" class="Tests\Webgriffe\SyliusAkeneoPlugin\Behat\Context\Setup\QueueContext">
<argument type="service" id="sylius.behat.shared_storage" />
<argument type="service" id="messenger.default_bus"/>
Expand Down Expand Up @@ -46,10 +43,6 @@

<service id="webgriffe_sylius_akeneo.behat.context.system.datetime" class="Tests\Webgriffe\SyliusAkeneoPlugin\Behat\Context\System\DateTimeContext" />

<service id="webgriffe_sylius_akeneo.behat.context.ui.admin.managing_queue_items" class="Tests\Webgriffe\SyliusAkeneoPlugin\Behat\Context\Ui\Admin\ManagingQueueItems">
<argument type="service" id="sylius.behat.shared_storage" />
</service>

<service id="webgriffe_sylius_akeneo.behat.context.ui.admin.managing_products" class="Tests\Webgriffe\SyliusAkeneoPlugin\Behat\Context\Ui\Admin\ManagingProductsContext">
<argument type="service" id="sylius.behat.page.admin.product.index" />
<argument type="service" id="sylius.behat.java_script_test_helper" />
Expand Down
2 changes: 0 additions & 2 deletions tests/Behat/Resources/suites.yml
Original file line number Diff line number Diff line change
Expand Up @@ -130,12 +130,10 @@ default:
- sylius.behat.context.hook.doctrine_orm

- sylius.behat.context.transform.shared_storage
- webgriffe_sylius_akeneo.behat.context.transform.queue_item

- sylius.behat.context.setup.admin_security
- webgriffe_sylius_akeneo.behat.context.setup.queue

- webgriffe_sylius_akeneo.behat.context.ui.admin.managing_queue_items
- sylius.behat.context.ui.admin.notification

filters:
Expand Down

0 comments on commit 8c32f6c

Please sign in to comment.