SIGN IN SIGN UP
laravel / framework UNCLAIMED

Laravel is a web application framework with expressive, elegant syntax.

0 0 2 PHP
2013-01-10 15:28:59 -06:00
<?php
use Mockery as m;
use Illuminate\View\Engines\CompilerEngine;
class ViewCompilerEngineTest extends PHPUnit_Framework_TestCase {
2013-01-10 15:28:59 -06:00
public function tearDown()
{
m::close();
}
2013-01-10 15:28:59 -06: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
$this->assertEquals("Hello World
", $results);
}
2013-01-10 15:28:59 -06: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
$this->assertEquals("Hello World
", $results);
}
2013-01-10 15:28:59 -06: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
}