Test Failed
Push — master ( 1b7368...050678 )
by Fran
25:16 queued 22:49
created

TemplateTest   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 46
Duplicated Lines 0 %

Importance

Changes 0
Metric Value
eloc 31
dl 0
loc 46
rs 10
c 0
b 0
f 0
wmc 2
1
<?php
2
namespace PSFS\tests\base;
3
4
use PHPUnit\Framework\TestCase;
5
use PSFS\base\config\Config;
6
use PSFS\base\Template;
7
8
/**
9
 * Class TemplateTest
10
 * @package PSFS\tests
11
 */
12
class TemplateTest extends TestCase {
13
14
    public function testTemplateBasics() {
15
        $template = Template::getInstance();
16
17
        // Check if the template engine is ok
18
        $engine = $template->getTemplateEngine();
19
        $this->assertNotNull($engine, 'Error at Template creation');
20
        $this->assertInstanceOf('\\Twig\\Environment', $engine);
21
22
        // Check if the template loader is ok
23
        $loader = $template->getLoader();
24
        $this->assertNotNull($loader, 'Error at Template creation');
25
        $this->assertInstanceOf('\\Twig\\Loader\\LoaderInterface', $loader);
26
27
        $domains = Template::getDomains(true);
28
        $this->assertNotNull($domains);
29
30
        $path = Template::extractPath(__DIR__);
31
        $this->assertNotNull($path);
32
        $this->assertFileExists($path);
33
34
        Config::getInstance()->setDebugMode(true);
35
        $output = $template->dump('index.html.twig');
36
        $this->assertNotNull($output);
37
        $this->assertNotEmpty($output);
38
39
        Config::getInstance()->setDebugMode(false);
40
        $output2 = $template->dump('index.html.twig');
41
        $this->assertNotNull($output2);
42
        $this->assertNotEmpty($output2);
43
        $this->assertNotEquals($output2, $output, 'Production template is the same than development one');
44
        Config::getInstance()->setDebugMode(true);
45
    }
46
47
    public function testTranslations() {
48
        $template = Template::getInstance();
49
50
        $template->setPublicZone(true);
51
        $this->assertTrue($template->isPublicZone());
52
        $template->setPublicZone(false);
53
        $this->assertFalse($template->isPublicZone());
54
55
        $translations = $template->regenerateTemplates();
56
        $this->assertNotNull($translations);
57
        $this->assertNotEmpty($translations);
58
    }
59
}
60