File tree 2 files changed +58
-0
lines changed
2 files changed +58
-0
lines changed Original file line number Diff line number Diff line change 3
3
namespace Pixelfear \ViewDebug ;
4
4
5
5
use Illuminate \Contracts \View \Engine ;
6
+ use Illuminate \Support \Traits \ForwardsCalls ;
6
7
7
8
class DebugEngine implements Engine
8
9
{
10
+ use ForwardsCalls;
11
+
9
12
protected $ engine ;
10
13
11
14
public function __construct ($ engine )
@@ -21,4 +24,9 @@ public function get($path, $data = [])
21
24
$ path
22
25
]);
23
26
}
27
+
28
+ public function __call ($ method , $ parameters )
29
+ {
30
+ return $ this ->forwardDecoratedCallTo ($ this ->engine , $ method , $ parameters );
31
+ }
24
32
}
Original file line number Diff line number Diff line change
1
+ <?php
2
+
3
+ namespace Tests ;
4
+
5
+ use BadMethodCallException ;
6
+ use Illuminate \Contracts \View \Engine ;
7
+ use Mockery ;
8
+ use Pixelfear \ViewDebug \DebugEngine ;
9
+
10
+ class DebugEngineTest extends TestCase
11
+ {
12
+ /** @test */
13
+ public function it_forwards_calls_to_engine ()
14
+ {
15
+ $ mock = Mockery::mock (Engine::class);
16
+ $ mock ->shouldReceive ('foo ' )->with ('bar ' )->andReturn ('baz ' );
17
+
18
+ $ engine = new DebugEngine ($ mock );
19
+
20
+ $ this ->assertEquals ('baz ' , $ engine ->foo ('bar ' ));
21
+ }
22
+
23
+ /** @test */
24
+ public function it_forwards_calls_to_engine_and_allows_fluency ()
25
+ {
26
+ $ mock = Mockery::mock (Engine::class);
27
+ $ mock ->shouldReceive ('foo ' )->with ('bar ' )->andReturnSelf ();
28
+
29
+ $ engine = new DebugEngine ($ mock );
30
+
31
+ $ this ->assertSame ($ engine , $ engine ->foo ('bar ' ));
32
+ }
33
+
34
+ /** @test */
35
+ public function it_throw_bad_method_call_exception ()
36
+ {
37
+ $ this ->expectException (BadMethodCallException::class);
38
+ $ this ->expectExceptionMessage ('Call to undefined method Pixelfear \\ViewDebug \\DebugEngine::foo() ' );
39
+
40
+ $ mock = Mockery::mock (Engine::class);
41
+ $ mock ->shouldReceive ('foo ' )->with ('bar ' )->andThrow (
42
+ BadMethodCallException::class,
43
+ 'Call to undefined method ' .get_class ($ mock ).'::foo() '
44
+ );
45
+
46
+ $ engine = new DebugEngine ($ mock );
47
+
48
+ $ engine ->foo ('bar ' );
49
+ }
50
+ }
You can’t perform that action at this time.
0 commit comments