@@ 44-74 (lines=31) @@ | ||
41 | /** |
|
42 | * @test |
|
43 | */ |
|
44 | public function shouldRenderTemplate() |
|
45 | { |
|
46 | /** @var Request $request */ |
|
47 | $request = $this->createMock(Request::class); |
|
48 | ||
49 | /** @var Response $expectedResponse */ |
|
50 | $expectedResponse = $this->createMock(Response::class); |
|
51 | ||
52 | $this->argumentCompiler->expects($this->once())->method('buildArguments')->with( |
|
53 | $this->equalTo(['foo' => 'bar']) |
|
54 | )->willReturn([ |
|
55 | 'bar' => 'baz' |
|
56 | ]); |
|
57 | ||
58 | $this->controllerHelper->expects($this->once())->method('renderTemplate')->with( |
|
59 | $this->equalTo("@foo/bar/baz.html"), |
|
60 | $this->equalTo(['bar' => 'baz']) |
|
61 | )->willReturn($expectedResponse); |
|
62 | ||
63 | $controller = new GenericTemplateRenderController($this->controllerHelper, $this->argumentCompiler, [ |
|
64 | 'template' => "@foo/bar/baz.html", |
|
65 | 'arguments' => [ |
|
66 | 'foo' => 'bar' |
|
67 | ] |
|
68 | ]); |
|
69 | ||
70 | /** @var Response $actualResponse */ |
|
71 | $actualResponse = $controller->renderTemplate($request); |
|
72 | ||
73 | $this->assertSame($expectedResponse, $actualResponse); |
|
74 | } |
|
75 | ||
76 | /** |
|
77 | * @test |
|
@@ 134-166 (lines=33) @@ | ||
131 | /** |
|
132 | * @test |
|
133 | */ |
|
134 | public function shouldBeCallableByInvokingController() |
|
135 | { |
|
136 | /** @var Request $request */ |
|
137 | $request = $this->createMock(Request::class); |
|
138 | ||
139 | /** @var Response $expectedResponse */ |
|
140 | $expectedResponse = $this->createMock(Response::class); |
|
141 | ||
142 | $this->argumentCompiler->expects($this->once())->method('buildArguments')->with( |
|
143 | $this->equalTo(['foo' => 'bar']) |
|
144 | )->willReturn([ |
|
145 | 'bar' => 'baz' |
|
146 | ]); |
|
147 | ||
148 | $this->controllerHelper->expects($this->once())->method('renderTemplate')->with( |
|
149 | $this->equalTo("@foo/bar/baz.html"), |
|
150 | $this->equalTo(['bar' => 'baz']) |
|
151 | )->willReturn($expectedResponse); |
|
152 | ||
153 | $controller = new GenericTemplateRenderController($this->controllerHelper, $this->argumentCompiler, [ |
|
154 | 'template' => "@foo/bar/baz.html", |
|
155 | 'arguments' => [ |
|
156 | 'foo' => 'bar' |
|
157 | ] |
|
158 | ]); |
|
159 | ||
160 | $this->controllerHelper->method('getCurrentRequest')->willReturn($request); |
|
161 | ||
162 | /** @var Response $actualResponse */ |
|
163 | $actualResponse = $controller(); |
|
164 | ||
165 | $this->assertSame($expectedResponse, $actualResponse); |
|
166 | } |
|
167 | ||
168 | /** |
|
169 | * @test |