Completed
Push — EZP-31287 ( fe8c5c...af9523 )
by
unknown
34:01
created

MultipleValuedTest   A

Complexity

Total Complexity 6

Size/Duplication

Total Lines 53
Duplicated Lines 43.4 %

Coupling/Cohesion

Components 1
Dependencies 1

Importance

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

4 Methods

Rating   Name   Duplication   Size   Complexity  
A testSetMatchingConfig() 12 12 3
A matchingConfigProvider() 11 11 1
A testInjectRepository() 0 6 1
A getMultipleValuedMatcherMock() 0 4 1

How to fix   Duplicated Code   

Duplicated Code

Duplicate code is one of the most pungent code smells. A rule that is often used is to re-structure code once it is duplicated in three or more places.

Common duplication problems, and corresponding solutions are:

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 View Code Duplication
    public function testSetMatchingConfig($matchingConfig)
19
    {
20
        $matcher = $this->getMultipleValuedMatcherMock();
21
        $matcher->setMatchingConfig($matchingConfig);
22
        $values = $matcher->getValues();
23
        $this->assertInternalType('array', $values);
0 ignored issues
show
Deprecated Code introduced by
The method PHPUnit\Framework\Assert::assertInternalType() has been deprecated with message: https://github.com/sebastianbergmann/phpunit/issues/3369

This method has been deprecated. The supplier of the class has supplied an explanatory message.

The explanatory message should give you some clue as to whether and when the method will be removed from the class and what other method or class to use instead.

Loading history...
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 View Code Duplication
    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);
56
        $this->assertSame($this->repositoryMock, $matcher->getRepository());
57
    }
58
59
    private function getMultipleValuedMatcherMock()
60
    {
61
        return $this->getMockForAbstractClass(MultipleValued::class);
62
    }
63
}
64