1
|
|
|
<?php |
2
|
|
|
/** |
3
|
|
|
This file is part of WideImage. |
4
|
|
|
|
5
|
|
|
WideImage is free software; you can redistribute it and/or modify |
6
|
|
|
it under the terms of the GNU Lesser General Public License as published by |
7
|
|
|
the Free Software Foundation; either version 2.1 of the License, or |
8
|
|
|
(at your option) any later version. |
9
|
|
|
|
10
|
|
|
WideImage is distributed in the hope that it will be useful, |
11
|
|
|
but WITHOUT ANY WARRANTY; without even the implied warranty of |
12
|
|
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
13
|
|
|
GNU Lesser General Public License for more details. |
14
|
|
|
|
15
|
|
|
You should have received a copy of the GNU Lesser General Public License |
16
|
|
|
along with WideImage; if not, write to the Free Software |
17
|
|
|
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA |
18
|
|
|
|
19
|
|
|
* @package Tests |
20
|
|
|
**/ |
21
|
|
|
|
22
|
|
|
namespace Test\WideImage; |
23
|
|
|
|
24
|
|
|
include_once __DIR__ . '/Operation/MyOperation.php'; |
25
|
|
|
|
26
|
|
|
use WideImage\OperationFactory; |
27
|
|
|
use WideImage\Operation\MyOperation; |
28
|
|
|
use Test\WideImage_TestCase; |
29
|
|
|
|
30
|
|
|
/** |
31
|
|
|
* @package Tests |
32
|
|
|
*/ |
33
|
|
|
class OperationFactoryTest extends WideImage_TestCase |
34
|
|
|
{ |
35
|
|
|
public function testFactoryReturnsCached() |
36
|
|
|
{ |
37
|
|
|
$op1 = OperationFactory::get('Mirror'); |
38
|
|
|
$op2 = OperationFactory::get('Mirror'); |
39
|
|
|
$this->assertSame($op1, $op2); |
40
|
|
|
} |
41
|
|
|
|
42
|
|
|
/** |
43
|
|
|
* @expectedException WideImage\Exception\UnknownImageOperationException |
44
|
|
|
*/ |
45
|
|
|
public function testNoOperation() |
46
|
|
|
{ |
47
|
|
|
$op = OperationFactory::get('NoSuchOp'); |
|
|
|
|
48
|
|
|
} |
49
|
|
|
|
50
|
|
|
public function testUserDefinedOp() |
51
|
|
|
{ |
52
|
|
|
$op = OperationFactory::get('MyOperation'); |
53
|
|
|
$this->assertTrue($op instanceof MyOperation); |
54
|
|
|
} |
55
|
|
|
} |
56
|
|
|
|