Completed
Push — master ( 7de777...9be641 )
by
unknown
11:28
created

ImageParameterBagTest   A

Complexity

Total Complexity 1

Size/Duplication

Total Lines 20
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 5

Importance

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

1 Method

Rating   Name   Duplication   Size   Complexity  
A testGettersSetters() 0 17 1
1
<?php
2
3
namespace MediaMonks\SonataMediaBundle\Tests\Unit\ParameterBag;
4
5
use MediaMonks\SonataMediaBundle\Model\MediaInterface;
6
use MediaMonks\SonataMediaBundle\ParameterBag\DownloadParameterBag;
7
use MediaMonks\SonataMediaBundle\ParameterBag\ImageParameterBag;
8
use Mockery as m;
9
10
class ImageParameterBagTest extends \PHPUnit_Framework_TestCase
11
{
12
    public function testGettersSetters()
13
    {
14
        $media = m::mock(MediaInterface::class);
15
        $media->shouldReceive('getId')->andReturn(1);
16
17
        $bag = new ImageParameterBag(400, 300);
18
        $this->assertEquals(['id' => 1, 'width' => 400, 'height' => 300], $bag->toArray($media));
19
        $bag->setExtra(['foo' => 'bar']);
20
        $this->assertEquals(['id' => 1, 'width' => 400, 'height' => 300, 'foo' => 'bar'], $bag->toArray($media));
21
        $this->assertFalse($bag->hasExtra('bar'));
22
        $bag->addExtra('bar', 'baz');
23
        $this->assertTrue($bag->hasExtra('bar'));
24
        $this->assertEquals(['id' => 1, 'width' => 400, 'height' => 300, 'foo' => 'bar', 'bar' => 'baz'], $bag->toArray($media));
25
        $bag->removeExtra('bar');
26
        $this->assertFalse($bag->hasExtra('bar'));
27
        $this->assertEquals(['id' => 1, 'width' => 400, 'height' => 300, 'foo' => 'bar'], $bag->toArray($media));
28
    }
29
}
30