|
@@ 106-118 (lines=13) @@
|
| 103 |
|
/** |
| 104 |
|
* Test serialization with included host in the URI |
| 105 |
|
*/ |
| 106 |
|
public function testSerializationWithIncludedHost() |
| 107 |
|
{ |
| 108 |
|
$user = (new Fixtures\UserA()) |
| 109 |
|
->setPhotoName('photo.jpg') |
| 110 |
|
->setCoverName('cover.jpg'); |
| 111 |
|
|
| 112 |
|
$context = DeserializationContext::create(); |
| 113 |
|
$event = new ObjectEvent($context, $user, []); |
| 114 |
|
$this->dispatcher->dispatch(JmsEvents::PRE_SERIALIZE, Fixtures\UserA::class, $context->getFormat(), $event); |
| 115 |
|
|
| 116 |
|
$this->assertEquals('http://example.com/uploads/photo.jpg', $user->getPhotoName()); |
| 117 |
|
$this->assertEquals('http://example.com/uploads/cover.jpg', $user->getCoverName()); |
| 118 |
|
} |
| 119 |
|
|
| 120 |
|
/** |
| 121 |
|
* Test serialization without included host in the URI |
|
@@ 123-135 (lines=13) @@
|
| 120 |
|
/** |
| 121 |
|
* Test serialization without included host in the URI |
| 122 |
|
*/ |
| 123 |
|
public function testSerializationWithoutIncludedHost() |
| 124 |
|
{ |
| 125 |
|
$user = (new Fixtures\UserB()) |
| 126 |
|
->setPhotoName('photo.jpg') |
| 127 |
|
->setCoverName('cover.jpg'); |
| 128 |
|
|
| 129 |
|
$context = DeserializationContext::create(); |
| 130 |
|
$event = new ObjectEvent($context, $user, []); |
| 131 |
|
$this->dispatcher->dispatch(JmsEvents::PRE_SERIALIZE, Fixtures\UserB::class, $context->getFormat(), $event); |
| 132 |
|
|
| 133 |
|
$this->assertEquals('http://example.com/uploads/photo.jpg', $user->getPhotoName()); |
| 134 |
|
$this->assertEquals('/uploads/cover.jpg', $user->getCoverName()); |
| 135 |
|
} |
| 136 |
|
|
| 137 |
|
/** |
| 138 |
|
* Test serialization without included host in the URI |
|
@@ 142-154 (lines=13) @@
|
| 139 |
|
* |
| 140 |
|
* @expectedException \Fresh\VichUploaderSerializationBundle\Exception\IncompatibleUploadableAndSerializableFieldAnnotationException |
| 141 |
|
*/ |
| 142 |
|
public function testExceptionForIncompatibleAnnotations() |
| 143 |
|
{ |
| 144 |
|
$user = (new Fixtures\UserC()) |
| 145 |
|
->setPhotoName('photo.jpg') |
| 146 |
|
->setCoverName('cover.jpg'); |
| 147 |
|
|
| 148 |
|
$context = DeserializationContext::create(); |
| 149 |
|
$event = new ObjectEvent($context, $user, []); |
| 150 |
|
$this->dispatcher->dispatch(JmsEvents::PRE_SERIALIZE, Fixtures\UserC::class, $context->getFormat(), $event); |
| 151 |
|
|
| 152 |
|
$this->assertEquals('http://example.com/uploads/photo.jpg', $user->getPhotoName()); |
| 153 |
|
$this->assertEquals('/uploads/cover.jpg', $user->getCoverName()); |
| 154 |
|
} |
| 155 |
|
} |
| 156 |
|
|