Completed
Pull Request — 3.x (#6220)
by Vincent
03:15
created

testDefaultSettings()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 14

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 14
rs 9.7998
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\Block;
15
16
use Sonata\AdminBundle\Admin\Pool;
17
use Sonata\AdminBundle\Block\AdminListBlockService;
18
use Sonata\AdminBundle\Templating\TemplateRegistryInterface;
19
use Sonata\AdminBundle\Tests\Fixtures\Block\FakeBlockService;
20
use Sonata\BlockBundle\Test\BlockServiceTestCase;
21
use Twig\Environment;
22
23
/**
24
 * NEXT_MAJOR: Remove this class.
25
 *
26
 * @group legacy
27
 *
28
 * @author Sullivan Senechal <[email protected]>
29
 */
30
class DeprecatedAdminListBlockServiceTest extends BlockServiceTestCase
31
{
32
    /**
33
     * @var Pool
34
     */
35
    private $pool;
36
37
    /**
38
     * @var TemplateRegistryInterface
39
     */
40
    private $templateRegistry;
41
42
    protected function setUp(): void
43
    {
44
        parent::setUp();
45
46
        $this->pool = $this->createMock(Pool::class);
47
48
        $this->templateRegistry = $this->prophesize(TemplateRegistryInterface::class);
49
    }
50
51
    /**
52
     * @expectedDeprecation Passing null as argument 2 to Sonata\AdminBundle\Block\AdminListBlockService::__construct() is deprecated since sonata-project/admin-bundle 3.x and will throw a \TypeError in version 4.0. You must pass an instance of Sonata\AdminBundle\Admin\Pool instead.
53
     */
54
    public function testDefaultSettings(): void
55
    {
56
        $blockService = new AdminListBlockService(
57
            $this->createMock(Environment::class),
58
            null,
59
            $this->pool,
60
            $this->templateRegistry->reveal()
0 ignored issues
show
Bug introduced by
The method reveal() does not seem to exist on object<Sonata\AdminBundl...plateRegistryInterface>.

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...
61
        );
62
        $blockContext = $this->getBlockContext($blockService);
63
64
        $this->assertSettings([
65
            'groups' => false,
66
        ], $blockContext);
67
    }
68
69
    /**
70
     * @expectedDeprecation Passing null as argument 2 to Sonata\AdminBundle\Block\AdminListBlockService::__construct() is deprecated since sonata-project/admin-bundle 3.x and will throw a \TypeError in version 4.0. You must pass an instance of Sonata\AdminBundle\Admin\Pool instead.
71
     */
72
    public function testOverriddenDefaultSettings(): void
73
    {
74
        $blockService = new FakeBlockService(
75
            $this->createMock(Environment::class),
76
            null,
77
            $this->pool,
78
            $this->templateRegistry->reveal()
0 ignored issues
show
Bug introduced by
The method reveal() does not seem to exist on object<Sonata\AdminBundl...plateRegistryInterface>.

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...
79
        );
80
        $blockContext = $this->getBlockContext($blockService);
81
82
        $this->assertSettings([
83
            'foo' => 'bar',
84
            'groups' => true,
85
        ], $blockContext);
86
    }
87
}
88