irishdan /
ResponsiveImageBundle
These results are based on our legacy PHP analysis, consider migrating to our new PHP analysis engine instead. Learn more
| 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 | |||
| 12 | namespace IrishDan\ResponsiveImageBundle; |
||
| 13 | |||
| 14 | use Symfony\Component\HttpKernel\Config\FileLocator; |
||
| 15 | |||
| 16 | class ImageEntityClassLocatorTest extends \PHPUnit_Framework_TestCase |
||
| 17 | { |
||
| 18 | public function getBundleDirectory() |
||
| 19 | { |
||
| 20 | return $directory = __DIR__ . '/../'; |
||
|
0 ignored issues
–
show
|
|||
| 21 | } |
||
| 22 | |||
| 23 | View Code Duplication | public function testItCanFindTheClassWhenPresent() |
|
|
0 ignored issues
–
show
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...
|
|||
| 24 | { |
||
| 25 | // Mock the FileLocator to return the mock of the repository |
||
| 26 | $fileLocator = $this->getMockBuilder(FileLocator::class) |
||
| 27 | ->disableOriginalConstructor() |
||
| 28 | ->getMock(); |
||
| 29 | |||
| 30 | $fileLocator->expects($this->any()) |
||
| 31 | ->method('locate') |
||
| 32 | ->will($this->returnValue($this->getBundleDirectory())); |
||
| 33 | |||
| 34 | $bundles = [ |
||
| 35 | 'ResponsiveImageBundle' => 'IrishDan\ResponsiveImageBundle\ResponsiveImageBundle', |
||
| 36 | 'TwigBundle' => "Symfony\Bundle\TwigBundle\TwigBundle", |
||
| 37 | ]; |
||
| 38 | |||
| 39 | $locator = new ImageEntityClassLocator($bundles, $fileLocator); |
||
| 40 | |||
| 41 | $locator->setEntityDirectory('Tests/Entity'); |
||
| 42 | |||
| 43 | $this->assertEquals('IrishDan\ResponsiveImageBundle\Tests\Entity\TestImage', $locator->getClassName()); |
||
| 44 | } |
||
| 45 | |||
| 46 | View Code Duplication | public function testItCantFindTheClassWhenNotPresent() |
|
|
0 ignored issues
–
show
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...
|
|||
| 47 | { |
||
| 48 | // Mock the EntityManager to return the mock of the repository |
||
| 49 | $fileLocator = $this->getMockBuilder(FileLocator::class) |
||
| 50 | ->disableOriginalConstructor() |
||
| 51 | ->getMock(); |
||
| 52 | |||
| 53 | |||
| 54 | $fileLocator->expects($this->any()) |
||
| 55 | ->method('locate') |
||
| 56 | ->will($this->returnValue($this->getBundleDirectory())); |
||
| 57 | |||
| 58 | $bundles = [ |
||
| 59 | 'ResponsiveImageBundle' => 'IrishDan\ResponsiveImageBundle\ResponsiveImageBundle', |
||
| 60 | 'TwigBundle' => 'Symfony\Bundle\TwigBundle\TwigBundle', |
||
| 61 | ]; |
||
| 62 | |||
| 63 | $locator = new ImageEntityClassLocator($bundles, $fileLocator); |
||
| 64 | |||
| 65 | $this->assertNull($locator->getClassName()); |
||
| 66 | } |
||
| 67 | } |
||
| 68 |
This check looks for variable assignements that are either overwritten by other assignments or where the variable is not used subsequently.
Both the
$myVarassignment in line 1 and the$higherassignment in line 2 are dead. The first because$myVaris never used and the second because$higheris always overwritten for every possible time line.