Skip to content

Commit 7d887b6

Browse files
committed
Don't take the channel hostname into consideration
1 parent 8aa06ef commit 7d887b6

File tree

2 files changed

+1
-52
lines changed

2 files changed

+1
-52
lines changed

src/Resolver/ImageUrlResolver.php

Lines changed: 1 addition & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@
77
use Liip\ImagineBundle\Imagine\Cache\CacheManager;
88
use Setono\SyliusRestockNotificationPlugin\Model\RestockNotificationRequestInterface;
99
use Sylius\Component\Core\Model\ProductInterface;
10-
use Symfony\Component\Routing\Generator\UrlGeneratorInterface;
1110

1211
final class ImageUrlResolver implements ImageUrlResolverInterface
1312
{
@@ -34,16 +33,7 @@ public function resolve(RestockNotificationRequestInterface $restockNotification
3433
return null;
3534
}
3635

37-
$hostname = self::getChannelHostname($restockNotificationRequest);
38-
if (null === $hostname) {
39-
return $this->cacheManager->getBrowserPath($path, $this->filter);
40-
}
41-
42-
return sprintf(
43-
'%s%s',
44-
$hostname,
45-
$this->cacheManager->getBrowserPath(path: $path, filter: $this->filter, referenceType: UrlGeneratorInterface::ABSOLUTE_PATH),
46-
);
36+
return $this->cacheManager->getBrowserPath($path, $this->filter);
4737
}
4838

4939
/**

tests/Resolver/ImageUrlResolverTest.php

Lines changed: 0 additions & 41 deletions
Original file line numberDiff line numberDiff line change
@@ -184,45 +184,4 @@ public function it_returns_browser_path_when_hostname_is_empty(): void
184184

185185
$this->assertEquals($browserPath, $result);
186186
}
187-
188-
/**
189-
* @test
190-
*/
191-
public function it_returns_absolute_url_when_hostname_is_available(): void
192-
{
193-
$path = 'path/to/image.jpg';
194-
$hostname = 'example.com';
195-
$absolutePath = '/media/cache/resolve/sylius_shop_product_large_thumbnail/path/to/image.jpg';
196-
$expectedUrl = 'https://example.com/media/cache/resolve/sylius_shop_product_large_thumbnail/path/to/image.jpg';
197-
198-
// Use Prophecy's argument matchers to match any call to getBrowserPath
199-
$this->cacheManager->getBrowserPath(
200-
\Prophecy\Argument::cetera(),
201-
)->willReturn($absolutePath);
202-
203-
$resolver = new ImageUrlResolver($this->cacheManager->reveal(), $this->filter);
204-
205-
$image = $this->prophesize(ImageInterface::class);
206-
$image->getPath()->willReturn($path);
207-
208-
$images = $this->prophesize(Collection::class);
209-
$images->first()->willReturn($image->reveal());
210-
211-
$product = $this->prophesize(ProductInterface::class);
212-
$product->getImages()->willReturn($images->reveal());
213-
214-
$productVariant = $this->prophesize(ProductVariantInterface::class);
215-
$productVariant->getProduct()->willReturn($product->reveal());
216-
217-
$channel = $this->prophesize(ChannelInterface::class);
218-
$channel->getHostname()->willReturn($hostname);
219-
220-
$request = $this->prophesize(RestockNotificationRequestInterface::class);
221-
$request->getProductVariant()->willReturn($productVariant->reveal());
222-
$request->getChannel()->willReturn($channel->reveal());
223-
224-
$result = $resolver->resolve($request->reveal());
225-
226-
$this->assertEquals($expectedUrl, $result);
227-
}
228187
}

0 commit comments

Comments
 (0)