Completed
Push — master ( 739ea2...dd79ae )
by Asmir
13s
created

CacheWarmerTest   A

Complexity

Total Complexity 4

Size/Duplication

Total Lines 39
Duplicated Lines 64.1 %

Coupling/Cohesion

Components 1
Dependencies 3

Importance

Changes 0
Metric Value
wmc 4
lcom 1
cbo 3
dl 25
loc 39
rs 10
c 0
b 0
f 0

4 Methods

Rating   Name   Duplication   Size   Complexity  
A setUp() 0 6 1
A testWarmUpRecursive() 9 9 1
A testWarmUpRecursiveWithInclusion() 8 8 1
A testWarmUpRecursiveWithExclusion() 8 8 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 2011 Johannes M. Schmitt <[email protected]>
5
 *
6
 * Licensed under the Apache License, Version 2.0 (the "License");
7
 * you may not use this file except in compliance with the License.
8
 * You may obtain a copy of the License at
9
 *
10
 * http://www.apache.org/licenses/LICENSE-2.0
11
 *
12
 * Unless required by applicable law or agreed to in writing, software
13
 * distributed under the License is distributed on an "AS IS" BASIS,
14
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15
 * See the License for the specific language governing permissions and
16
 * limitations under the License.
17
 */
18
19
namespace JMS\SerializerBundle\Tests\Cache;
20
21
use JMS\SerializerBundle\Cache\CacheWarmer;
22
use JMS\SerializerBundle\Tests\Cache\Files\Bar\BarBar;
23
use Metadata\MetadataFactoryInterface;
24
use PHPUnit\Framework\TestCase;
25
26
class CacheWarmerTest extends TestCase
27
{
28
    private $metadataFactory;
29
30
    public function setUp()
31
    {
32
        $this->metadataFactory = $this->getMockBuilder(MetadataFactoryInterface::class)
33
            ->disableOriginalConstructor()
34
            ->getMock();
35
    }
36
37 View Code Duplication
    public function testWarmUpRecursive()
0 ignored issues
show
Duplication introduced by
This method seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
38
    {
39
40
        $this->metadataFactory->expects($this->exactly(3))
41
            ->method('getMetadataForClass');
42
43
        $warmer = new CacheWarmer([__DIR__ . "/Files"], $this->metadataFactory);
44
        $warmer->warmUp("foo");
45
    }
46
47 View Code Duplication
    public function testWarmUpRecursiveWithInclusion()
0 ignored issues
show
Duplication introduced by
This method seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
48
    {
49
        $this->metadataFactory->expects($this->exactly(1))
50
            ->method('getMetadataForClass')->with(BarBar::class);
51
52
        $warmer = new CacheWarmer([__DIR__ . "/Files/Ba*"], $this->metadataFactory);
53
        $warmer->warmUp("foo");
54
    }
55
56 View Code Duplication
    public function testWarmUpRecursiveWithExclusion()
0 ignored issues
show
Duplication introduced by
This method seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
57
    {
58
        $this->metadataFactory->expects($this->exactly(2))
59
            ->method('getMetadataForClass');
60
61
        $warmer = new CacheWarmer([__DIR__ . "/Files"], $this->metadataFactory, ["Bar"]);
62
        $warmer->warmUp("foo");
63
    }
64
}
65
66