1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
namespace HtImgModuleTest\Options; |
4
|
|
|
|
5
|
|
|
use HtImgModule\Options\ModuleOptions; |
6
|
|
|
|
7
|
|
|
class ModuleOptionsTest extends \PHPUnit_Framework_TestCase |
8
|
|
|
{ |
9
|
|
|
|
10
|
|
|
public function testSettersAndGetters() |
11
|
|
|
{ |
12
|
|
|
$moduleOptions = new ModuleOptions([ |
13
|
|
|
'enable_cache' => false, |
14
|
|
|
'img_source_path_stack' => ['img/'], |
15
|
|
|
'img_source_map' => ['name' => 'hello'], |
16
|
|
|
'driver' => 'imagick', |
17
|
|
|
'filters' => ['hello'], |
18
|
|
|
'web_root' => 'web', |
19
|
|
|
'image_resolvers' => ['image_resolvers'], |
20
|
|
|
'cache_path' => 'images', |
21
|
|
|
'cache_expiry' => 678678, |
22
|
|
|
'filter_loaders' => ['factories' => [], 'aliases' => []], |
23
|
|
|
'default_image_loader' => 'my_image_loader', |
24
|
|
|
]); |
25
|
|
|
$this->assertEquals(false, $moduleOptions->getEnableCache()); |
26
|
|
|
$this->assertEquals(['img/'], $moduleOptions->getImgSourcePathStack()); |
27
|
|
|
$this->assertEquals(['name' => 'hello'], $moduleOptions->getImgSourceMap()); |
28
|
|
|
$this->assertEquals('imagick', $moduleOptions->getDriver()); |
29
|
|
|
$this->assertEquals(['hello'], $moduleOptions->getFilters()); |
30
|
|
|
$this->assertEquals('web', $moduleOptions->getWebRoot()); |
31
|
|
|
$this->assertEquals(['image_resolvers'], $moduleOptions->getImageResolvers()); |
32
|
|
|
$this->assertEquals('images', $moduleOptions->getCachePath()); |
33
|
|
|
$this->assertEquals(678678, $moduleOptions->getCacheExpiry()); |
34
|
|
|
$this->assertEquals(['factories' => [], 'aliases' => []], $moduleOptions->getFilterLoaders()); |
35
|
|
|
$this->assertEquals('my_image_loader', $moduleOptions->getDefaultImageLoader()); |
36
|
|
|
} |
37
|
|
|
|
38
|
|
|
public function testGetExceptionWithInvalidDriver() |
39
|
|
|
{ |
40
|
|
|
$this->setExpectedException('HtImgModule\Exception\InvalidArgumentException'); |
|
|
|
|
41
|
|
|
$moduleOptions = new ModuleOptions(['driver' => 'iasfdasdf',]); |
|
|
|
|
42
|
|
|
} |
43
|
|
|
|
44
|
|
|
public function testAddFilter() |
45
|
|
|
{ |
46
|
|
|
$moduleOptions = new ModuleOptions; |
47
|
|
|
$moduleOptions->addFilter('foo_and_crop', ['foo' => 'crop']); |
48
|
|
|
$this->assertCount(1, $moduleOptions->getFilters()); |
49
|
|
|
$this->assertEquals(['foo' => 'crop'], $moduleOptions->getFilters()['foo_and_crop']); |
50
|
|
|
} |
51
|
|
|
} |
52
|
|
|
|
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.