Completed
Push — master ( c56c3c...fbb14f )
by Grégoire
16s queued 11s
created

getRootMenuItemWithDifferentUrlTypes()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 40

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 40
rs 9.28
c 0
b 0
f 0
cc 1
nc 1
nop 0
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\Menu\Provider;
15
16
use Knp\Menu\FactoryInterface;
17
use Knp\Menu\Integration\Symfony\RoutingExtension;
18
use Knp\Menu\ItemInterface;
19
use Knp\Menu\MenuFactory;
20
use Knp\Menu\MenuItem;
21
use Knp\Menu\Provider\MenuProviderInterface;
22
use PHPUnit\Framework\MockObject\MockObject;
23
use PHPUnit\Framework\TestCase;
24
use Sonata\AdminBundle\Admin\AbstractAdmin;
25
use Sonata\AdminBundle\Admin\Pool;
26
use Sonata\AdminBundle\Menu\Provider\GroupMenuProvider;
27
use Symfony\Component\Routing\Generator\UrlGeneratorInterface;
28
use Symfony\Component\Security\Core\Authorization\AuthorizationCheckerInterface;
29
30
class GroupMenuProviderTest extends TestCase
31
{
32
    /**
33
     * @var MockObject|Pool
34
     */
35
    private $pool;
36
    /**
37
     * @var MockObject|MenuProviderInterface
38
     */
39
    private $provider;
40
    /**
41
     * @var MockObject|FactoryInterface
42
     */
43
    private $factory;
44
45
    /**
46
     * @var MockObject
47
     */
48
    private $checker;
49
50
    protected function setUp(): void
51
    {
52
        $this->pool = $this->getMockBuilder(Pool::class)->disableOriginalConstructor()->getMock();
53
        $this->checker = $this
54
            ->getMockBuilder(AuthorizationCheckerInterface::class)
55
            ->setMethods(['isGranted'])
56
            ->disableOriginalConstructor()
57
            ->getMock();
58
59
        $this->factory = new MenuFactory();
60
61
        $urlGenerator = $this->createStub(UrlGeneratorInterface::class);
62
        $urlGenerator->method('generate')->willReturnCallback(static function (string $name, array $parameters = [], int $referenceType = UrlGeneratorInterface::ABSOLUTE_PATH): string {
63
            switch ($referenceType) {
64
                case UrlGeneratorInterface::ABSOLUTE_URL:
65
                    return 'http://sonata-project/'.$name.($parameters ? '?'.http_build_query($parameters) : '');
66
                case UrlGeneratorInterface::ABSOLUTE_PATH:
67
                    return '/'.$name.($parameters ? '?'.http_build_query($parameters) : '');
68
                default:
69
                    throw new \InvalidArgumentException(sprintf('Dummy router does not support the reference type "%s".', $referenceType));
70
            }
71
        });
72
73
        $this->factory->addExtension(new RoutingExtension($urlGenerator));
74
75
        $this->provider = new GroupMenuProvider($this->factory, $this->pool, $this->checker);
76
    }
77
78
    public function testGroupMenuProviderName(): void
79
    {
80
        $this->assertTrue($this->provider->has('sonata_group_menu'));
81
    }
82
83
    /**
84
     * @dataProvider getAdminGroups
85
     */
86
    public function testGetMenuProviderWithCheckerGrantedGroupRoles(array $adminGroups): void
87
    {
88
        $this->pool
0 ignored issues
show
Bug introduced by
The method method() does not seem to exist on object<Sonata\AdminBundle\Admin\Pool>.

This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces.

This is most likely a typographical error or the method has been renamed.

Loading history...
89
            ->method('getInstance')
90
            ->with($this->equalTo('sonata_admin_foo_service'))
91
            ->willReturn($this->getAdminMock());
92
93
        $this->checker
94
            ->method('isGranted')
95
            ->willReturn(false);
96
97
        $menu = $this->provider->get(
98
            'providerFoo',
99
            [
100
                'name' => 'foo',
101
                'group' => $adminGroups,
102
            ]
103
        );
104
105
        $this->assertInstanceOf(ItemInterface::class, $menu);
106
        $this->assertSame('foo', $menu->getName());
107
108
        $children = $menu->getChildren();
109
110
        $this->assertCount(1, $children);
111
        $this->assertArrayHasKey('foo_admin_label', $children);
112
        $this->assertArrayNotHasKey('route_label', $children);
113
        $this->assertInstanceOf(MenuItem::class, $menu['foo_admin_label']);
114
        $this->assertSame('foo_admin_label', $menu['foo_admin_label']->getLabel());
115
116
        $extras = $menu['foo_admin_label']->getExtras();
117
        $this->assertArrayHasKey('label_catalogue', $extras);
118
        $this->assertSame($extras['label_catalogue'], 'SonataAdminBundle');
119
    }
120
121
    public function unanimousGrantCheckerMock(string $role): bool
122
    {
123
        return \in_array($role, ['foo', 'bar', 'baz'], true);
124
    }
125
126
    public function unanimousGrantCheckerNoBazMock(string $role): bool
127
    {
128
        return \in_array($role, ['foo', 'bar'], true);
129
    }
130
131
    /**
132
     * @dataProvider getAdminGroupsMultipleRoles
133
     */
134
    public function testGetMenuProviderWithCheckerGrantedMultipleGroupRoles(
135
        array $adminGroups
136
    ): void {
137
        $this->checker
138
            ->method('isGranted')
139
            ->willReturnCallback([$this, 'unanimousGrantCheckerMock']);
140
141
        $menu = $this->provider->get(
142
            'providerFoo',
143
            [
144
                'name' => 'foo',
145
                'group' => $adminGroups,
146
            ]
147
        );
148
149
        $this->assertInstanceOf(ItemInterface::class, $menu);
150
151
        $children = $menu->getChildren();
152
153
        $this->assertCount(4, $children);
154
    }
155
156
    /**
157
     * @dataProvider getAdminGroupsMultipleRoles
158
     */
159
    public function testGetMenuProviderWithCheckerGrantedGroupAndItemRoles(
160
        array $adminGroups
161
    ): void {
162
        $this->checker
163
            ->method('isGranted')
164
            ->willReturnCallback([$this, 'unanimousGrantCheckerNoBazMock']);
165
166
        $menu = $this->provider->get(
167
            'providerFoo',
168
            [
169
                'name' => 'foo',
170
                'group' => $adminGroups,
171
            ]
172
        );
173
        $isBazItem = $adminGroups['roles'] === ['baz'];
174
175
        $this->assertInstanceOf(ItemInterface::class, $menu);
176
        $this->assertSame(!$isBazItem, $menu->isDisplayed());
177
178
        $children = $menu->getChildren();
179
        $this->assertCount($isBazItem ? 0 : 3, $children);
180
    }
181
182
    /**
183
     * @dataProvider getAdminGroupsMultipleRolesOnTop
184
     */
185
    public function testGetMenuProviderWithCheckerGrantedMultipleGroupRolesOnTop(
186
        array $adminGroups
187
    ): void {
188
        $this->checker
189
            ->method('isGranted')
190
            ->willReturnCallback([$this, 'unanimousGrantCheckerMock']);
191
192
        $menu = $this->provider->get(
193
            'providerFoo',
194
            [
195
                'name' => 'foo',
196
                'group' => $adminGroups,
197
            ]
198
        );
199
        $this->assertInstanceOf(ItemInterface::class, $menu);
200
201
        $this->assertTrue($menu->isDisplayed());
202
    }
203
204
    /**
205
     * @dataProvider getAdminGroups
206
     */
207
    public function testGetMenuProviderWithAdmin(array $adminGroups): void
208
    {
209
        $this->pool
0 ignored issues
show
Bug introduced by
The method method() does not seem to exist on object<Sonata\AdminBundle\Admin\Pool>.

This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces.

This is most likely a typographical error or the method has been renamed.

Loading history...
210
            ->method('getInstance')
211
            ->with($this->equalTo('sonata_admin_foo_service'))
212
            ->willReturn($this->getAdminMock());
213
214
        $this->checker
215
            ->method('isGranted')
216
            ->willReturn(true);
217
218
        $menu = $this->provider->get(
219
            'providerFoo',
220
            [
221
                'name' => 'foo',
222
                'group' => $adminGroups,
223
            ]
224
        );
225
226
        $this->assertInstanceOf(ItemInterface::class, $menu);
227
        $this->assertSame('foo', $menu->getName());
228
229
        $children = $menu->getChildren();
230
231
        $this->assertCount(3, $children);
232
        $this->assertArrayHasKey('foo_admin_label', $children);
233
        $this->assertArrayHasKey('route_label', $children);
234
        $this->assertInstanceOf(MenuItem::class, $menu['foo_admin_label']);
235
        $this->assertSame('foo_admin_label', $menu['foo_admin_label']->getLabel());
236
237
        $extras = $menu['foo_admin_label']->getExtras();
238
        $this->assertArrayHasKey('label_catalogue', $extras);
239
        $this->assertSame('SonataAdminBundle', $extras['label_catalogue']);
240
241
        $extras = $menu['route_label']->getExtras();
242
        $this->assertArrayHasKey('label_catalogue', $extras);
243
        $this->assertSame('SonataAdminBundle', $extras['label_catalogue']);
244
245
        $this->assertSame('http://sonata-project/FooRoute?foo=bar', $menu['route_label']->getUri());
246
        $this->assertSame('/FooRelativeRoute?baz=qux', $menu['relative_route']->getUri());
247
    }
248
249
    /**
250
     * @dataProvider getAdminGroups
251
     */
252
    public function testGetKnpMenuWithListRoute(array $adminGroups): void
253
    {
254
        $this->pool
0 ignored issues
show
Bug introduced by
The method method() does not seem to exist on object<Sonata\AdminBundle\Admin\Pool>.

This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces.

This is most likely a typographical error or the method has been renamed.

Loading history...
255
            ->method('getInstance')
256
            ->with($this->equalTo('sonata_admin_foo_service'))
257
            ->willReturn($this->getAdminMock(false));
258
259
        $this->checker
260
            ->method('isGranted')
261
            ->willReturn(true);
262
263
        $menu = $this->provider->get(
264
            'providerFoo',
265
            [
266
                'name' => 'foo',
267
                'group' => $adminGroups,
268
            ]
269
        );
270
271
        $this->assertInstanceOf(ItemInterface::class, $menu);
272
        $this->assertArrayNotHasKey('foo_admin_label', $menu->getChildren());
273
        $this->assertArrayHasKey('route_label', $menu->getChildren());
274
        $this->assertCount(2, $menu->getChildren());
275
    }
276
277
    /**
278
     * @dataProvider getAdminGroups
279
     */
280
    public function testGetKnpMenuWithGrantedList(array $adminGroups): void
281
    {
282
        $this->pool
0 ignored issues
show
Bug introduced by
The method method() does not seem to exist on object<Sonata\AdminBundle\Admin\Pool>.

This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces.

This is most likely a typographical error or the method has been renamed.

Loading history...
283
            ->method('getInstance')
284
            ->with($this->equalTo('sonata_admin_foo_service'))
285
            ->willReturn($this->getAdminMock(true, false));
286
287
        $this->checker
288
            ->method('isGranted')
289
            ->willReturn(true);
290
291
        $menu = $this->provider->get(
292
            'providerFoo',
293
            [
294
                'name' => 'foo',
295
                'group' => $adminGroups,
296
            ]
297
        );
298
299
        $this->assertInstanceOf(ItemInterface::class, $menu);
300
        $this->assertArrayNotHasKey('foo_admin_label', $menu->getChildren());
301
        $this->assertArrayHasKey('route_label', $menu->getChildren());
302
        $this->assertCount(2, $menu->getChildren());
303
    }
304
305
    /**
306
     * @dataProvider getAdminGroupsWithOnTopOption
307
     */
308
    public function testGetMenuProviderOnTopOptions(array $adminGroupsOnTopOption): void
309
    {
310
        $this->pool
0 ignored issues
show
Bug introduced by
The method method() does not seem to exist on object<Sonata\AdminBundle\Admin\Pool>.

This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces.

This is most likely a typographical error or the method has been renamed.

Loading history...
311
            ->method('getInstance')
312
            ->with($this->equalTo('sonata_admin_foo_service'))
313
            ->willReturn($this->getAdminMock(true, false));
314
315
        $menu = $this->provider->get(
316
            'providerFoo',
317
            [
318
                'name' => 'foo',
319
                'group' => $adminGroupsOnTopOption,
320
            ]
321
        );
322
323
        $this->assertInstanceOf(ItemInterface::class, $menu);
324
        $this->assertCount(0, $menu->getChildren());
325
    }
326
327
    /**
328
     * @dataProvider getAdminGroups
329
     */
330
    public function testGetMenuProviderKeepOpenOption(array $adminGroups): void
331
    {
332
        $this->pool
0 ignored issues
show
Bug introduced by
The method method() does not seem to exist on object<Sonata\AdminBundle\Admin\Pool>.

This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces.

This is most likely a typographical error or the method has been renamed.

Loading history...
333
            ->method('getInstance')
334
            ->with($this->equalTo('sonata_admin_foo_service'))
335
            ->willReturn($this->getAdminMock());
336
337
        $this->checker
338
            ->method('isGranted')
339
            ->willReturn(true);
340
341
        $adminGroups['keep_open'] = true;
342
343
        $menu = $this->provider->get(
344
            'providerFoo',
345
            [
346
                'name' => 'foo',
347
                'group' => $adminGroups,
348
            ]
349
        );
350
351
        $this->assertInstanceOf(ItemInterface::class, $menu);
352
        $this->assertSame('keep-open', $menu->getAttribute('class'));
353
        $this->assertTrue($menu->getExtra('keep_open'));
354
    }
355
356
    /**
357
     * @dataProvider getRootMenuItemWithDifferentUrlTypes
358
     */
359
    public function testRootMenuItemUrl(string $expectedUrl, array $item): void
360
    {
361
        $this->pool
0 ignored issues
show
Bug introduced by
The method method() does not seem to exist on object<Sonata\AdminBundle\Admin\Pool>.

This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces.

This is most likely a typographical error or the method has been renamed.

Loading history...
362
            ->method('getInstance')
363
            ->with($this->equalTo('sonata_admin_absolute_url'))
364
            ->willReturn($this->getAdminMock());
365
366
        $this->checker
367
            ->method('isGranted')
368
            ->willReturn(true);
369
370
        $menu = $this->provider->get(
371
            'providerFoo',
372
            [
373
                'name' => 'foo',
374
                'group' => $item,
375
            ]
376
        );
377
378
        $this->assertInstanceOf(ItemInterface::class, $menu);
379
        $this->assertSame('foo', $menu->getName());
380
        $this->assertSame($expectedUrl, $menu['foo_admin_label']->getUri());
381
    }
382
383
    public function getAdminGroups(): array
384
    {
385
        return [
386
            [
387
                'bar' => [
388
                    'label' => 'foo',
389
                    'icon' => '<i class="fa fa-edit"></i>',
390
                    'label_catalogue' => 'SonataAdminBundle',
391
                    'items' => [
392
                        [
393
                            'admin' => 'sonata_admin_foo_service',
394
                            'label' => 'fooLabel',
395
                            'route' => 'FooServiceRoute',
396
                            'route_absolute' => true,
397
                        ],
398
                        [
399
                            'admin' => '',
400
                            'label' => 'route_label',
401
                            'route' => 'FooRoute',
402
                            'route_params' => ['foo' => 'bar'],
403
                            'route_absolute' => true,
404
                            'roles' => [],
405
                        ],
406
                        [
407
                            'admin' => '',
408
                            'label' => 'relative_route',
409
                            'route' => 'FooRelativeRoute',
410
                            'route_params' => ['baz' => 'qux'],
411
                            'route_absolute' => false,
412
                            'roles' => [],
413
                        ],
414
                    ],
415
                    'item_adds' => [],
416
                    'roles' => ['foo'],
417
                ],
418
            ],
419
        ];
420
    }
421
422
    public function getAdminGroupsMultipleRoles(): array
423
    {
424
        return [
425
            [
426
                // group for all roles, children with different roles
427
                [
428
                    'label' => 'foo',
429
                    'icon' => '<i class="fa fa-edit"></i>',
430
                    'label_catalogue' => 'SonataAdminBundle',
431
                    'items' => [
432
                        [
433
                            'admin' => '',
434
                            'label' => 'route_label1',
435
                            'route' => 'FooRoute1',
436
                            'route_params' => ['foo' => 'bar'],
437
                            'route_absolute' => true,
438
                            'roles' => ['foo', 'bar'],
439
                        ],
440
                        [
441
                            'admin' => '',
442
                            'label' => 'route_label2',
443
                            'route' => 'FooRoute2',
444
                            'route_params' => ['foo' => 'bar'],
445
                            'route_absolute' => true,
446
                            'roles' => ['foo'],
447
                        ],
448
                        [
449
                            'admin' => '',
450
                            'label' => 'route_label3',
451
                            'route' => 'FooRoute3',
452
                            'route_params' => ['foo' => 'bar'],
453
                            'route_absolute' => true,
454
                            'roles' => ['bar'],
455
                        ],
456
                        [
457
                            'admin' => '',
458
                            'label' => 'route_label4',
459
                            'route' => 'FooRoute4',
460
                            'route_params' => ['foo' => 'bar'],
461
                            'route_absolute' => true,
462
                            'roles' => ['baz'],
463
                        ],
464
                    ],
465
                    'roles' => ['foo', 'bar'],
466
                    'item_adds' => [],
467
                ],
468
            ], [
469
                // group for one role, children with different roles
470
                [
471
                    'label' => 'foo',
472
                    'icon' => '<i class="fa fa-edit"></i>',
473
                    'label_catalogue' => 'SonataAdminBundle',
474
                    'items' => [
475
                        [
476
                            'admin' => '',
477
                            'label' => 'route_label1',
478
                            'route' => 'FooRoute1',
479
                            'route_params' => ['foo' => 'bar'],
480
                            'route_absolute' => true,
481
                            'roles' => ['foo', 'bar'],
482
                        ],
483
                        [
484
                            'admin' => '',
485
                            'label' => 'route_label2',
486
                            'route' => 'FooRoute2',
487
                            'route_params' => ['foo' => 'bar'],
488
                            'route_absolute' => true,
489
                            'roles' => ['foo'],
490
                        ],
491
                        [
492
                            'admin' => '',
493
                            'label' => 'route_label3',
494
                            'route' => 'FooRoute3',
495
                            'route_params' => ['foo' => 'bar'],
496
                            'route_absolute' => true,
497
                            'roles' => ['bar'],
498
                        ],
499
                        [
500
                            'admin' => '',
501
                            'label' => 'route_label4',
502
                            'route' => 'FooRoute4',
503
                            'route_params' => ['foo' => 'bar'],
504
                            'route_absolute' => true,
505
                            'roles' => ['baz'],
506
                        ],
507
                    ],
508
                    'roles' => ['baz'],
509
                    'item_adds' => [],
510
                ],
511
            ],
512
        ];
513
    }
514
515
    public function getAdminGroupsMultipleRolesOnTop(): array
516
    {
517
        return [
518
            [
519
                [
520
                    'label' => 'foo1',
521
                    'icon' => '<i class="fa fa-edit"></i>',
522
                    'label_catalogue' => 'SonataAdminBundle',
523
                    'items' => [
524
                        [
525
                            'admin' => '',
526
                            'label' => 'route_label1',
527
                            'route' => 'FooRoute1',
528
                            'route_params' => ['foo' => 'bar'],
529
                            'route_absolute' => true,
530
                        ],
531
                    ],
532
                    'item_adds' => [],
533
                    'roles' => ['foo', 'bar'],
534
                    'on_top' => true,
535
                ],
536
            ], [
537
                [
538
                    'label' => 'foo2',
539
                    'icon' => '<i class="fa fa-edit"></i>',
540
                    'label_catalogue' => 'SonataAdminBundle',
541
                    'items' => [
542
                        [
543
                            'admin' => '',
544
                            'label' => 'route_label2',
545
                            'route' => 'FooRoute2',
546
                            'route_params' => ['foo' => 'bar'],
547
                            'route_absolute' => true,
548
                        ],
549
                    ],
550
                    'item_adds' => [],
551
                    'roles' => ['foo'],
552
                    'on_top' => true,
553
                ],
554
            ], [
555
                [
556
                    'label' => 'foo3',
557
                    'icon' => '<i class="fa fa-edit"></i>',
558
                    'label_catalogue' => 'SonataAdminBundle',
559
                    'items' => [
560
                        [
561
                            'admin' => '',
562
                            'label' => 'route_label3',
563
                            'route' => 'FooRoute3',
564
                            'route_params' => ['foo' => 'bar'],
565
                            'route_absolute' => true,
566
                        ],
567
                    ],
568
                    'item_adds' => [],
569
                    'roles' => ['bar'],
570
                    'on_top' => true,
571
                ],
572
            ],
573
        ];
574
    }
575
576
    public function getAdminGroupsWithOnTopOption(): array
577
    {
578
        return [
579
            [
580
                'foo' => [
581
                    'label' => 'foo_on_top',
582
                    'icon' => '<i class="fa fa-edit"></i>',
583
                    'label_catalogue' => 'SonataAdminBundle',
584
                    'on_top' => true,
585
                    'items' => [
586
                        [
587
                            'admin' => 'sonata_admin_foo_service',
588
                            'label' => 'fooLabel',
589
                            'route_absolute' => true,
590
                            'route_params' => [],
591
                        ],
592
                    ],
593
                    'item_adds' => [],
594
                    'roles' => [],
595
                ],
596
            ],
597
        ];
598
    }
599
600
    public function getRootMenuItemWithDifferentUrlTypes(): iterable
601
    {
602
        yield 'absolute_url' => [
603
            'http://sonata-project/list',
604
            [
605
                'label' => 'foo',
606
                'icon' => '<i class="fa fa-edit"></i>',
607
                'label_catalogue' => 'SonataAdminBundle',
608
                'items' => [
609
                    [
610
                        'admin' => 'sonata_admin_absolute_url',
611
                        'label' => 'fooLabel',
612
                        'route' => 'FooAbsoulteRoute',
613
                        'route_absolute' => true,
614
                    ],
615
                ],
616
                'item_adds' => [],
617
                'roles' => ['foo'],
618
            ],
619
        ];
620
621
        yield 'absolute_path' => [
622
            '/list',
623
            [
624
                'label' => 'foo',
625
                'icon' => '<i class="fa fa-edit"></i>',
626
                'label_catalogue' => 'SonataAdminBundle',
627
                'items' => [
628
                    [
629
                        'admin' => 'sonata_admin_absolute_url',
630
                        'label' => 'fooLabel',
631
                        'route' => 'FooAbsolutePath',
632
                        'route_absolute' => false,
633
                    ],
634
                ],
635
                'item_adds' => [],
636
                'roles' => ['foo'],
637
            ],
638
        ];
639
    }
640
641
    private function getAdminMock(bool $hasRoute = true, bool $isGranted = true): AbstractAdmin
642
    {
643
        $admin = $this->createMock(AbstractAdmin::class);
644
        $admin->expects($this->once())
645
            ->method('hasRoute')
646
            ->with($this->equalTo('list'))
647
            ->willReturn($hasRoute);
648
649
        $admin
650
            ->method('hasAccess')
651
            ->with($this->equalTo('list'))
652
            ->willReturn($isGranted);
653
654
        $admin
655
            ->method('getLabel')
656
            ->willReturn('foo_admin_label');
657
658
        $admin
659
            ->method('generateMenuUrl')
660
            ->willReturnCallback(static function (string $name, array $parameters = [], int $referenceType = UrlGeneratorInterface::ABSOLUTE_PATH): array {
661
                if (!\in_array($referenceType, [UrlGeneratorInterface::ABSOLUTE_URL, UrlGeneratorInterface::ABSOLUTE_PATH], true)) {
662
                    throw new \InvalidArgumentException(sprintf('Dummy router does not support the reference type "%s".', $referenceType));
663
                }
664
665
                return [
666
                    'route' => $name,
667
                    'routeParameters' => $parameters,
668
                    'routeAbsolute' => UrlGeneratorInterface::ABSOLUTE_URL === $referenceType,
669
                ];
670
            });
671
672
        $admin
673
            ->method('getTranslationDomain')
674
            ->willReturn('SonataAdminBundle');
675
676
        return $admin;
677
    }
678
}
679