@@ -27,6 +27,37 @@ public function testSupportsRetrievesEngineFromTheContainer()
27
27
$ this ->assertTrue ($ delegatingEngine ->supports ('template.php ' ));
28
28
}
29
29
30
+ public function testGetExistingEngine ()
31
+ {
32
+ $ firstEngine = $ this ->getEngineMock ('template.php ' , false );
33
+ $ secondEngine = $ this ->getEngineMock ('template.php ' , true );
34
+ $ container = $ this ->getContainerMock (array (
35
+ 'engine.first ' => $ firstEngine ,
36
+ 'engine.second ' => $ secondEngine
37
+ ));
38
+
39
+ $ delegatingEngine = new DelegatingEngine ($ container , array ('engine.first ' , 'engine.second ' ));
40
+
41
+ $ this ->assertSame ($ secondEngine , $ delegatingEngine ->getEngine ('template.php ' , array ('foo ' => 'bar ' )));
42
+ }
43
+
44
+ /**
45
+ * @expectedException \RuntimeException
46
+ * @expectedExceptionMessage No engine is able to work with the template "template.php"
47
+ */
48
+ public function testGetInvalidEngine ()
49
+ {
50
+ $ firstEngine = $ this ->getEngineMock ('template.php ' , false );
51
+ $ secondEngine = $ this ->getEngineMock ('template.php ' , false );
52
+ $ container = $ this ->getContainerMock (array (
53
+ 'engine.first ' => $ firstEngine ,
54
+ 'engine.second ' => $ secondEngine
55
+ ));
56
+
57
+ $ delegatingEngine = new DelegatingEngine ($ container , array ('engine.first ' , 'engine.second ' ));
58
+ $ delegatingEngine ->getEngine ('template.php ' , array ('foo ' => 'bar ' ));
59
+ }
60
+
30
61
public function testRenderResponse ()
31
62
{
32
63
$ response = $ this ->getMock ('Symfony\Component\HttpFoundation\Response ' );
0 commit comments