Completed
Push — 1.0 ( 92e65c...08f62c )
by Kamil
27:49
created

TaxonSpec   A

Complexity

Total Complexity 6

Size/Duplication

Total Lines 41
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 1

Importance

Changes 0
Metric Value
wmc 6
lcom 0
cbo 1
dl 0
loc 41
c 0
b 0
f 0
rs 10

6 Methods

Rating   Name   Duplication   Size   Complexity  
A it_is_a_taxon() 0 4 1
A it_implements_an_image_aware_interface() 0 4 1
A it_initializes_an_image_collection_by_default() 0 4 1
A it_adds_an_image() 0 6 1
A it_removes_an_image() 0 6 1
A it_returns_images_by_type() 0 9 1
1
<?php
2
3
/*
4
 * This file is part of the Sylius package.
5
 *
6
 * (c) Paweł Jędrzejewski
7
 *
8
 * For the full copyright and license information, please view the LICENSE
9
 * file that was distributed with this source code.
10
 */
11
12
declare(strict_types=1);
13
14
namespace spec\Sylius\Component\Core\Model;
15
16
use Doctrine\Common\Collections\ArrayCollection;
17
use Doctrine\Common\Collections\Collection;
18
use PhpSpec\ObjectBehavior;
19
use Sylius\Component\Core\Model\ImageInterface;
20
use Sylius\Component\Core\Model\ImagesAwareInterface;
21
use Sylius\Component\Core\Model\TaxonInterface;
22
23
final class TaxonSpec extends ObjectBehavior
24
{
25
    function it_is_a_taxon(): void
26
    {
27
        $this->shouldImplement(TaxonInterface::class);
28
    }
29
30
    function it_implements_an_image_aware_interface(): void
31
    {
32
        $this->shouldImplement(ImagesAwareInterface::class);
33
    }
34
35
    function it_initializes_an_image_collection_by_default(): void
36
    {
37
        $this->getImages()->shouldHaveType(Collection::class);
38
    }
39
40
    function it_adds_an_image(ImageInterface $image): void
41
    {
42
        $this->addImage($image);
43
        $this->hasImages()->shouldReturn(true);
44
        $this->hasImage($image)->shouldReturn(true);
45
    }
46
47
    function it_removes_an_image(ImageInterface $image): void
48
    {
49
        $this->addImage($image);
50
        $this->removeImage($image);
51
        $this->hasImage($image)->shouldReturn(false);
52
    }
53
54
    function it_returns_images_by_type(ImageInterface $image): void
55
    {
56
        $image->getType()->willReturn('thumbnail');
57
        $image->setOwner($this)->shouldBeCalled();
58
59
        $this->addImage($image);
60
61
        $this->getImagesByType('thumbnail')->shouldBeLike(new ArrayCollection([$image->getWrappedObject()]));
0 ignored issues
show
Bug introduced by
The method getWrappedObject() does not seem to exist on object<Sylius\Component\...e\Model\ImageInterface>.

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...
62
    }
63
}
64