create(['level' => LogLevel::ALERT, 'message' => 'Alert test']); $alert = $log->find($alert)->first(); $error = $log->create(['level' => LogLevel::ERROR, 'message' => 'Error test']); $error = $log->find($error)->first(); $response = $this->createMock(Response::class); $response->expects($this->exactly(2)) ->method('withView') ->withConsecutive( ['admin/log.twig', ['entries' => new Collection([$error, $alert]), 'search' => null]], ['admin/log.twig', ['entries' => new Collection([$error]), 'search' => 'error']] ) ->willReturn($response); $request = Request::create('/'); $controller = new LogsController($log, $response); $controller->index($request); $request->request->set('search', 'error'); $controller->index($request); } /** * Setup the DB */ public function setUp(): void { parent::setUp(); $this->initDatabase(); } }