forked from laravel/framework
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathViewCompilerEngineTest.php
More file actions
executable file
·43 lines (31 loc) · 1.33 KB
/
ViewCompilerEngineTest.php
File metadata and controls
executable file
·43 lines (31 loc) · 1.33 KB
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
<?php
use Mockery as m;
use Illuminate\View\Engines\CompilerEngine;
class ViewCompilerEngineTest extends PHPUnit_Framework_TestCase {
public function tearDown()
{
m::close();
}
public function testViewsMayBeRecompiledAndRendered()
{
$engine = $this->getEngine();
$engine->getCompiler()->shouldReceive('getCompiledPath')->with(__DIR__.'/fixtures/foo.php')->andReturn(__DIR__.'/fixtures/basic.php');
$engine->getCompiler()->shouldReceive('isExpired')->once()->with(__DIR__.'/fixtures/foo.php')->andReturn(true);
$engine->getCompiler()->shouldReceive('compile')->once()->with(__DIR__.'/fixtures/foo.php');;
$results = $engine->get(__DIR__.'/fixtures/foo.php');
$this->assertEquals('Hello World'.PHP_EOL, $results);
}
public function testViewsAreNotRecompiledIfTheyAreNotExpired()
{
$engine = $this->getEngine();
$engine->getCompiler()->shouldReceive('getCompiledPath')->with(__DIR__.'/fixtures/foo.php')->andReturn(__DIR__.'/fixtures/basic.php');
$engine->getCompiler()->shouldReceive('isExpired')->once()->andReturn(false);
$engine->getCompiler()->shouldReceive('compile')->never();
$results = $engine->get(__DIR__.'/fixtures/foo.php');
$this->assertEquals('Hello World'.PHP_EOL, $results);
}
protected function getEngine()
{
return new CompilerEngine(m::mock('Illuminate\View\Compilers\CompilerInterface'));
}
}