GitHub Access Token became invalid

It seems like the GitHub access token used for retrieving details about this repository from GitHub became invalid. This might prevent certain types of inspections from being run (in particular, everything related to pull requests).
Please ask an admin of your repository to re-new the access token on this website.

LoaderManagerTest::testLoadBinary()   B
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 42
Code Lines 33

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 42
rs 8.8571
c 0
b 0
f 0
cc 1
eloc 33
nc 1
nop 2
1
<?php
2
namespace HtImgModuleTest\Imagine\Loader;
3
4
use HtImgModule\Imagine\Loader\LoaderManager;
5
6
class LoaderManagerTest extends \PHPUnit_Framework_TestCase
7
{
8
    public function testGetExceptionWhenImageLoaderCannotLoadImage()
9
    {
10
        $imageLoaders  = $this->createMock('Zend\ServiceManager\ServiceLocatorInterface');
11
        $filterManager = $this->createMock('HtImgModule\Imagine\Filter\FilterManagerInterface');
12
        $imageLoader = $this->createMock('HtImgModule\Imagine\Loader\LoaderInterface');
13
        $mimeTypeGuesser = $this->getMockBuilder('HtImgModule\Binary\MimeTypeGuesser')
14
            ->disableOriginalConstructor()
15
            ->getMock();
16
        $loadManager = new LoaderManager($imageLoaders, $filterManager, $imageLoader, $mimeTypeGuesser);
17
18
        $relativePath = 'relative/path/of/some/image';
19
        $imageLoader->expects($this->once())
20
            ->method('load')
21
            ->with($relativePath)
22
            ->will($this->returnValue(FALSE));
23
24
        $this->setExpectedException('HtImgModule\Exception\ImageNotFoundException');
0 ignored issues
show
Deprecated Code introduced by
The method PHPUnit_Framework_TestCase::setExpectedException() has been deprecated with message: Method deprecated since Release 5.2.0; use expectException() instead

This method has been deprecated. The supplier of the class has supplied an explanatory message.

The explanatory message should give you some clue as to whether and when the method will be removed from the class and what other method or class to use instead.

Loading history...
25
        $loadManager->loadBinary($relativePath, 'asdf');
26
    }
27
28
    public function getData()
29
    {
30
        return [
31
            ['awesome_image_loader', ['loader_options' => ['a' => []]]],
32
            ['awesome_image_loader_2', []],
33
        ];
34
    }
35
36
    /**
37
     * @dataProvider getData
38
     */
39
    public function testLoadBinary($imageLoaderName, $filterOptions)
40
    {
41
        $imageLoaders  = $this->createMock('Zend\ServiceManager\ServiceLocatorInterface');
42
        $filterManager = $this->createMock('HtImgModule\Imagine\Filter\FilterManagerInterface');
43
        $imageLoader = $this->createMock('HtImgModule\Imagine\Loader\LoaderInterface');
44
        $mimeTypeGuesser = $this->getMockBuilder('HtImgModule\Binary\MimeTypeGuesser')
45
            ->disableOriginalConstructor()
46
            ->getMock();
47
        $loadManager = new LoaderManager($imageLoaders, $filterManager, $imageLoader, $mimeTypeGuesser);
48
49
        $relativePath = 'relative/path/of/some/image';
50
        $filter = 'bar_filter';
51
        $binaryContent = 'asdf55asd4f53as4df54asdf564asdf';
52
        $mimeType = 'image/png';
53
        $filterOptions['image_loader'] = $imageLoaderName;
54
55
        $filterManager->expects($this->once())
56
            ->method('getFilterOptions')
57
            ->with($filter)
58
            ->will($this->returnValue($filterOptions));
59
60
        $imageLoaders->expects($this->once())
61
            ->method('get')
62
            ->with($imageLoaderName)
63
            ->will($this->returnValue($imageLoader));
64
65
        $imageLoader->expects($this->once())
66
            ->method('load')
67
            ->with($relativePath)
68
            ->will($this->returnValue($binaryContent));
69
70
        $mimeTypeGuesser->expects($this->once())
71
            ->method('guess')
72
            ->with($binaryContent)
73
            ->will($this->returnValue($mimeType));
74
75
        $binary = $loadManager->loadBinary($relativePath, $filter);
76
77
        $this->assertInstanceOf('HtImgModule\Binary\Binary', $binary);
78
        $this->assertEquals($mimeType, $binary->getMimeType());
79
        $this->assertEquals($loadManager->getExtensionGuesser()->guess($mimeType), $binary->getFormat());
80
    }
81
}
82