aboutsummaryrefslogtreecommitdiff
path: root/tests/unit/lib/flexi/TemplateEmptyTest.php
blob: c5ebd79e4a7954179fb6f730752af5f3d320a995 (plain)
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
<?php

use Flexi\Factory;
use Flexi\Template;

final class TemplateEmptyTestCase extends \Codeception\Test\Unit
{
    private Factory $factory;

    public function setUp(): void
    {
        $this->factory = $this->make(Factory::class, [
            'open' => $this->make(Template::class),
        ]);
    }

    public function tearDown(): void
    {
        unset($this->factory);
    }

    public function testShouldHaveNoAttributes()
    {
        $template = $this->factory->open('');
        $this->assertCount(0, $template->get_attributes());
    }

    public function testShouldNotBeEmptyAfterSettingAnAttribute()
    {
        $template = $this->factory->open('');
        $template->set_attribute('foo', 'bar');
        $this->assertNotEmpty($template->get_attributes());
    }

    public function testShouldBeEmptyAfterClear()
    {
        $template = $this->factory->open('foo');

        $this->assertEmpty($template->get_attributes());

        $template->clear_attributes();
        $this->assertEmpty($template->get_attributes());
    }
}