summaryrefslogtreecommitdiff
path: root/tests/UnitTests/TemplateSource/ValueTests/SmartySpecialVars/Now/SmartyNowTest.php
blob: 32116a7c1eaac4b4e4791a72180fecadf0366f55 (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
45
46
47
48
49
50
<?php
/**
 * Smarty PHPunit tests {$smarty.now}
 *

 * @author  Uwe Tews
 */

/**
 * class for {$smarty.now} tests
 *
 * 
 * 
 *
 */
class SmartyNowTest extends PHPUnit_Smarty
{
    public function setUp(): void
    {
        $this->setUpSmarty(__DIR__);
    }

    public function testInit()
    {
        $this->cleanDirs();
    }
    /**
     * test {$smarty.now}
     *
     */
    public function testSmartyNow() {
        $result = $this->smarty->fetch('now.tpl');
        $this->assertTrue(is_numeric($result));
        $this->assertTrue((time() - $result) <= 1);
    }
    /**
     * test {$smarty.now nocache}
     * @group slow
     */
    public function testSmartyNowNocache() {
        $this->smarty->setCaching(true);
        $result = $this->smarty->fetch('now_nocache.tpl');
        $this->assertTrue(is_numeric($result));
        $this->assertTrue((time() - $result) <= 1);
        sleep(2);
        $result2 = $this->smarty->fetch('now_nocache.tpl');
        $this->assertTrue(is_numeric($result2));
        $this->assertTrue((time() - $result2) <= 1);
    }
}