testItCantFindTheClassWhenNotPresent()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 21
Code Lines 12

Duplication

Lines 21
Ratio 100 %

Importance

Changes 0
Metric Value
dl 21
loc 21
rs 9.3142
c 0
b 0
f 0
cc 1
eloc 12
nc 1
nop 0
1
<?php
2
/**
3
 * This file is part of the IrishDan\ResponsiveImageBundle package.
4
 *
5
 * (c) Daniel Byrne <[email protected]>
6
 *
7
 * For the full copyright and license information, please view the LICENSE file that was distributed with this source
8
 * code.
9
 */
10
11
namespace IrishDan\ResponsiveImageBundle;
12
13
use Symfony\Component\HttpKernel\Config\FileLocator;
14
15
class ImageEntityClassLocatorTest extends \PHPUnit_Framework_TestCase
16
{
17
    public function getBundleDirectory()
18
    {
19
        return $directory = __DIR__ . '/../';
0 ignored issues
show
Unused Code introduced by
$directory is not used, you could remove the assignment.

This check looks for variable assignements that are either overwritten by other assignments or where the variable is not used subsequently.

$myVar = 'Value';
$higher = false;

if (rand(1, 6) > 3) {
    $higher = true;
} else {
    $higher = false;
}

Both the $myVar assignment in line 1 and the $higher assignment in line 2 are dead. The first because $myVar is never used and the second because $higher is always overwritten for every possible time line.

Loading history...
20
    }
21
22 View Code Duplication
    public function testItCanFindTheClassWhenPresent()
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...
23
    {
24
        // Mock the FileLocator to return the mock of the repository
25
        $fileLocator = $this->getMockBuilder(FileLocator::class)
26
                            ->disableOriginalConstructor()
27
                            ->getMock();
28
29
        $fileLocator->expects($this->any())
30
                    ->method('locate')
31
                    ->will($this->returnValue($this->getBundleDirectory()));
32
33
        $bundles = [
34
            'ResponsiveImageBundle' => 'IrishDan\ResponsiveImageBundle\ResponsiveImageBundle',
35
            'TwigBundle'            => "Symfony\Bundle\TwigBundle\TwigBundle",
36
        ];
37
38
        $locator = new ImageEntityClassLocator($bundles, $fileLocator);
39
40
        $locator->setEntityDirectory('Tests/Entity');
41
42
        $this->assertEquals('IrishDan\ResponsiveImageBundle\Tests\Entity\TestImage', $locator->getClassName());
43
    }
44
45 View Code Duplication
    public function testItCantFindTheClassWhenNotPresent()
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
    {
47
        // Mock the EntityManager to return the mock of the repository
48
        $fileLocator = $this->getMockBuilder(FileLocator::class)
49
                            ->disableOriginalConstructor()
50
                            ->getMock();
51
52
53
        $fileLocator->expects($this->any())
54
                    ->method('locate')
55
                    ->will($this->returnValue($this->getBundleDirectory()));
56
57
        $bundles = [
58
            'ResponsiveImageBundle' => 'IrishDan\ResponsiveImageBundle\ResponsiveImageBundle',
59
            'TwigBundle'            => 'Symfony\Bundle\TwigBundle\TwigBundle',
60
        ];
61
62
        $locator = new ImageEntityClassLocator($bundles, $fileLocator);
63
64
        $this->assertNull($locator->getClassName());
65
    }
66
}
67