Completed
Pull Request — master (#732)
by 12345
03:41
created

FloatToIntCastByRoundUpscaleFilterLoaderTest   A

Complexity

Total Complexity 1

Size/Duplication

Total Lines 18
Duplicated Lines 100 %

Coupling/Cohesion

Components 0
Dependencies 5
Metric Value
wmc 1
lcom 0
cbo 5
dl 18
loc 18
rs 10

1 Method

Rating   Name   Duplication   Size   Complexity  
A testLoad() 15 15 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
namespace Liip\ImagineBundle\Tests\Filter;
4
5
use Imagine\Gd\Imagine;
6
use Liip\ImagineBundle\Imagine\Filter\Loader\UpscaleFilterLoader;
7
use Liip\ImagineBundle\Tests\AbstractTest;
8
9
/**
10
 * @covers Liip\ImagineBundle\Imagine\Filter\Loader\UpscaleFilterLoader
11
 *
12
 * Due to int casting in Imagine\Image\Box which can lead to wrong pixel
13
 * numbers ( e.g. float(201) casted to int(200) ). Solved by round the
14
 * floating number before passing to the Box constructor.
15
 */
16 View Code Duplication
class FloatToIntCastByRoundUpscaleFilterLoaderTest extends AbstractTest
0 ignored issues
show
Duplication introduced by
This class 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...
17
{
18
    public function testLoad()
19
    {
20
        $loader = new UpscaleFilterLoader();
21
        $imagine = new Imagine();
22
        $image = $imagine->open(__DIR__.'/../../../Fixtures/assets/square-50x50.png');
23
24
        $options = array(
25
            'min' => array(201, 201),
26
        );
27
28
        $image = $loader->load($image, $options);
29
        $size = $image->getSize();
30
31
        $this->assertEquals($options['min'], array($size->getWidth(), $size->getHeight()));
32
    }
33
}
34