|
0
|
1 |
<?php |
|
|
2 |
|
|
|
3 |
/* |
|
|
4 |
* This file is part of the Assetic package, an OpenSky project. |
|
|
5 |
* |
|
|
6 |
* (c) 2010-2011 OpenSky Project Inc |
|
|
7 |
* |
|
|
8 |
* For the full copyright and license information, please view the LICENSE |
|
|
9 |
* file that was distributed with this source code. |
|
|
10 |
*/ |
|
|
11 |
|
|
|
12 |
namespace Assetic\Test\Extension\Twig; |
|
|
13 |
|
|
|
14 |
use Assetic\Extension\Twig\TwigResource; |
|
|
15 |
|
|
|
16 |
class TwigResourceTest extends \PHPUnit_Framework_TestCase |
|
|
17 |
{ |
|
|
18 |
protected function setUp() |
|
|
19 |
{ |
|
|
20 |
if (!class_exists('Twig_Environment')) { |
|
|
21 |
$this->markTestSkipped('Twig is not installed.'); |
|
|
22 |
} |
|
|
23 |
} |
|
|
24 |
|
|
|
25 |
public function testInvalidTemplateNameGetContent() |
|
|
26 |
{ |
|
|
27 |
$loader = $this->getMock('Twig_LoaderInterface'); |
|
|
28 |
$loader->expects($this->once()) |
|
|
29 |
->method('getSource') |
|
|
30 |
->with('asdf') |
|
|
31 |
->will($this->throwException(new \Twig_Error_Loader(''))); |
|
|
32 |
|
|
|
33 |
$resource = new TwigResource($loader, 'asdf'); |
|
|
34 |
$this->assertEquals('', $resource->getContent()); |
|
|
35 |
} |
|
|
36 |
|
|
|
37 |
public function testInvalidTemplateNameIsFresh() |
|
|
38 |
{ |
|
|
39 |
$loader = $this->getMock('Twig_LoaderInterface'); |
|
|
40 |
$loader->expects($this->once()) |
|
|
41 |
->method('isFresh') |
|
|
42 |
->with('asdf', 1234) |
|
|
43 |
->will($this->throwException(new \Twig_Error_Loader(''))); |
|
|
44 |
|
|
|
45 |
$resource = new TwigResource($loader, 'asdf'); |
|
|
46 |
$this->assertFalse($resource->isFresh(1234)); |
|
|
47 |
} |
|
|
48 |
} |