| @@ 23-46 (lines=24) @@ | ||
| 20 | ||
| 21 | class HomepageControllerTest extends TestCase |
|
| 22 | { |
|
| 23 | public function testInvoke(): void |
|
| 24 | { |
|
| 25 | $slidingPagination = new SlidingPagination([]); |
|
| 26 | $slidingPagination->setItemNumberPerPage(10); |
|
| 27 | $slidingPagination->setCurrentPageNumber(1); |
|
| 28 | /** @var Environment|MockObject $twig */ |
|
| 29 | $twig = $this->createMock(Environment::class); |
|
| 30 | $twig |
|
| 31 | ->expects($this->once()) |
|
| 32 | ->method('render') |
|
| 33 | ->with('@HarentiusBlog/Blog/index.html.twig', [ |
|
| 34 | 'page' => null, |
|
| 35 | 'articles' => $slidingPagination, |
|
| 36 | 'hasToPaginate' => false, |
|
| 37 | 'noIndex' => false, |
|
| 38 | ]) |
|
| 39 | ; |
|
| 40 | $homepageController = $this->createHomepageController($twig, $slidingPagination); |
|
| 41 | ||
| 42 | $request = new Request(); |
|
| 43 | $response = $homepageController($request); |
|
| 44 | ||
| 45 | $this->assertInstanceOf(Response::class, $response); |
|
| 46 | } |
|
| 47 | ||
| 48 | private function createHomepageController(Environment $twig, SlidingPagination $slidingPagination): HomepageController |
|
| 49 | { |
|
| @@ 22-44 (lines=23) @@ | ||
| 19 | ||
| 20 | class TagControllerTest extends TestCase |
|
| 21 | { |
|
| 22 | public function testInvoke(): void |
|
| 23 | { |
|
| 24 | $slidingPagination = new SlidingPagination([]); |
|
| 25 | $slidingPagination->setItemNumberPerPage(10); |
|
| 26 | $tag = new Tag(); |
|
| 27 | $twig = $this->createMock(Environment::class); |
|
| 28 | $twig |
|
| 29 | ->expects($this->once()) |
|
| 30 | ->method('render') |
|
| 31 | ->with('@HarentiusBlog/Blog/list.html.twig', [ |
|
| 32 | 'articles' => $slidingPagination, |
|
| 33 | 'parent' => $tag, |
|
| 34 | 'noIndex' => true, |
|
| 35 | 'hasToPaginate' => false, |
|
| 36 | ]) |
|
| 37 | ; |
|
| 38 | $tagController = $this->createTagController($twig, $slidingPagination); |
|
| 39 | $request = new Request(); |
|
| 40 | ||
| 41 | $response = $tagController($request, $tag); |
|
| 42 | ||
| 43 | $this->assertInstanceOf(Response::class, $response); |
|
| 44 | } |
|
| 45 | ||
| 46 | private function createTagController(Environment $twig, SlidingPagination $slidingPagination): TagController |
|
| 47 | { |
|