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\TaxonFixture; |
18
|
|
|
|
19
|
|
|
/** |
20
|
|
|
* @author Kamil Kokot <[email protected]> |
21
|
|
|
*/ |
22
|
|
|
final class TaxonFixtureTest extends \PHPUnit_Framework_TestCase |
23
|
|
|
{ |
24
|
|
|
use ConfigurationTestCaseTrait; |
25
|
|
|
|
26
|
|
|
/** |
27
|
|
|
* @test |
28
|
|
|
*/ |
29
|
|
|
public function taxons_are_optional() |
30
|
|
|
{ |
31
|
|
|
$this->assertConfigurationIsValid([[]], 'custom'); |
32
|
|
|
} |
33
|
|
|
|
34
|
|
|
/** |
35
|
|
|
* @test |
36
|
|
|
*/ |
37
|
|
|
public function taxons_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 taxon_code_is_optional() |
47
|
|
|
{ |
48
|
|
|
$this->assertConfigurationIsValid([['custom' => [['code' => 'CUSTOM']]]], 'custom.*.code'); |
49
|
|
|
} |
50
|
|
|
|
51
|
|
|
/** |
52
|
|
|
* @test |
53
|
|
|
*/ |
54
|
|
|
public function taxon_slug_is_optional() |
55
|
|
|
{ |
56
|
|
|
$this->assertConfigurationIsValid([['custom' => [['slug' => 'custom']]]], 'custom.*.slug'); |
57
|
|
|
} |
58
|
|
|
|
59
|
|
|
/** |
60
|
|
|
* @test |
61
|
|
|
*/ |
62
|
|
|
public function taxon_children_are_optional() |
63
|
|
|
{ |
64
|
|
|
$this->assertConfigurationIsValid([['custom' => [['children' => [['name' => 'foo']]]]]], 'custom.*.children'); |
65
|
|
|
} |
66
|
|
|
|
67
|
|
|
/** |
68
|
|
|
* @test |
69
|
|
|
*/ |
70
|
|
|
public function taxon_children_may_contain_nested_array() |
71
|
|
|
{ |
72
|
|
|
$this->assertProcessedConfigurationEquals( |
73
|
|
|
[['custom' => [['children' => [['nested' => ['key' => 'value']]]]]]], |
74
|
|
|
['custom' => [['children' => [['nested' => ['key' => 'value']]]]]], |
75
|
|
|
'custom.*.children' |
76
|
|
|
); |
77
|
|
|
} |
78
|
|
|
|
79
|
|
|
/** |
80
|
|
|
* {@inheritdoc} |
81
|
|
|
*/ |
82
|
|
|
protected function getConfiguration() |
83
|
|
|
{ |
84
|
|
|
return new TaxonFixture( |
85
|
|
|
$this->getMockBuilder(ObjectManager::class)->getMock(), |
86
|
|
|
$this->getMockBuilder(ExampleFactoryInterface::class)->getMock() |
87
|
|
|
); |
88
|
|
|
} |
89
|
|
|
} |
90
|
|
|
|