Completed
Pull Request — master (#54)
by Konrad
04:41
created

ImageTransformerSpec   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 26
Duplicated Lines 0 %

Importance

Changes 0
Metric Value
eloc 9
dl 0
loc 26
rs 10
c 0
b 0
f 0
wmc 3

3 Methods

Rating   Name   Duplication   Size   Complexity  
A it_is_a_transformer() 0 3 1
A let() 0 3 1
A it_transforms_product_images_into_product_thumbnail() 0 14 1
1
<?php
2
3
declare(strict_types=1);
4
5
namespace spec\BitBag\SyliusElasticsearchPlugin\Transformer\Product;
6
7
use BitBag\SyliusElasticsearchPlugin\Transformer\Product\TransformerInterface;
8
use Doctrine\Common\Collections\ArrayCollection;
9
use Liip\ImagineBundle\Service\FilterService;
10
use PhpSpec\ObjectBehavior;
11
use Sylius\Component\Core\Model\ImageInterface;
12
use Sylius\Component\Core\Model\ProductInterface;
13
14
final class ImageTransformerSpec extends ObjectBehavior
15
{
16
    function let(FilterService $filterService): void
0 ignored issues
show
Best Practice introduced by
It is generally recommended to explicitly declare the visibility for methods.

Adding explicit visibility (private, protected, or public) is generally recommend to communicate to other developers how, and from where this method is intended to be used.

Loading history...
17
    {
18
        $this->beConstructedWith($filterService);
19
    }
20
21
    function it_is_a_transformer(): void
0 ignored issues
show
Best Practice introduced by
It is generally recommended to explicitly declare the visibility for methods.

Adding explicit visibility (private, protected, or public) is generally recommend to communicate to other developers how, and from where this method is intended to be used.

Loading history...
22
    {
23
        $this->shouldImplement(TransformerInterface::class);
24
    }
25
26
    function it_transforms_product_images_into_product_thumbnail(
27
        ProductInterface $product,
28
        ImageInterface $productImage,
29
        FilterService $filterService
30
    ): void {
31
        $product->getImagesByType('thumbnail')->willReturn(new ArrayCollection([$productImage->getWrappedObject()]));
0 ignored issues
show
Bug introduced by
The method getWrappedObject() does not exist on Sylius\Component\Core\Model\ImageInterface. ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-call  annotation

31
        $product->getImagesByType('thumbnail')->willReturn(new ArrayCollection([$productImage->/** @scrutinizer ignore-call */ getWrappedObject()]));

This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces.

This is most likely a typographical error or the method has been renamed.

Loading history...
Bug introduced by
The method willReturn() does not exist on Doctrine\Common\Collections\Collection. ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-call  annotation

31
        $product->getImagesByType('thumbnail')->/** @scrutinizer ignore-call */ willReturn(new ArrayCollection([$productImage->getWrappedObject()]));

This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces.

This is most likely a typographical error or the method has been renamed.

Loading history...
32
        $productImage->getPath()->willReturn('/path-to-image');
33
34
        $filterService
35
            ->getUrlOfFilteredImage('/path-to-image', 'sylius_shop_product_thumbnail')
36
            ->shouldBeCalled()
37
        ;
38
39
        $this->transform($product);
0 ignored issues
show
Bug introduced by
The method transform() does not exist on spec\BitBag\SyliusElasti...ct\ImageTransformerSpec. Since you implemented __call, consider adding a @method annotation. ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-call  annotation

39
        $this->/** @scrutinizer ignore-call */ 
40
               transform($product);
Loading history...
40
    }
41
}
42