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
|
|
|
|