-
-
Notifications
You must be signed in to change notification settings - Fork 111
Expand file tree
/
Copy pathAdminTest.php
More file actions
79 lines (65 loc) · 2.47 KB
/
AdminTest.php
File metadata and controls
79 lines (65 loc) · 2.47 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
<?php
declare(strict_types=1);
/*
* This file is part of the Sonata Project package.
*
* (c) Thomas Rabaix <thomas.rabaix@sonata-project.org>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
namespace Sonata\ClassificationBundle\Tests\Admin;
use PHPUnit\Framework\TestCase;
use Sonata\AdminBundle\Admin\AbstractAdmin;
use Sonata\AdminBundle\Admin\AdminExtensionInterface;
use Sonata\ClassificationBundle\Admin\ContextAdmin;
use Sonata\ClassificationBundle\Admin\ContextAwareAdmin;
use Sonata\ClassificationBundle\Model\ContextAwareInterface;
use Sonata\ClassificationBundle\Model\ContextManagerInterface;
final class AdminTest extends TestCase
{
private ContextManagerInterface $contextManager;
protected function setUp(): void
{
$this->contextManager = $this->createMock(ContextManagerInterface::class);
}
public function testAbstractAdminChildren(): void
{
$contextAwareAdmin = $this->createMock(ContextAwareAdmin::class);
static::assertInstanceOf(AbstractAdmin::class, $contextAwareAdmin);
$contextAdmin = new ContextAdmin();
static::assertInstanceOf(AbstractAdmin::class, $contextAdmin);
}
public function testGetPersistentParametersWithNoExtension(): void
{
$expected = [
'context' => '',
'hide_context' => 0,
];
$admin = new
/** @phpstan-extends ContextAwareAdmin<ContextAwareInterface> */
class($this->contextManager) extends ContextAwareAdmin {};
static::assertSame($expected, $admin->getPersistentParameters());
}
public function testGetPersistentParametersWithValidExtension(): void
{
$admin = new
/** @phpstan-extends ContextAwareAdmin<ContextAwareInterface> */
class($this->contextManager) extends ContextAwareAdmin {
public function __construct(ContextManagerInterface $contextManager)
{
parent::__construct($contextManager);
}
};
$extension = $this->createMock(AdminExtensionInterface::class);
$extension->expects(static::once())->method('configurePersistentParameters')->with(
static::anything(),
[
'context' => '',
'hide_context' => 0,
],
)->willReturn([]);
$admin->addExtension($extension);
$admin->getPersistentParameters();
}
}