Completed
Push — master ( 0136c1...94aca9 )
by Lukas Kahwe
03:29
created

FloatToIntCastByRoundDownscaleFilterLoaderTest   A

Complexity

Total Complexity 1

Size/Duplication

Total Lines 18
Duplicated Lines 100 %

Coupling/Cohesion

Components 0
Dependencies 5

Importance

Changes 1
Bugs 0 Features 1
Metric Value
dl 18
loc 18
wmc 1
c 1
b 0
f 1
lcom 0
cbo 5
rs 10

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\DownscaleFilterLoader;
7
use Liip\ImagineBundle\Tests\AbstractTest;
8
9
/**
10
 * @covers Liip\ImagineBundle\Imagine\Filter\Loader\DownscaleFilterLoader
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
class FloatToIntCastByRoundDownscaleFilterLoaderTest extends AbstractTest
17
{
18
    public function testLoad()
19
    {
20
        $loader = new DownscaleFilterLoader();
21
        $imagine = new Imagine();
22
        $image = $imagine->open(__DIR__.'/../../../Fixtures/assets/square-300x300.png');
23
24
        $options = array(
25
            'max' => array(201, 201),
26
        );
27
28
        $image = $loader->load($image, $options);
29
        $size = $image->getSize();
30
31
        $this->assertEquals($options['max'], array($size->getWidth(), $size->getHeight()));
32
    }
33
}
34