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() |
|
|
|
|
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
|
|
|
|
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.