From a50fa6fd5ad612260146eeb2531990829f948549 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Elan=20Ruusam=C3=A4e?= Date: Tue, 22 Dec 2020 23:41:52 +0200 Subject: [PATCH] RunController::index: Use render() method --- src/Controller/RunController.php | 5 ++--- src/ServiceProvider/RouteProvider.php | 2 +- tests/Controller/RunTest.php | 8 ++++---- 3 files changed, 7 insertions(+), 8 deletions(-) diff --git a/src/Controller/RunController.php b/src/Controller/RunController.php index 60d87a1b8..154ad3279 100644 --- a/src/Controller/RunController.php +++ b/src/Controller/RunController.php @@ -71,14 +71,13 @@ public function index(Request $request, Response $response) 'direction' => $result['direction'], ]; - $this->_template = 'runs/list.twig'; - $this->set([ + $this->render('runs/list.twig', [ 'paging' => $paging, 'base_url' => 'home', 'runs' => $result['results'], 'date_format' => $this->config('date.format'), 'search' => $search, - 'has_search' => strlen(implode('', $search)) > 0, + 'has_search' => implode('', $search) !== '', 'title' => $title, ]); } diff --git a/src/ServiceProvider/RouteProvider.php b/src/ServiceProvider/RouteProvider.php index 75f96499d..6c73803f3 100644 --- a/src/ServiceProvider/RouteProvider.php +++ b/src/ServiceProvider/RouteProvider.php @@ -40,7 +40,7 @@ private function registerRoutes(Container $di, App $app) // Profile Runs routes $app->get('/', static function () use ($di, $app) { /** @var Controller\RunController $controller */ - $controller = $app->controller = $di['runController']; + $controller = $di['runController']; $request = $app->request(); $response = $app->response(); diff --git a/tests/Controller/RunTest.php b/tests/Controller/RunTest.php index ee4cd0a30..3fe6115e2 100644 --- a/tests/Controller/RunTest.php +++ b/tests/Controller/RunTest.php @@ -25,7 +25,7 @@ public function setUp() public function testIndexEmpty() { $this->runs->index($this->app->request(), $this->app->response()); - $result = $this->runs->templateVars(); + $result = $this->view->all(); $this->assertEquals('Recent runs', $result['title']); $this->assertFalse($result['has_search'], 'No search being done.'); @@ -47,7 +47,7 @@ public function testIndexSortedWallTime() ]); $this->runs->index($this->app->request(), $this->app->response()); - $result = $this->runs->templateVars(); + $result = $this->view->all(); $this->assertEquals('Longest wall time', $result['title']); $this->assertEquals('wt', $result['paging']['sort']); } @@ -61,7 +61,7 @@ public function testIndexSortedCpu() ]); $this->runs->index($this->app->request(), $this->app->response()); - $result = $this->runs->templateVars(); + $result = $this->view->all(); $this->assertEquals('Most CPU time', $result['title']); $this->assertEquals('cpu', $result['paging']['sort']); $this->assertEquals('desc', $result['paging']['direction']); @@ -76,7 +76,7 @@ public function testIndexWithSearch() ]); $this->runs->index($this->app->request(), $this->app->response()); - $result = $this->runs->templateVars(); + $result = $this->view->all(); $this->assertEquals('Highest memory use', $result['title']); $this->assertEquals('mu', $result['paging']['sort']); $this->assertEquals('asc', $result['paging']['direction']);