|
1
|
|
|
<?php declare(strict_types = 1); |
|
2
|
|
|
|
|
3
|
|
|
/* |
|
4
|
|
|
* This file is part of the Bukashk0zzzLiipImagineSerializationBundle |
|
5
|
|
|
* |
|
6
|
|
|
* (c) Denis Golubovskiy <[email protected]> |
|
7
|
|
|
* |
|
8
|
|
|
* For the full copyright and license information, please view the LICENSE |
|
9
|
|
|
* file that was distributed with this source code. |
|
10
|
|
|
*/ |
|
11
|
|
|
|
|
12
|
|
|
namespace Bukashk0zzz\LiipImagineSerializationBundle\Tests\Annotation; |
|
13
|
|
|
|
|
14
|
|
|
use Bukashk0zzz\LiipImagineSerializationBundle\Annotation\LiipImagineSerializableField; |
|
15
|
|
|
use PHPUnit\Framework\TestCase; |
|
16
|
|
|
|
|
17
|
|
|
/** |
|
18
|
|
|
* LiipImagineSerializableFieldTest |
|
19
|
|
|
*/ |
|
20
|
|
|
class LiipImagineSerializableFieldTest extends TestCase |
|
21
|
|
|
{ |
|
22
|
|
|
/** |
|
23
|
|
|
* Test annotation with `value` option |
|
24
|
|
|
*/ |
|
25
|
|
|
public function testValueOption(): void |
|
26
|
|
|
{ |
|
27
|
|
|
$annotation = new LiipImagineSerializableField(['value' => 'thumb_filter']); |
|
28
|
|
|
|
|
29
|
|
|
static::assertEquals('thumb_filter', $annotation->getFilter()); |
|
30
|
|
|
static::assertEmpty($annotation->getVichUploaderField()); |
|
31
|
|
|
static::assertEmpty($annotation->getVirtualField()); |
|
32
|
|
|
} |
|
33
|
|
|
|
|
34
|
|
|
/** |
|
35
|
|
|
* Test annotation with all options |
|
36
|
|
|
*/ |
|
37
|
|
|
public function testAllOptions(): void |
|
38
|
|
|
{ |
|
39
|
|
|
$annotation = new LiipImagineSerializableField([ |
|
40
|
|
|
'filter' => 'thumb_filter', |
|
41
|
|
|
'vichUploaderField' => 'photoFile', |
|
42
|
|
|
'virtualField' => 'photo_thumb', |
|
43
|
|
|
]); |
|
44
|
|
|
|
|
45
|
|
|
static::assertEquals('thumb_filter', $annotation->getFilter()); |
|
46
|
|
|
static::assertEquals('photoFile', $annotation->getVichUploaderField()); |
|
47
|
|
|
static::assertEquals('photo_thumb', $annotation->getVirtualField()); |
|
48
|
|
|
} |
|
49
|
|
|
|
|
50
|
|
|
/** |
|
51
|
|
|
* Test annotation without any option |
|
52
|
|
|
* |
|
53
|
|
|
* @expectedException \LogicException |
|
54
|
|
|
*/ |
|
55
|
|
|
public function testAnnotationWithoutOptions(): void |
|
56
|
|
|
{ |
|
57
|
|
|
new LiipImagineSerializableField([]); |
|
58
|
|
|
} |
|
59
|
|
|
|
|
60
|
|
|
/** |
|
61
|
|
|
* Test annotation with wrong type for `filter` option |
|
62
|
|
|
* |
|
63
|
|
|
* @expectedException \InvalidArgumentException |
|
64
|
|
|
*/ |
|
65
|
|
|
public function testWrongTypeForFilterOption(): void |
|
66
|
|
|
{ |
|
67
|
|
|
new LiipImagineSerializableField(['filter' => 123]); |
|
68
|
|
|
} |
|
69
|
|
|
|
|
70
|
|
|
/** |
|
71
|
|
|
* Test annotation with wrong type for `value` option |
|
72
|
|
|
* |
|
73
|
|
|
* @expectedException \InvalidArgumentException |
|
74
|
|
|
*/ |
|
75
|
|
|
public function testWrongTypeForValueOption(): void |
|
76
|
|
|
{ |
|
77
|
|
|
new LiipImagineSerializableField(['value' => 123]); |
|
78
|
|
|
} |
|
79
|
|
|
|
|
80
|
|
|
/** |
|
81
|
|
|
* Test annotation with wrong type for `vichUploaderField` option |
|
82
|
|
|
* |
|
83
|
|
|
* @expectedException \InvalidArgumentException |
|
84
|
|
|
*/ |
|
85
|
|
|
public function testWrongTypeForVichUploaderFieldOption(): void |
|
86
|
|
|
{ |
|
87
|
|
|
new LiipImagineSerializableField(['filter' => 'thumb_filter', 'vichUploaderField' => 123]); |
|
88
|
|
|
} |
|
89
|
|
|
|
|
90
|
|
|
/** |
|
91
|
|
|
* Test annotation with wrong type for `virtualField` option |
|
92
|
|
|
* |
|
93
|
|
|
* @expectedException \InvalidArgumentException |
|
94
|
|
|
*/ |
|
95
|
|
|
public function testWrongTypeForVirtualFieldOption(): void |
|
96
|
|
|
{ |
|
97
|
|
|
new LiipImagineSerializableField(['filter' => 'thumb_filter', 'virtualField' => 123]); |
|
98
|
|
|
} |
|
99
|
|
|
} |
|
100
|
|
|
|