FileLocatorTestCase   A
last analyzed

Complexity

Total Complexity 3

Size/Duplication

Total Lines 70
Duplicated Lines 44.29 %

Coupling/Cohesion

Components 1
Dependencies 2

Importance

Changes 0
Metric Value
dl 31
loc 70
c 0
b 0
f 0
wmc 3
lcom 1
cbo 2
rs 10

4 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 21 21 1
createLocator() 0 1 ?
A testfindMappingFile() 0 9 1
A testGetAllClassNames() 10 10 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
 * This file is part of the Cubiche/Metadata component.
5
 *
6
 * Copyright (c) Cubiche
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 Cubiche\Core\Metadata\Tests\Units\Locator;
13
14
use Cubiche\Core\Metadata\Locator\FileLocatorInterface;
15
use Cubiche\Core\Metadata\Tests\Fixtures\Address;
16
use Cubiche\Core\Metadata\Tests\Fixtures\User;
17
use Cubiche\Core\Metadata\Tests\Units\TestCase;
18
use mageekguy\atoum\adapter as Adapter;
19
use mageekguy\atoum\annotations\extractor as Extractor;
20
use mageekguy\atoum\asserter\generator as Generator;
21
use mageekguy\atoum\test\assertion\manager as Manager;
22
use mageekguy\atoum\tools\variable\analyzer as Analyzer;
23
24
/**
25
 * FileLocatorTestCase class.
26
 *
27
 * Generated by TestGenerator on 2017-05-16 at 13:17:21.
28
 */
29
abstract class FileLocatorTestCase extends TestCase
30
{
31
    /**
32
     * @var string
33
     */
34
    protected $mappingDirectory;
35
36
    /**
37
     * @param Adapter   $adapter
38
     * @param Extractor $annotationExtractor
39
     * @param Generator $asserterGenerator
40
     * @param Manager   $assertionManager
41
     * @param \Closure  $reflectionClassFactory
42
     * @param \Closure  $phpExtensionFactory
43
     * @param Analyzer  $analyzer
44
     */
45 View Code Duplication
    public function __construct(
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...
46
        Adapter $adapter = null,
47
        Extractor $annotationExtractor = null,
48
        Generator $asserterGenerator = null,
49
        Manager $assertionManager = null,
50
        \Closure $reflectionClassFactory = null,
51
        \Closure $phpExtensionFactory = null,
52
        Analyzer $analyzer = null
53
    ) {
54
        parent::__construct(
55
            $adapter,
56
            $annotationExtractor,
57
            $asserterGenerator,
58
            $assertionManager,
59
            $reflectionClassFactory,
60
            $phpExtensionFactory,
61
            $analyzer
62
        );
63
64
        $this->mappingDirectory = __DIR__.'/../../Fixtures/mapping';
65
    }
66
67
    /**
68
     * @return FileLocatorInterface
69
     */
70
    abstract protected function createLocator();
71
72
    /**
73
     * Test findMappingFile method.
74
     */
75
    public function testfindMappingFile()
76
    {
77
        $this
78
            ->given($locator = $this->createLocator())
79
            ->then()
80
                ->string($locator->findMappingFile(User::class, '.xml'))
81
                    ->isEqualTo($this->mappingDirectory.'/Fixtures.User.xml')
82
        ;
83
    }
84
85
    /**
86
     * Test getAllClassNames method.
87
     */
88 View Code Duplication
    public function testGetAllClassNames()
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...
89
    {
90
        $this
91
            ->given($locator = $this->createLocator())
92
            ->then()
93
                ->array($locator->getAllClassNames('.xml'))
94
                    ->contains(Address::class)
95
                    ->contains(User::class)
96
        ;
97
    }
98
}
99