Completed
Pull Request — 5.4 (#2671)
by Jeroen
639:18 queued 633:10
created

ImageHandlerTest   A

Complexity

Total Complexity 1

Size/Duplication

Total Lines 20
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 6

Importance

Changes 0
Metric Value
wmc 1
lcom 0
cbo 6
dl 0
loc 20
rs 10
c 0
b 0
f 0

1 Method

Rating   Name   Duplication   Size   Complexity  
A testPrepareWithSvg() 0 17 1
1
<?php
2
3
namespace Kunstmaan\MediaBundle\Tests\Helper\Image;
4
5
use Kunstmaan\MediaBundle\Entity\Media;
6
use Kunstmaan\MediaBundle\Helper\Image\ImageHandler;
7
use Kunstmaan\UtilitiesBundle\Helper\Slugifier;
8
use PHPUnit\Framework\TestCase;
9
use Symfony\Component\HttpFoundation\File\File;
10
use Symfony\Component\HttpFoundation\File\MimeType\MimeTypeGuesser;
11
use Kunstmaan\MediaBundle\Helper\MimeTypeGuesserFactoryInterface;
12
use Kunstmaan\MediaBundle\Helper\ExtensionGuesserFactoryInterface;
13
14
class ImageHandlerTest extends TestCase
15
{
16
    public function testPrepareWithSvg()
17
    {
18
        $mockMimeTypeGuesserfactory = $this->createMock(MimeTypeGuesserFactoryInterface::class);
19
        $mockExtensionGuesserfactory = $this->createMock(ExtensionGuesserFactoryInterface::class);
20
21
        $mockMimeTypeGuesserfactory->method('get')->willReturn(MimeTypeGuesser::getInstance());
22
23
        $handler = new ImageHandler(1, $mockMimeTypeGuesserfactory, $mockExtensionGuesserfactory, 'aviaryKey');
0 ignored issues
show
Documentation introduced by
$mockMimeTypeGuesserfactory is of type object<PHPUnit\Framework\MockObject\MockObject>, but the function expects a object<Kunstmaan\MediaBu...uesserFactoryInterface>.

It seems like the type of the argument is not accepted by the function/method which you are calling.

In some cases, in particular if PHP’s automatic type-juggling kicks in this might be fine. In other cases, however this might be a bug.

We suggest to add an explicit type cast like in the following example:

function acceptsInteger($int) { }

$x = '123'; // string "123"

// Instead of
acceptsInteger($x);

// we recommend to use
acceptsInteger((integer) $x);
Loading history...
Documentation introduced by
$mockExtensionGuesserfactory is of type object<PHPUnit\Framework\MockObject\MockObject>, but the function expects a object<Kunstmaan\MediaBu...uesserFactoryInterface>.

It seems like the type of the argument is not accepted by the function/method which you are calling.

In some cases, in particular if PHP’s automatic type-juggling kicks in this might be fine. In other cases, however this might be a bug.

We suggest to add an explicit type cast like in the following example:

function acceptsInteger($int) { }

$x = '123'; // string "123"

// Instead of
acceptsInteger($x);

// we recommend to use
acceptsInteger((integer) $x);
Loading history...
24
        $handler->setSlugifier(new Slugifier());
25
26
        $media = new Media();
27
        $media->setContent(new File(__DIR__.'/../../Fixtures/sample.svg'));
28
29
        $handler->prepareMedia($media);
30
31
        $this->assertSame(['original_width' => null, 'original_height' => null], $media->getMetadata());
32
    }
33
}
34