2013-01-10 15:28:59 -06:00
|
|
|
<?php
|
|
|
|
|
|
|
|
|
|
use Mockery as m;
|
|
|
|
|
use Illuminate\View\Engines\CompilerEngine;
|
|
|
|
|
|
2013-01-17 11:14:13 -06:00
|
|
|
class ViewCompilerEngineTest extends PHPUnit_Framework_TestCase {
|
2013-01-10 15:28:59 -06:00
|
|
|
|
2015-06-01 15:56:31 +01:00
|
|
|
public function tearDown()
|
|
|
|
|
{
|
|
|
|
|
m::close();
|
|
|
|
|
}
|
2013-01-10 15:28:59 -06:00
|
|
|
|
|
|
|
|
|
2015-06-01 15:56:31 +01:00
|
|
|
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');
|
2013-01-10 15:28:59 -06:00
|
|
|
|
2015-06-01 15:56:31 +01:00
|
|
|
$this->assertEquals("Hello World
|
2015-05-19 23:08:45 +02:00
|
|
|
", $results);
|
2015-06-01 15:56:31 +01:00
|
|
|
}
|
2013-01-10 15:28:59 -06:00
|
|
|
|
|
|
|
|
|
2015-06-01 15:56:31 +01:00
|
|
|
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');
|
2013-01-10 15:28:59 -06:00
|
|
|
|
2015-06-01 15:56:31 +01:00
|
|
|
$this->assertEquals("Hello World
|
2015-05-19 23:08:45 +02:00
|
|
|
", $results);
|
2015-06-01 15:56:31 +01:00
|
|
|
}
|
2013-01-10 15:28:59 -06:00
|
|
|
|
|
|
|
|
|
2015-06-01 15:56:31 +01:00
|
|
|
protected function getEngine()
|
|
|
|
|
{
|
|
|
|
|
return new CompilerEngine(m::mock('Illuminate\View\Compilers\CompilerInterface'));
|
|
|
|
|
}
|
2013-01-10 15:28:59 -06:00
|
|
|
|
2014-02-27 19:30:59 +00:00
|
|
|
}
|