Completed
Push — composer-autoload ( 2ad06b )
by Kamil
18:19
created

ProductAssociationFixtureTest   A

Complexity

Total Complexity 6

Size/Duplication

Total Lines 61
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 4

Importance

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

6 Methods

Rating   Name   Duplication   Size   Complexity  
A product_assoiations_are_optional() 0 4 1
A product_associations_can_be_generated_randomly() 0 5 1
A product_association_type_is_optional() 0 4 1
A product_association_owner_is_optional() 0 4 1
A product_association_associated_products_are_optional() 0 9 1
A getConfiguration() 0 7 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 Sylius\Bundle\CoreBundle\Tests\Fixture;
13
14
use Doctrine\Common\Persistence\ObjectManager;
15
use Matthias\SymfonyConfigTest\PhpUnit\ConfigurationTestCaseTrait;
16
use Sylius\Bundle\CoreBundle\Fixture\Factory\ExampleFactoryInterface;
17
use Sylius\Bundle\CoreBundle\Fixture\ProductAssociationFixture;
18
19
/**
20
 * @author Grzegorz Sadowski <[email protected]>
21
 */
22
final class ProductAssociationFixtureTest extends \PHPUnit_Framework_TestCase
23
{
24
    use ConfigurationTestCaseTrait;
25
26
    /**
27
     * @test
28
     */
29
    public function product_assoiations_are_optional()
30
    {
31
        $this->assertConfigurationIsValid([[]], 'custom');
32
    }
33
34
    /**
35
     * @test
36
     */
37
    public function product_associations_can_be_generated_randomly()
38
    {
39
        $this->assertConfigurationIsValid([['random' => 4]], 'random');
40
        $this->assertPartialConfigurationIsInvalid([['random' => -1]], 'random');
41
    }
42
43
    /**
44
     * @test
45
     */
46
    public function product_association_type_is_optional()
47
    {
48
        $this->assertConfigurationIsValid([['custom' => [['type' => 'type']]]], 'custom.*.type');
49
    }
50
51
    /**
52
     * @test
53
     */
54
    public function product_association_owner_is_optional()
55
    {
56
        $this->assertConfigurationIsValid([['custom' => [['owner' => 'product']]]], 'custom.*.owner');
57
    }
58
59
    /**
60
     * @test
61
     */
62
    public function product_association_associated_products_are_optional()
63
    {
64
        $this->assertConfigurationIsValid(
65
            [[
66
                'custom' => [['associated_products' => ['product-1', 'product-2']]]
67
            ]],
68
            'custom.*.associated_products')
69
        ;
70
    }
71
72
    /**
73
     * {@inheritdoc}
74
     */
75
    protected function getConfiguration()
76
    {
77
        return new ProductAssociationFixture(
78
            $this->getMockBuilder(ObjectManager::class)->getMock(),
79
            $this->getMockBuilder(ExampleFactoryInterface::class)->getMock()
80
        );
81
    }
82
}
83