|
1
|
|
|
<?php |
|
2
|
|
|
|
|
3
|
|
|
declare(strict_types=1); |
|
4
|
|
|
|
|
5
|
|
|
/* |
|
6
|
|
|
* This file is part of the Sonata Project package. |
|
7
|
|
|
* |
|
8
|
|
|
* (c) Thomas Rabaix <[email protected]> |
|
9
|
|
|
* |
|
10
|
|
|
* For the full copyright and license information, please view the LICENSE |
|
11
|
|
|
* file that was distributed with this source code. |
|
12
|
|
|
*/ |
|
13
|
|
|
|
|
14
|
|
|
namespace Sonata\AdminBundle\Tests\Action; |
|
15
|
|
|
|
|
16
|
|
|
use PHPUnit\Framework\TestCase; |
|
17
|
|
|
use Prophecy\Argument; |
|
18
|
|
|
use Sonata\AdminBundle\Action\GetShortObjectDescriptionAction; |
|
19
|
|
|
use Sonata\AdminBundle\Action\SetObjectFieldValueAction; |
|
20
|
|
|
use Sonata\AdminBundle\Admin\AbstractAdmin; |
|
21
|
|
|
use Sonata\AdminBundle\Admin\FieldDescriptionInterface; |
|
22
|
|
|
use Sonata\AdminBundle\Admin\Pool; |
|
23
|
|
|
use Sonata\AdminBundle\Model\ModelManagerInterface; |
|
24
|
|
|
use Sonata\AdminBundle\Templating\TemplateRegistryInterface; |
|
25
|
|
|
use Sonata\AdminBundle\Twig\Extension\SonataAdminExtension; |
|
26
|
|
|
use Symfony\Component\DependencyInjection\ContainerInterface; |
|
27
|
|
|
use Symfony\Component\HttpFoundation\Request; |
|
28
|
|
|
use Symfony\Component\HttpFoundation\Response; |
|
29
|
|
|
use Symfony\Component\PropertyAccess\PropertyAccessor; |
|
30
|
|
|
use Symfony\Component\Validator\ConstraintViolation; |
|
31
|
|
|
use Symfony\Component\Validator\ConstraintViolationList; |
|
32
|
|
|
use Symfony\Component\Validator\Validator\ValidatorInterface; |
|
33
|
|
|
use Symfony\Contracts\Translation\TranslatorInterface; |
|
34
|
|
|
use Twig\Environment; |
|
35
|
|
|
use Twig\Loader\ArrayLoader; |
|
36
|
|
|
|
|
37
|
|
|
final class SetObjectFieldValueActionTest extends TestCase |
|
38
|
|
|
{ |
|
39
|
|
|
/** |
|
40
|
|
|
* @var Pool |
|
41
|
|
|
*/ |
|
42
|
|
|
private $pool; |
|
43
|
|
|
|
|
44
|
|
|
/** |
|
45
|
|
|
* @var Environment |
|
46
|
|
|
*/ |
|
47
|
|
|
private $twig; |
|
48
|
|
|
|
|
49
|
|
|
/** |
|
50
|
|
|
* @var GetShortObjectDescriptionAction |
|
51
|
|
|
*/ |
|
52
|
|
|
private $action; |
|
53
|
|
|
|
|
54
|
|
|
/** |
|
55
|
|
|
* @var AbstractAdmin |
|
56
|
|
|
*/ |
|
57
|
|
|
private $admin; |
|
58
|
|
|
|
|
59
|
|
|
/** |
|
60
|
|
|
* @var ValidatorInterface |
|
61
|
|
|
*/ |
|
62
|
|
|
private $validator; |
|
63
|
|
|
|
|
64
|
|
|
protected function setUp(): void |
|
65
|
|
|
{ |
|
66
|
|
|
$this->twig = new Environment(new ArrayLoader([ |
|
67
|
|
|
'admin_template' => 'renderedTemplate', |
|
68
|
|
|
'field_template' => 'renderedTemplate', |
|
69
|
|
|
])); |
|
70
|
|
|
$this->pool = $this->prophesize(Pool::class); |
|
71
|
|
|
$this->admin = $this->prophesize(AbstractAdmin::class); |
|
72
|
|
|
$this->pool->getInstance(Argument::any())->willReturn($this->admin->reveal()); |
|
73
|
|
|
$this->admin->setRequest(Argument::type(Request::class))->shouldBeCalled(); |
|
74
|
|
|
$this->validator = $this->prophesize(ValidatorInterface::class); |
|
75
|
|
|
$this->action = new SetObjectFieldValueAction( |
|
|
|
|
|
|
76
|
|
|
$this->twig, |
|
77
|
|
|
$this->pool->reveal(), |
|
78
|
|
|
$this->validator->reveal() |
|
79
|
|
|
); |
|
80
|
|
|
} |
|
81
|
|
|
|
|
82
|
|
|
public function testSetObjectFieldValueAction(): void |
|
83
|
|
|
{ |
|
84
|
|
|
$object = new Foo(); |
|
85
|
|
|
$request = new Request([ |
|
86
|
|
|
'code' => 'sonata.post.admin', |
|
87
|
|
|
'objectId' => 42, |
|
88
|
|
|
'field' => 'enabled', |
|
89
|
|
|
'value' => 1, |
|
90
|
|
|
'context' => 'list', |
|
91
|
|
|
], [], [], [], [], ['REQUEST_METHOD' => Request::METHOD_POST, 'HTTP_X_REQUESTED_WITH' => 'XMLHttpRequest']); |
|
92
|
|
|
|
|
93
|
|
|
$fieldDescription = $this->prophesize(FieldDescriptionInterface::class); |
|
94
|
|
|
$pool = $this->prophesize(Pool::class); |
|
95
|
|
|
$translator = $this->prophesize(TranslatorInterface::class); |
|
96
|
|
|
$propertyAccessor = new PropertyAccessor(); |
|
97
|
|
|
$templateRegistry = $this->prophesize(TemplateRegistryInterface::class); |
|
98
|
|
|
$container = $this->prophesize(ContainerInterface::class); |
|
99
|
|
|
|
|
100
|
|
|
$this->admin->getObject(42)->willReturn($object); |
|
101
|
|
|
$this->admin->getCode()->willReturn('sonata.post.admin'); |
|
|
|
|
|
|
102
|
|
|
$this->admin->hasAccess('edit', $object)->willReturn(true); |
|
|
|
|
|
|
103
|
|
|
$this->admin->getListFieldDescription('enabled')->willReturn($fieldDescription->reveal()); |
|
|
|
|
|
|
104
|
|
|
$this->admin->update($object)->shouldBeCalled(); |
|
105
|
|
|
// NEXT_MAJOR: Remove this line |
|
106
|
|
|
$this->admin->getTemplate('base_list_field')->willReturn('admin_template'); |
|
|
|
|
|
|
107
|
|
|
$templateRegistry->getTemplate('base_list_field')->willReturn('admin_template'); |
|
108
|
|
|
$container->get('sonata.post.admin.template_registry')->willReturn($templateRegistry->reveal()); |
|
109
|
|
|
$this->pool->getPropertyAccessor()->willReturn($propertyAccessor); |
|
|
|
|
|
|
110
|
|
|
$this->twig->addExtension(new SonataAdminExtension( |
|
111
|
|
|
$pool->reveal(), |
|
112
|
|
|
null, |
|
113
|
|
|
$translator->reveal(), |
|
114
|
|
|
$container->reveal() |
|
115
|
|
|
)); |
|
116
|
|
|
$fieldDescription->getOption('editable')->willReturn(true); |
|
117
|
|
|
$fieldDescription->getAdmin()->willReturn($this->admin->reveal()); |
|
|
|
|
|
|
118
|
|
|
$fieldDescription->getType()->willReturn('boolean'); |
|
119
|
|
|
$fieldDescription->getTemplate()->willReturn('field_template'); |
|
120
|
|
|
$fieldDescription->getValue(Argument::cetera())->willReturn('some value'); |
|
121
|
|
|
|
|
122
|
|
|
$this->validator->validate($object)->willReturn(new ConstraintViolationList([])); |
|
|
|
|
|
|
123
|
|
|
|
|
124
|
|
|
$response = ($this->action)($request); |
|
125
|
|
|
|
|
126
|
|
|
$this->assertSame(Response::HTTP_OK, $response->getStatusCode()); |
|
127
|
|
|
} |
|
128
|
|
|
|
|
129
|
|
|
public function getTimeZones(): array |
|
130
|
|
|
{ |
|
131
|
|
|
return [ |
|
132
|
|
|
[null], |
|
133
|
|
|
[false], |
|
134
|
|
|
[\date_default_timezone_get()], |
|
135
|
|
|
[new \DateTimeZone(\date_default_timezone_get())], |
|
136
|
|
|
['Europe/Rome'], |
|
137
|
|
|
[new \DateTimeZone('Europe/Rome')], |
|
138
|
|
|
]; |
|
139
|
|
|
} |
|
140
|
|
|
|
|
141
|
|
|
/** |
|
142
|
|
|
* @dataProvider getTimeZones |
|
143
|
|
|
*/ |
|
144
|
|
|
public function testSetObjectFieldValueActionWithDate($timezone): void |
|
145
|
|
|
{ |
|
146
|
|
|
$object = new Bafoo(); |
|
147
|
|
|
$request = new Request([ |
|
148
|
|
|
'code' => 'sonata.post.admin', |
|
149
|
|
|
'objectId' => 42, |
|
150
|
|
|
'field' => 'dateProp', |
|
151
|
|
|
'value' => '2020-12-12', |
|
152
|
|
|
'context' => 'list', |
|
153
|
|
|
], [], [], [], [], ['REQUEST_METHOD' => Request::METHOD_POST, 'HTTP_X_REQUESTED_WITH' => 'XMLHttpRequest']); |
|
154
|
|
|
|
|
155
|
|
|
$fieldDescription = $this->prophesize(FieldDescriptionInterface::class); |
|
156
|
|
|
$pool = $this->prophesize(Pool::class); |
|
157
|
|
|
$translator = $this->prophesize(TranslatorInterface::class); |
|
158
|
|
|
$propertyAccessor = new PropertyAccessor(); |
|
159
|
|
|
$templateRegistry = $this->prophesize(TemplateRegistryInterface::class); |
|
160
|
|
|
$container = $this->prophesize(ContainerInterface::class); |
|
161
|
|
|
|
|
162
|
|
|
$this->admin->getObject(42)->willReturn($object); |
|
163
|
|
|
$this->admin->getCode()->willReturn('sonata.post.admin'); |
|
|
|
|
|
|
164
|
|
|
$this->admin->hasAccess('edit', $object)->willReturn(true); |
|
|
|
|
|
|
165
|
|
|
$this->admin->getListFieldDescription('dateProp')->willReturn($fieldDescription->reveal()); |
|
|
|
|
|
|
166
|
|
|
$this->admin->update($object)->shouldBeCalled(); |
|
167
|
|
|
|
|
168
|
|
|
$this->admin->getTemplate('base_list_field')->willReturn('admin_template'); |
|
|
|
|
|
|
169
|
|
|
$templateRegistry->getTemplate('base_list_field')->willReturn('admin_template'); |
|
170
|
|
|
$container->get('sonata.post.admin.template_registry')->willReturn($templateRegistry->reveal()); |
|
171
|
|
|
$this->pool->getPropertyAccessor()->willReturn($propertyAccessor); |
|
|
|
|
|
|
172
|
|
|
$this->twig->addExtension(new SonataAdminExtension( |
|
173
|
|
|
$pool->reveal(), |
|
174
|
|
|
null, |
|
175
|
|
|
$translator->reveal(), |
|
176
|
|
|
$container->reveal() |
|
177
|
|
|
)); |
|
178
|
|
|
$fieldDescription->getOption('editable')->willReturn(true); |
|
179
|
|
|
$fieldDescription->getOption('timezone')->willReturn($timezone); |
|
180
|
|
|
$fieldDescription->getAdmin()->willReturn($this->admin->reveal()); |
|
|
|
|
|
|
181
|
|
|
$fieldDescription->getType()->willReturn('date'); |
|
182
|
|
|
$fieldDescription->getTemplate()->willReturn('field_template'); |
|
183
|
|
|
$fieldDescription->getValue(Argument::cetera())->willReturn('some value'); |
|
184
|
|
|
|
|
185
|
|
|
$this->validator->validate($object)->willReturn(new ConstraintViolationList([])); |
|
|
|
|
|
|
186
|
|
|
|
|
187
|
|
|
$response = ($this->action)($request); |
|
188
|
|
|
|
|
189
|
|
|
$this->assertSame(Response::HTTP_OK, $response->getStatusCode()); |
|
190
|
|
|
} |
|
191
|
|
|
|
|
192
|
|
|
/** |
|
193
|
|
|
* @dataProvider getTimeZones |
|
194
|
|
|
*/ |
|
195
|
|
|
public function testSetObjectFieldValueActionWithDateTime($timezone): void |
|
196
|
|
|
{ |
|
197
|
|
|
$object = new Bafoo(); |
|
198
|
|
|
$request = new Request([ |
|
199
|
|
|
'code' => 'sonata.post.admin', |
|
200
|
|
|
'objectId' => 42, |
|
201
|
|
|
'field' => 'datetimeProp', |
|
202
|
|
|
'value' => '2020-12-12 23:11:23', |
|
203
|
|
|
'context' => 'list', |
|
204
|
|
|
], [], [], [], [], ['REQUEST_METHOD' => Request::METHOD_POST, 'HTTP_X_REQUESTED_WITH' => 'XMLHttpRequest']); |
|
205
|
|
|
|
|
206
|
|
|
$fieldDescription = $this->prophesize(FieldDescriptionInterface::class); |
|
207
|
|
|
$pool = $this->prophesize(Pool::class); |
|
208
|
|
|
$translator = $this->prophesize(TranslatorInterface::class); |
|
209
|
|
|
$propertyAccessor = new PropertyAccessor(); |
|
210
|
|
|
$templateRegistry = $this->prophesize(TemplateRegistryInterface::class); |
|
211
|
|
|
$container = $this->prophesize(ContainerInterface::class); |
|
212
|
|
|
|
|
213
|
|
|
$this->admin->getObject(42)->willReturn($object); |
|
214
|
|
|
$this->admin->getCode()->willReturn('sonata.post.admin'); |
|
|
|
|
|
|
215
|
|
|
$this->admin->hasAccess('edit', $object)->willReturn(true); |
|
|
|
|
|
|
216
|
|
|
$this->admin->getListFieldDescription('datetimeProp')->willReturn($fieldDescription->reveal()); |
|
|
|
|
|
|
217
|
|
|
$this->admin->update($object)->shouldBeCalled(); |
|
218
|
|
|
|
|
219
|
|
|
$this->admin->getTemplate('base_list_field')->willReturn('admin_template'); |
|
|
|
|
|
|
220
|
|
|
$templateRegistry->getTemplate('base_list_field')->willReturn('admin_template'); |
|
221
|
|
|
$container->get('sonata.post.admin.template_registry')->willReturn($templateRegistry->reveal()); |
|
222
|
|
|
$this->pool->getPropertyAccessor()->willReturn($propertyAccessor); |
|
|
|
|
|
|
223
|
|
|
$this->twig->addExtension(new SonataAdminExtension( |
|
224
|
|
|
$pool->reveal(), |
|
225
|
|
|
null, |
|
226
|
|
|
$translator->reveal(), |
|
227
|
|
|
$container->reveal() |
|
228
|
|
|
)); |
|
229
|
|
|
$fieldDescription->getOption('editable')->willReturn(true); |
|
230
|
|
|
$fieldDescription->getOption('timezone')->willReturn($timezone); |
|
231
|
|
|
$fieldDescription->getAdmin()->willReturn($this->admin->reveal()); |
|
|
|
|
|
|
232
|
|
|
$fieldDescription->getType()->willReturn('datetime'); |
|
233
|
|
|
$fieldDescription->getTemplate()->willReturn('field_template'); |
|
234
|
|
|
$fieldDescription->getValue(Argument::cetera())->willReturn('some value'); |
|
235
|
|
|
|
|
236
|
|
|
$this->validator->validate($object)->willReturn(new ConstraintViolationList([])); |
|
|
|
|
|
|
237
|
|
|
|
|
238
|
|
|
$response = ($this->action)($request); |
|
239
|
|
|
|
|
240
|
|
|
$this->assertSame(Response::HTTP_OK, $response->getStatusCode()); |
|
241
|
|
|
} |
|
242
|
|
|
|
|
243
|
|
|
public function testSetObjectFieldValueActionOnARelationField(): void |
|
244
|
|
|
{ |
|
245
|
|
|
$object = new Baz(); |
|
246
|
|
|
$associationObject = new Bar(); |
|
247
|
|
|
$request = new Request([ |
|
248
|
|
|
'code' => 'sonata.post.admin', |
|
249
|
|
|
'objectId' => 42, |
|
250
|
|
|
'field' => 'bar', |
|
251
|
|
|
'value' => 1, |
|
252
|
|
|
'context' => 'list', |
|
253
|
|
|
], [], [], [], [], ['REQUEST_METHOD' => Request::METHOD_POST, 'HTTP_X_REQUESTED_WITH' => 'XMLHttpRequest']); |
|
254
|
|
|
|
|
255
|
|
|
$fieldDescription = $this->prophesize(FieldDescriptionInterface::class); |
|
256
|
|
|
$modelManager = $this->prophesize(ModelManagerInterface::class); |
|
257
|
|
|
$translator = $this->prophesize(TranslatorInterface::class); |
|
258
|
|
|
$propertyAccessor = new PropertyAccessor(); |
|
259
|
|
|
$templateRegistry = $this->prophesize(TemplateRegistryInterface::class); |
|
260
|
|
|
$container = $this->prophesize(ContainerInterface::class); |
|
261
|
|
|
|
|
262
|
|
|
$this->admin->getObject(42)->willReturn($object); |
|
263
|
|
|
$this->admin->getCode()->willReturn('sonata.post.admin'); |
|
|
|
|
|
|
264
|
|
|
$this->admin->hasAccess('edit', $object)->willReturn(true); |
|
|
|
|
|
|
265
|
|
|
$this->admin->getListFieldDescription('bar')->willReturn($fieldDescription->reveal()); |
|
|
|
|
|
|
266
|
|
|
$this->admin->getClass()->willReturn(\get_class($object)); |
|
|
|
|
|
|
267
|
|
|
$this->admin->update($object)->shouldBeCalled(); |
|
268
|
|
|
$container->get('sonata.post.admin.template_registry')->willReturn($templateRegistry->reveal()); |
|
269
|
|
|
// NEXT_MAJOR: Remove this line |
|
270
|
|
|
$this->admin->getTemplate('base_list_field')->willReturn('admin_template'); |
|
|
|
|
|
|
271
|
|
|
$templateRegistry->getTemplate('base_list_field')->willReturn('admin_template'); |
|
272
|
|
|
$this->admin->getModelManager()->willReturn($modelManager->reveal()); |
|
|
|
|
|
|
273
|
|
|
$this->twig->addExtension(new SonataAdminExtension( |
|
274
|
|
|
$this->pool->reveal(), |
|
|
|
|
|
|
275
|
|
|
null, |
|
276
|
|
|
$translator->reveal(), |
|
277
|
|
|
$container->reveal() |
|
278
|
|
|
)); |
|
279
|
|
|
$this->pool->getPropertyAccessor()->willReturn($propertyAccessor); |
|
|
|
|
|
|
280
|
|
|
$fieldDescription->getType()->willReturn('choice'); |
|
281
|
|
|
$fieldDescription->getOption('editable')->willReturn(true); |
|
282
|
|
|
$fieldDescription->getOption('class')->willReturn(Bar::class); |
|
283
|
|
|
$fieldDescription->getTargetEntity()->willReturn(Bar::class); |
|
284
|
|
|
$fieldDescription->getAdmin()->willReturn($this->admin->reveal()); |
|
|
|
|
|
|
285
|
|
|
$fieldDescription->getTemplate()->willReturn('field_template'); |
|
286
|
|
|
$fieldDescription->getValue(Argument::cetera())->willReturn('some value'); |
|
287
|
|
|
$modelManager->find(\get_class($associationObject), 1)->willReturn($associationObject); |
|
288
|
|
|
|
|
289
|
|
|
$this->validator->validate($object)->willReturn(new ConstraintViolationList([])); |
|
|
|
|
|
|
290
|
|
|
|
|
291
|
|
|
$response = ($this->action)($request); |
|
292
|
|
|
|
|
293
|
|
|
$this->assertSame(Response::HTTP_OK, $response->getStatusCode()); |
|
294
|
|
|
} |
|
295
|
|
|
|
|
296
|
|
|
public function testSetObjectFieldValueActionWithViolations(): void |
|
297
|
|
|
{ |
|
298
|
|
|
$bar = new Bar(); |
|
299
|
|
|
$object = new Baz(); |
|
300
|
|
|
$object->setBar($bar); |
|
301
|
|
|
$request = new Request([ |
|
302
|
|
|
'code' => 'sonata.post.admin', |
|
303
|
|
|
'objectId' => 42, |
|
304
|
|
|
'field' => 'bar.enabled', |
|
305
|
|
|
'value' => 1, |
|
306
|
|
|
'context' => 'list', |
|
307
|
|
|
], [], [], [], [], ['REQUEST_METHOD' => Request::METHOD_POST, 'HTTP_X_REQUESTED_WITH' => 'XMLHttpRequest']); |
|
308
|
|
|
|
|
309
|
|
|
$fieldDescription = $this->prophesize(FieldDescriptionInterface::class); |
|
310
|
|
|
$propertyAccessor = new PropertyAccessor(); |
|
311
|
|
|
|
|
312
|
|
|
$this->pool->getPropertyAccessor()->willReturn($propertyAccessor); |
|
|
|
|
|
|
313
|
|
|
$this->admin->getObject(42)->willReturn($object); |
|
314
|
|
|
$this->admin->hasAccess('edit', $object)->willReturn(true); |
|
|
|
|
|
|
315
|
|
|
$this->admin->getListFieldDescription('bar.enabled')->willReturn($fieldDescription->reveal()); |
|
|
|
|
|
|
316
|
|
|
$this->validator->validate($bar)->willReturn(new ConstraintViolationList([ |
|
|
|
|
|
|
317
|
|
|
new ConstraintViolation('error1', null, [], null, 'enabled', null), |
|
318
|
|
|
new ConstraintViolation('error2', null, [], null, 'enabled', null), |
|
319
|
|
|
])); |
|
320
|
|
|
$fieldDescription->getOption('editable')->willReturn(true); |
|
321
|
|
|
$fieldDescription->getType()->willReturn('boolean'); |
|
322
|
|
|
|
|
323
|
|
|
$response = ($this->action)($request); |
|
324
|
|
|
|
|
325
|
|
|
$this->assertSame(Response::HTTP_BAD_REQUEST, $response->getStatusCode()); |
|
326
|
|
|
$this->assertSame(json_encode("error1\nerror2"), $response->getContent()); |
|
327
|
|
|
} |
|
328
|
|
|
|
|
329
|
|
|
public function testSetObjectFieldEditableMultipleValue(): void |
|
330
|
|
|
{ |
|
331
|
|
|
$object = new StatusMultiple(); |
|
332
|
|
|
$request = new Request([ |
|
333
|
|
|
'code' => 'sonata.post.admin', |
|
334
|
|
|
'objectId' => 42, |
|
335
|
|
|
'field' => 'status', |
|
336
|
|
|
'value' => [1, 2], |
|
337
|
|
|
'context' => 'list', |
|
338
|
|
|
], [], [], [], [], ['REQUEST_METHOD' => Request::METHOD_POST, 'HTTP_X_REQUESTED_WITH' => 'XMLHttpRequest']); |
|
339
|
|
|
|
|
340
|
|
|
$fieldDescription = $this->prophesize(FieldDescriptionInterface::class); |
|
341
|
|
|
$pool = $this->prophesize(Pool::class); |
|
342
|
|
|
$template = $this->prophesize(Template::class); |
|
|
|
|
|
|
343
|
|
|
$translator = $this->prophesize(TranslatorInterface::class); |
|
344
|
|
|
$propertyAccessor = new PropertyAccessor(); |
|
345
|
|
|
$templateRegistry = $this->prophesize(TemplateRegistryInterface::class); |
|
346
|
|
|
$container = $this->prophesize(ContainerInterface::class); |
|
347
|
|
|
|
|
348
|
|
|
$this->admin->getObject(42)->willReturn($object); |
|
349
|
|
|
$this->admin->getCode()->willReturn('sonata.post.admin'); |
|
|
|
|
|
|
350
|
|
|
$this->admin->hasAccess('edit', $object)->willReturn(true); |
|
|
|
|
|
|
351
|
|
|
$this->admin->getListFieldDescription('status')->willReturn($fieldDescription->reveal()); |
|
|
|
|
|
|
352
|
|
|
$this->admin->update($object)->shouldBeCalled(); |
|
353
|
|
|
// NEXT_MAJOR: Remove this line |
|
354
|
|
|
$this->admin->getTemplate('base_list_field')->willReturn('admin_template'); |
|
|
|
|
|
|
355
|
|
|
$templateRegistry->getTemplate('base_list_field')->willReturn('admin_template'); |
|
356
|
|
|
$container->get('sonata.post.admin.template_registry')->willReturn($templateRegistry->reveal()); |
|
357
|
|
|
$this->pool->getPropertyAccessor()->willReturn($propertyAccessor); |
|
|
|
|
|
|
358
|
|
|
$this->twig->addExtension(new SonataAdminExtension( |
|
359
|
|
|
$pool->reveal(), |
|
360
|
|
|
null, |
|
361
|
|
|
$translator->reveal(), |
|
362
|
|
|
$container->reveal() |
|
363
|
|
|
)); |
|
364
|
|
|
$fieldDescription->getOption('editable')->willReturn(true); |
|
365
|
|
|
$fieldDescription->getOption('multiple')->willReturn(true); |
|
366
|
|
|
$fieldDescription->getAdmin()->willReturn($this->admin->reveal()); |
|
|
|
|
|
|
367
|
|
|
$fieldDescription->getType()->willReturn('boolean'); |
|
368
|
|
|
$fieldDescription->getTemplate()->willReturn('field_template'); |
|
369
|
|
|
$fieldDescription->getValue(Argument::cetera())->willReturn(['some value']); |
|
370
|
|
|
|
|
371
|
|
|
$this->validator->validate($object)->willReturn(new ConstraintViolationList([])); |
|
|
|
|
|
|
372
|
|
|
|
|
373
|
|
|
$response = ($this->action)($request); |
|
374
|
|
|
|
|
375
|
|
|
$this->assertSame(Response::HTTP_OK, $response->getStatusCode()); |
|
376
|
|
|
} |
|
377
|
|
|
} |
|
378
|
|
|
|
Our type inference engine has found an assignment to a property that is incompatible with the declared type of that property.
Either this assignment is in error or the assigned type should be added to the documentation/type hint for that property..