Completed
Push — remove-content-bundle ( 201341 )
by Kamil
34:43
created

ProductAssociationSpec   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
rs 10
c 0
b 0
f 0

6 Methods

Rating   Name   Duplication   Size   Complexity  
A it_is_initializable() 0 4 1
A it_implements_ProductAssociation_interface() 0 4 1
A it_has_owner() 0 5 1
A it_has_type() 0 5 1
A it_adds_association_product() 0 5 1
A it_checks_if_product_is_associated() 0 10 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
namespace spec\Sylius\Component\Product\Model;
13
14
use PhpSpec\ObjectBehavior;
15
use Sylius\Component\Product\Model\ProductAssociation;
16
use Sylius\Component\Product\Model\ProductAssociationInterface;
17
use Sylius\Component\Product\Model\ProductAssociationType;
18
use Sylius\Component\Product\Model\ProductInterface;
19
20
/**
21
 * @author Leszek Prabucki <[email protected]>
22
 * @author Łukasz Chruściel <[email protected]>
23
 */
24
final class ProductAssociationSpec extends ObjectBehavior
25
{
26
    function it_is_initializable()
27
    {
28
        $this->shouldHaveType(ProductAssociation::class);
29
    }
30
31
    function it_implements_ProductAssociation_interface()
0 ignored issues
show
Coding Style introduced by
function it_implements_P...Association_interface() does not seem to conform to the naming convention (^(?:(?:[a-z]|__)[a-zA-Z0-9]*|[a-z][a-z0-9_]*)$).

This check examines a number of code elements and verifies that they conform to the given naming conventions.

You can set conventions for local variables, abstract classes, utility classes, constant, properties, methods, parameters, interfaces, classes, exceptions and special methods.

Loading history...
32
    {
33
        $this->shouldHaveType(ProductAssociationInterface::class);
34
    }
35
36
    function it_has_owner(ProductInterface $product)
37
    {
38
        $this->setOwner($product);
39
        $this->getOwner()->shouldReturn($product);
40
    }
41
42
    function it_has_type(ProductAssociationType $associationType)
43
    {
44
        $this->setType($associationType);
45
        $this->getType()->shouldReturn($associationType);
46
    }
47
48
    function it_adds_association_product(ProductInterface $product)
49
    {
50
        $this->addAssociatedProduct($product);
51
        $this->getAssociatedProducts()->shouldHaveCount(1);
52
    }
53
54
    function it_checks_if_product_is_associated(ProductInterface $product)
55
    {
56
        $this->hasAssociatedProduct($product)->shouldReturn(false);
57
58
        $this->addAssociatedProduct($product);
59
        $this->hasAssociatedProduct($product)->shouldReturn(true);
60
61
        $this->removeAssociatedProduct($product);
62
        $this->hasAssociatedProduct($product)->shouldReturn(false);
63
    }
64
}
65