|
12 | 12 | namespace Gedmo\Tests\Uploadable\Mapping;
|
13 | 13 |
|
14 | 14 | use Doctrine\ORM\Mapping\ClassMetadata;
|
| 15 | +use Doctrine\ORM\Mapping\FieldMapping; |
15 | 16 | use Gedmo\Exception\InvalidMappingException;
|
16 | 17 | use Gedmo\Exception\UploadableInvalidPathException;
|
17 | 18 | use Gedmo\Uploadable\FilenameGenerator\FilenameGeneratorSha1;
|
@@ -51,7 +52,13 @@ public function testValidateFieldIfFieldIsNotOfAValidTypeThrowException(): void
|
51 | 52 | $this->expectException(InvalidMappingException::class);
|
52 | 53 | $this->meta->expects(static::once())
|
53 | 54 | ->method('getFieldMapping')
|
54 |
| - ->willReturn(['type' => 'someType']); |
| 55 | + ->willReturnCallback(static function (string $fieldName) { |
| 56 | + if (class_exists(FieldMapping::class)) { |
| 57 | + return FieldMapping::fromMappingArray(['type' => 'someType', 'fieldName' => $fieldName, 'columnName' => $fieldName]); |
| 58 | + } |
| 59 | + |
| 60 | + return ['type' => 'someType']; |
| 61 | + }); |
55 | 62 |
|
56 | 63 | Validator::validateField(
|
57 | 64 | $this->meta,
|
@@ -122,7 +129,13 @@ public function testValidateConfigurationIfFilenameGeneratorValueIsNotValidThrow
|
122 | 129 | ->willReturn(new \ReflectionClass(new FakeEntity()));
|
123 | 130 | $this->meta
|
124 | 131 | ->method('getFieldMapping')
|
125 |
| - ->willReturn(['type' => 'someType']); |
| 132 | + ->willReturnCallback(static function (string $fieldName) { |
| 133 | + if (class_exists(FieldMapping::class)) { |
| 134 | + return FieldMapping::fromMappingArray(['type' => 'someType', 'fieldName' => $fieldName, 'columnName' => $fieldName]); |
| 135 | + } |
| 136 | + |
| 137 | + return ['type' => 'someType']; |
| 138 | + }); |
126 | 139 |
|
127 | 140 | $config = [
|
128 | 141 | 'fileMimeTypeField' => '',
|
@@ -151,7 +164,13 @@ public function testValidateConfigurationIfFilenameGeneratorValueIsValidButDoesn
|
151 | 164 | ->willReturn(new \ReflectionClass(new FakeEntity()));
|
152 | 165 | $this->meta
|
153 | 166 | ->method('getFieldMapping')
|
154 |
| - ->willReturn(['type' => 'someType']); |
| 167 | + ->willReturnCallback(static function (string $fieldName) { |
| 168 | + if (class_exists(FieldMapping::class)) { |
| 169 | + return FieldMapping::fromMappingArray(['type' => 'someType', 'fieldName' => $fieldName, 'columnName' => $fieldName]); |
| 170 | + } |
| 171 | + |
| 172 | + return ['type' => 'someType']; |
| 173 | + }); |
155 | 174 |
|
156 | 175 | $config = [
|
157 | 176 | 'fileMimeTypeField' => '',
|
@@ -179,7 +198,13 @@ public function testValidateConfigurationIfFilenameGeneratorValueIsValidThenDont
|
179 | 198 | ->willReturn(new \ReflectionClass(new FakeEntity()));
|
180 | 199 | $this->meta
|
181 | 200 | ->method('getFieldMapping')
|
182 |
| - ->willReturn(['type' => 'string']); |
| 201 | + ->willReturnCallback(static function (string $fieldName) { |
| 202 | + if (class_exists(FieldMapping::class)) { |
| 203 | + return FieldMapping::fromMappingArray(['type' => 'string', 'fieldName' => $fieldName, 'columnName' => $fieldName]); |
| 204 | + } |
| 205 | + |
| 206 | + return ['type' => 'string']; |
| 207 | + }); |
183 | 208 |
|
184 | 209 | $config = [
|
185 | 210 | 'fileMimeTypeField' => '',
|
@@ -207,7 +232,13 @@ public function testValidateConfigurationIfFilenameGeneratorValueIsAValidClassTh
|
207 | 232 | ->willReturn(new \ReflectionClass(new FakeEntity()));
|
208 | 233 | $this->meta
|
209 | 234 | ->method('getFieldMapping')
|
210 |
| - ->willReturn(['type' => 'string']); |
| 235 | + ->willReturnCallback(static function (string $fieldName) { |
| 236 | + if (class_exists(FieldMapping::class)) { |
| 237 | + return FieldMapping::fromMappingArray(['type' => 'string', 'fieldName' => $fieldName, 'columnName' => $fieldName]); |
| 238 | + } |
| 239 | + |
| 240 | + return ['type' => 'string']; |
| 241 | + }); |
211 | 242 |
|
212 | 243 | $config = [
|
213 | 244 | 'fileMimeTypeField' => '',
|
|
0 commit comments