Completed
Push — 2.0 ( 663717...809d1e )
by Nicolas
15:54
created

ThumbnailsManagerTest   A

Complexity

Total Complexity 4

Size/Duplication

Total Lines 44
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 2

Importance

Changes 3
Bugs 0 Features 0
Metric Value
wmc 4
c 3
b 0
f 0
lcom 1
cbo 2
dl 0
loc 44
rs 10

4 Methods

Rating   Name   Duplication   Size   Complexity  
A setUp() 0 5 1
A it_initialises_empty_array() 0 4 1
A it_can_add_a_thumbnail() 0 6 1
A it_can_find_a_thumbnail() 0 15 1
1
<?php
2
3
namespace Modules\Tests;
4
5
use Modules\Media\Image\ThumbnailManager;
6
use Modules\Media\Tests\MediaTestCase;
7
8
class ThumbnailsManagerTest extends MediaTestCase
9
{
10
    /**
11
     * @var ThumbnailManager
12
     */
13
    private $thumbnailManager;
14
15
    public function setUp()
16
    {
17
        parent::setUp();
18
        $this->thumbnailManager = app(ThumbnailManager::class);
19
    }
20
21
    /** @test */
22
    public function it_initialises_empty_array()
23
    {
24
        $this->assertCount(2, $this->thumbnailManager->all());
25
    }
26
27
    /** @test */
28
    public function it_can_add_a_thumbnail()
29
    {
30
        $this->thumbnailManager->registerThumbnail('coolThumb', []);
31
32
        $this->assertCount(3, $this->thumbnailManager->all());
33
    }
34
35
    /** @test */
36
    public function it_can_find_a_thumbnail()
37
    {
38
        $expected = [
39
            'resize' => [
40
                'width' => 180,
41
                'height' => null,
42
                'callback' => function ($constraint) {
43
                    $constraint->aspectRatio();
44
                    $constraint->upsize();
45
                },
46
            ],
47
        ];
48
49
        $this->assertEquals($expected, $this->thumbnailManager->find('mediumThumb'));
50
    }
51
}
52