Completed
Push — master ( ff8f52...ed8581 )
by
unknown
12:31 queued 10s
created

MultipleValuedTest   A

Complexity

Total Complexity 6

Size/Duplication

Total Lines 53
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 1

Importance

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

4 Methods

Rating   Name   Duplication   Size   Complexity  
A testInjectRepository() 0 6 1
A getMultipleValuedMatcherMock() 0 4 1
A testSetMatchingConfig() 0 12 3
A matchingConfigProvider() 0 11 1
1
<?php
2
3
/**
4
 * @copyright Copyright (C) eZ Systems AS. All rights reserved.
5
 * @license For full copyright and license information view LICENSE file distributed with this source code.
6
 */
7
namespace eZ\Publish\Core\MVC\Symfony\Matcher\Tests\ContentBased;
8
9
use eZ\Publish\Core\MVC\Symfony\Matcher\ContentBased\MultipleValued;
10
11
class MultipleValuedTest extends BaseTest
12
{
13
    /**
14
     * @dataProvider matchingConfigProvider
15
     * @covers \eZ\Publish\Core\MVC\Symfony\Matcher\ContentBased\MultipleValued::setMatchingConfig
16
     * @covers \eZ\Publish\Core\MVC\Symfony\Matcher\ContentBased\MultipleValued::getValues
17
     */
18
    public function testSetMatchingConfig($matchingConfig)
19
    {
20
        $matcher = $this->getMultipleValuedMatcherMock();
21
        $matcher->setMatchingConfig($matchingConfig);
0 ignored issues
show
Bug introduced by
The method setMatchingConfig() does not seem to exist on object<PHPUnit\Framework\MockObject\MockObject>.

This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces.

This is most likely a typographical error or the method has been renamed.

Loading history...
22
        $values = $matcher->getValues();
0 ignored issues
show
Bug introduced by
The method getValues() does not seem to exist on object<PHPUnit\Framework\MockObject\MockObject>.

This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces.

This is most likely a typographical error or the method has been renamed.

Loading history...
23
        $this->assertIsArray($values);
24
25
        $matchingConfig = is_array($matchingConfig) ? $matchingConfig : [$matchingConfig];
26
        foreach ($matchingConfig as $val) {
27
            $this->assertContains($val, $values);
28
        }
29
    }
30
31
    /**
32
     * Returns a set of matching values, either single or multiple.
33
     *
34
     * @return array
35
     */
36
    public function matchingConfigProvider()
37
    {
38
        return [
39
            [
40
                'singleValue',
41
                ['one', 'two', 'three'],
42
                [123, 'nous irons au bois'],
43
                456,
44
            ],
45
        ];
46
    }
47
48
    /**
49
     * @covers \eZ\Publish\Core\MVC\RepositoryAware::setRepository
50
     * @covers \eZ\Publish\Core\MVC\Symfony\Matcher\ContentBased\MultipleValued::getRepository
51
     */
52
    public function testInjectRepository()
53
    {
54
        $matcher = $this->getMultipleValuedMatcherMock();
55
        $matcher->setRepository($this->repositoryMock);
0 ignored issues
show
Bug introduced by
The method setRepository() does not seem to exist on object<PHPUnit\Framework\MockObject\MockObject>.

This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces.

This is most likely a typographical error or the method has been renamed.

Loading history...
56
        $this->assertSame($this->repositoryMock, $matcher->getRepository());
0 ignored issues
show
Bug introduced by
The method getRepository() does not seem to exist on object<PHPUnit\Framework\MockObject\MockObject>.

This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces.

This is most likely a typographical error or the method has been renamed.

Loading history...
57
    }
58
59
    private function getMultipleValuedMatcherMock()
60
    {
61
        return $this->getMockForAbstractClass(MultipleValued::class);
62
    }
63
}
64