1
|
|
|
<?php |
2
|
|
|
/* |
3
|
|
|
* This file is part of the FreshVichUploaderSerializationBundle |
4
|
|
|
* |
5
|
|
|
* (c) Artem Henvald <[email protected]> |
6
|
|
|
* |
7
|
|
|
* For the full copyright and license information, please view the LICENSE |
8
|
|
|
* file that was distributed with this source code. |
9
|
|
|
*/ |
10
|
|
|
|
11
|
|
|
namespace Fresh\VichUploaderSerializationBundle\Tests\Annotation; |
12
|
|
|
|
13
|
|
|
use Fresh\VichUploaderSerializationBundle\Annotation\VichSerializableField; |
14
|
|
|
|
15
|
|
|
/** |
16
|
|
|
* VichSerializableFieldTest. |
17
|
|
|
* |
18
|
|
|
* @author Artem Henvald <[email protected]> |
19
|
|
|
*/ |
20
|
|
|
class VichSerializableFieldTest extends \PHPUnit_Framework_TestCase |
21
|
|
|
{ |
22
|
|
|
public function testValueOption() |
23
|
|
|
{ |
24
|
|
|
$annotation = new VichSerializableField(['value' => 'photoFile']); |
25
|
|
|
|
26
|
|
|
$this->assertEquals('photoFile', $annotation->getField()); |
27
|
|
|
$this->assertTrue($annotation->isIncludeHost()); |
28
|
|
|
} |
29
|
|
|
|
30
|
|
|
public function testFieldOption() |
31
|
|
|
{ |
32
|
|
|
$annotation = new VichSerializableField(['field' => 'photoFile']); |
33
|
|
|
|
34
|
|
|
$this->assertEquals('photoFile', $annotation->getField()); |
35
|
|
|
$this->assertTrue($annotation->isIncludeHost()); |
36
|
|
|
} |
37
|
|
|
|
38
|
|
|
public function testValueAndIncludeHostOptions() |
39
|
|
|
{ |
40
|
|
|
$annotation = new VichSerializableField(['value' => 'photoFile', 'includeHost' => false]); |
41
|
|
|
|
42
|
|
|
$this->assertEquals('photoFile', $annotation->getField()); |
43
|
|
|
$this->assertFalse($annotation->isIncludeHost()); |
44
|
|
|
} |
45
|
|
|
|
46
|
|
|
/** |
47
|
|
|
* @expectedException \LogicException |
48
|
|
|
*/ |
49
|
|
|
public function testAnnotationWithoutOptions() |
50
|
|
|
{ |
51
|
|
|
new VichSerializableField([]); |
52
|
|
|
} |
53
|
|
|
|
54
|
|
|
/** |
55
|
|
|
* @expectedException \LogicException |
56
|
|
|
*/ |
57
|
|
|
public function testAnnotationWithoutIncludeHostOption() |
58
|
|
|
{ |
59
|
|
|
new VichSerializableField(['includeHost' => false]); |
60
|
|
|
} |
61
|
|
|
|
62
|
|
|
/** |
63
|
|
|
* @expectedException \InvalidArgumentException |
64
|
|
|
*/ |
65
|
|
|
public function testWrongTypeForValueOption() |
66
|
|
|
{ |
67
|
|
|
new VichSerializableField(['value' => 123]); |
68
|
|
|
} |
69
|
|
|
|
70
|
|
|
/** |
71
|
|
|
* @expectedException \InvalidArgumentException |
72
|
|
|
*/ |
73
|
|
|
public function testWrongTypeForFieldOption() |
74
|
|
|
{ |
75
|
|
|
new VichSerializableField(['field' => 123]); |
76
|
|
|
} |
77
|
|
|
|
78
|
|
|
/** |
79
|
|
|
* @expectedException \InvalidArgumentException |
80
|
|
|
*/ |
81
|
|
|
public function testWrongTypeForFieldIncludeHost() |
82
|
|
|
{ |
83
|
|
|
new VichSerializableField(['value' => 'photoFile', 'includeHost' => 123]); |
84
|
|
|
} |
85
|
|
|
} |
86
|
|
|
|