Completed
Push — 3.x ( 799626...732596 )
by Grégoire
04:11
created

TemplateRegistryTest::testGetTemplates()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 13
Code Lines 8

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 13
rs 9.4285
c 0
b 0
f 0
cc 1
eloc 8
nc 1
nop 0
1
<?php
2
3
/*
4
 * This file is part of the Sonata Project package.
5
 *
6
 * (c) Thomas Rabaix <[email protected]>
7
 *
8
 * For the full copyright and license information, please view the LICENSE
9
 * file that was distributed with this source code.
10
 */
11
12
namespace Sonata\AdminBundle\Tests\Templating;
13
14
use PHPUnit\Framework\TestCase;
15
use Sonata\AdminBundle\Templating\TemplateRegistry;
16
17
class TemplateRegistryTest extends TestCase
18
{
19
    /**
20
     * @var TemplateRegistry
21
     */
22
    private $templateRegistry;
23
24
    protected function setUp()
25
    {
26
        $this->templateRegistry = new TemplateRegistry();
27
    }
28
29
    public function testGetTemplates()
30
    {
31
        $this->assertSame([], $this->templateRegistry->getTemplates());
32
33
        $templates = [
34
            'list' => '@FooAdmin/CRUD/list.html.twig',
35
            'show' => '@FooAdmin/CRUD/show.html.twig',
36
            'edit' => '@FooAdmin/CRUD/edit.html.twig',
37
        ];
38
39
        $this->templateRegistry->setTemplates($templates);
40
        $this->assertSame($templates, $this->templateRegistry->getTemplates());
41
    }
42
43
    public function testGetTemplate1()
44
    {
45
        $this->assertNull($this->templateRegistry->getTemplate('edit'));
46
47
        $this->templateRegistry->setTemplate('edit', '@FooAdmin/CRUD/edit.html.twig');
48
        $this->templateRegistry->setTemplate('show', '@FooAdmin/CRUD/show.html.twig');
49
50
        $this->assertSame('@FooAdmin/CRUD/edit.html.twig', $this->templateRegistry->getTemplate('edit'));
51
        $this->assertSame('@FooAdmin/CRUD/show.html.twig', $this->templateRegistry->getTemplate('show'));
52
    }
53
54
    public function testGetTemplate2()
55
    {
56
        $this->assertNull($this->templateRegistry->getTemplate('edit'));
57
58
        $templates = [
59
            'list' => '@FooAdmin/CRUD/list.html.twig',
60
            'show' => '@FooAdmin/CRUD/show.html.twig',
61
            'edit' => '@FooAdmin/CRUD/edit.html.twig',
62
        ];
63
64
        $this->templateRegistry->setTemplates($templates);
65
66
        $this->assertSame('@FooAdmin/CRUD/edit.html.twig', $this->templateRegistry->getTemplate('edit'));
67
        $this->assertSame('@FooAdmin/CRUD/show.html.twig', $this->templateRegistry->getTemplate('show'));
68
    }
69
}
70