| @@ 17-34 (lines=18) @@ | ||
| 14 | ||
| 15 | class RateControllerTest extends TestCase |
|
| 16 | { |
|
| 17 | public function testInvoke(): void |
|
| 18 | { |
|
| 19 | $rating = $this->createMock(Rating::class); |
|
| 20 | $rating |
|
| 21 | ->method('rate') |
|
| 22 | ->willReturn(new Response()) |
|
| 23 | ; |
|
| 24 | $entityManager = $this->createMock(EntityManagerInterface::class); |
|
| 25 | $entityManager |
|
| 26 | ->expects($this->once()) |
|
| 27 | ->method('flush') |
|
| 28 | ; |
|
| 29 | $article = new Article(); |
|
| 30 | ||
| 31 | $rateController = $this->createRateController($rating, $entityManager); |
|
| 32 | $response = $rateController($article); |
|
| 33 | $this->assertInstanceOf(Response::class, $response); |
|
| 34 | } |
|
| 35 | ||
| 36 | public function testInvokeWithException(): void |
|
| 37 | { |
|
| @@ 16-35 (lines=20) @@ | ||
| 13 | ||
| 14 | class ViewCountControllerTest extends TestCase |
|
| 15 | { |
|
| 16 | public function testInvoke(): void |
|
| 17 | { |
|
| 18 | $article = new Article(); |
|
| 19 | $viewsCounter = $this->createMock(ViewsCounter::class); |
|
| 20 | $viewsCounter |
|
| 21 | ->expects($this->once()) |
|
| 22 | ->method('processArticle') |
|
| 23 | ->with($article) |
|
| 24 | ; |
|
| 25 | $entityManager = $this->createMock(EntityManagerInterface::class); |
|
| 26 | $entityManager |
|
| 27 | ->expects($this->once()) |
|
| 28 | ->method('flush') |
|
| 29 | ; |
|
| 30 | $viewCountController = new ViewCountController($viewsCounter, $entityManager); |
|
| 31 | ||
| 32 | $response = $viewCountController($article); |
|
| 33 | ||
| 34 | $this->assertInstanceOf(JsonResponse::class, $response); |
|
| 35 | } |
|
| 36 | } |
|
| 37 | ||