Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Product images deletion fix #9906

Merged
merged 4 commits into from
Nov 12, 2018
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Extract parmeter and remove image paths from service memory
  • Loading branch information
Zales0123 committed Nov 12, 2018
commit 88526763f5978d37c9ae271de262d979f877467f
2 changes: 1 addition & 1 deletion src/Sylius/Behat/Resources/config/services.xml
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@

<service id="sylius.behat.checker.image_existence" class="Sylius\Behat\Service\Checker\ImageExistenceChecker">
<argument type="service" id="__symfony__.sylius.liip.filter_service" />
<argument type="string">%__symfony__.kernel.project_dir%/web/</argument>
<argument type="string">%__symfony__.sylius_core.public_dir%</argument>
</service>

<service id="sylius.behat.paypal_api_mocker" class="Sylius\Behat\Service\Mocker\PaypalApiMocker" public="false">
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -59,9 +59,10 @@ public function onFlush(OnFlushEventArgs $event): void

public function postFlush(PostFlushEventArgs $event): void
{
foreach ($this->imagesToDelete as $imagePath) {
foreach ($this->imagesToDelete as $key => $imagePath) {
$this->imageUploader->remove($imagePath);
Zales0123 marked this conversation as resolved.
Show resolved Hide resolved
$this->cacheManager->remove($imagePath, array_keys($this->filterManager->getFilterConfiguration()->all()));
unset($this->imagesToDelete[$key]);
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -5,3 +5,4 @@ parameters:
sylius.cache:
type: file_system
sylius.uploader.filesystem: sylius_image
sylius_core.public_dir: "%kernel.project_dir%/web"
Original file line number Diff line number Diff line change
Expand Up @@ -83,4 +83,35 @@ function it_removes_saved_images_paths(

$this->postFlush($postFlushEvent);
}

function it_removes_saved_images_paths_from_both_filesystem_and_service_property(
ImageUploaderInterface $imageUploader,
CacheManager $cacheManager,
FilterManager $filterManager,
OnFlushEventArgs $onFlushEvent,
PostFlushEventArgs $postFlushEvent,
EntityManagerInterface $entityManager,
UnitOfWork $unitOfWork,
ImageInterface $image,
ProductInterface $product,
FilterConfiguration $filterConfiguration
): void {
$onFlushEvent->getEntityManager()->willReturn($entityManager);
$entityManager->getUnitOfWork()->willReturn($unitOfWork);
$unitOfWork->getScheduledEntityDeletions()->willReturn([$image, $product]);

$image->getPath()->willReturn('image/path');

$this->onFlush($onFlushEvent);

$imageUploader->remove('image/path')->shouldBeCalledOnce();

$filterManager->getFilterConfiguration()->willReturn($filterConfiguration);
$filterConfiguration->all()->willReturn(['test' => 'Test']);

$cacheManager->remove('image/path', ['test'])->shouldBeCalledOnce();

$this->postFlush($postFlushEvent);
$this->postFlush($postFlushEvent);
}
}