Completed
Push — master ( 906add...e6fdb6 )
by
unknown
18:20 queued 11s
created

ImagineCompatibleResizerTraitTest   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 25
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 0

Importance

Changes 0
Metric Value
wmc 2
lcom 0
cbo 0
dl 0
loc 25
rs 10
c 0
b 0
f 0

2 Methods

Rating   Name   Duplication   Size   Complexity  
A testModeConversion() 0 11 1
A getModes() 0 7 1
1
<?php
2
3
declare(strict_types=1);
4
5
/*
6
 * This file is part of the Sonata Project package.
7
 *
8
 * (c) Thomas Rabaix <[email protected]>
9
 *
10
 * For the full copyright and license information, please view the LICENSE
11
 * file that was distributed with this source code.
12
 */
13
14
namespace Sonata\MediaBundle\Tests\Resizer;
15
16
use Imagine\Image\ImageInterface;
17
use PHPUnit\Framework\TestCase;
18
use Sonata\MediaBundle\Resizer\ImagineCompatibleResizerTrait;
19
20
class ImagineCompatibleResizerTraitTest extends TestCase
21
{
22
    /**
23
     * @dataProvider getModes
24
     */
25
    public function testModeConversion($mode, $result): void
26
    {
27
        $objectWithTrait = $this->getObjectForTrait(ImagineCompatibleResizerTrait::class);
28
        $reflection = new \ReflectionObject($objectWithTrait);
29
        $method = $reflection->getMethod('convertMode');
30
        $method->setAccessible(true);
31
32
        $convertedMode = $method->invokeArgs($objectWithTrait, [$mode]);
33
34
        $this->assertSame($result, $convertedMode);
35
    }
36
37
    public static function getModes()
38
    {
39
        return [
40
            ['inset', ImageInterface::THUMBNAIL_INSET],
41
            ['outbound', ImageInterface::THUMBNAIL_OUTBOUND],
42
        ];
43
    }
44
}
45