|
1
|
|
|
<?php |
|
2
|
|
|
|
|
3
|
|
|
/** |
|
4
|
|
|
* File containing the MultipleValuedTest class. |
|
5
|
|
|
* |
|
6
|
|
|
* @copyright Copyright (C) eZ Systems AS. All rights reserved. |
|
7
|
|
|
* @license For full copyright and license information view LICENSE file distributed with this source code. |
|
8
|
|
|
*/ |
|
9
|
|
|
namespace eZ\Publish\Core\MVC\Symfony\Matcher\Tests\ContentBased; |
|
10
|
|
|
|
|
11
|
|
|
use eZ\Publish\Core\MVC\Symfony\Matcher\ContentBased\MultipleValued; |
|
12
|
|
|
|
|
13
|
|
|
class MultipleValuedTest extends BaseTest |
|
14
|
|
|
{ |
|
15
|
|
|
/** |
|
16
|
|
|
* @dataProvider matchingConfigProvider |
|
17
|
|
|
* @covers \eZ\Publish\Core\MVC\Symfony\Matcher\ContentBased\MultipleValued::setMatchingConfig |
|
18
|
|
|
* @covers \eZ\Publish\Core\MVC\Symfony\Matcher\ContentBased\MultipleValued::getValues |
|
19
|
|
|
*/ |
|
20
|
|
View Code Duplication |
public function testSetMatchingConfig($matchingConfig) |
|
21
|
|
|
{ |
|
22
|
|
|
$matcher = $this->getMultipleValuedMatcherMock(); |
|
23
|
|
|
$matcher->setMatchingConfig($matchingConfig); |
|
24
|
|
|
$values = $matcher->getValues(); |
|
25
|
|
|
$this->assertInternalType('array', $values); |
|
26
|
|
|
|
|
27
|
|
|
$matchingConfig = is_array($matchingConfig) ? $matchingConfig : [$matchingConfig]; |
|
28
|
|
|
foreach ($matchingConfig as $val) { |
|
29
|
|
|
$this->assertContains($val, $values); |
|
30
|
|
|
} |
|
31
|
|
|
} |
|
32
|
|
|
|
|
33
|
|
|
/** |
|
34
|
|
|
* Returns a set of matching values, either single or multiple. |
|
35
|
|
|
* |
|
36
|
|
|
* @return array |
|
37
|
|
|
*/ |
|
38
|
|
View Code Duplication |
public function matchingConfigProvider() |
|
39
|
|
|
{ |
|
40
|
|
|
return [ |
|
41
|
|
|
[ |
|
42
|
|
|
'singleValue', |
|
43
|
|
|
['one', 'two', 'three'], |
|
44
|
|
|
[123, 'nous irons au bois'], |
|
45
|
|
|
456, |
|
46
|
|
|
], |
|
47
|
|
|
]; |
|
48
|
|
|
} |
|
49
|
|
|
|
|
50
|
|
|
/** |
|
51
|
|
|
* @covers \eZ\Publish\Core\MVC\RepositoryAware::setRepository |
|
52
|
|
|
* @covers \eZ\Publish\Core\MVC\Symfony\Matcher\ContentBased\MultipleValued::getRepository |
|
53
|
|
|
*/ |
|
54
|
|
|
public function testInjectRepository() |
|
55
|
|
|
{ |
|
56
|
|
|
$matcher = $this->getMultipleValuedMatcherMock(); |
|
57
|
|
|
$matcher->setRepository($this->repositoryMock); |
|
58
|
|
|
$this->assertSame($this->repositoryMock, $matcher->getRepository()); |
|
59
|
|
|
} |
|
60
|
|
|
|
|
61
|
|
|
private function getMultipleValuedMatcherMock() |
|
62
|
|
|
{ |
|
63
|
|
|
return $this->getMockForAbstractClass(MultipleValued::class); |
|
64
|
|
|
} |
|
65
|
|
|
} |
|
66
|
|
|
|