Skip to content

Commit

Permalink
RunController::index: Use render() method
Browse files Browse the repository at this point in the history
  • Loading branch information
glensc committed Dec 22, 2020
1 parent 0620810 commit a50fa6f
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 8 deletions.
5 changes: 2 additions & 3 deletions src/Controller/RunController.php
Original file line number Diff line number Diff line change
Expand Up @@ -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,
]);
}
Expand Down
2 changes: 1 addition & 1 deletion src/ServiceProvider/RouteProvider.php
Original file line number Diff line number Diff line change
Expand Up @@ -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();

Expand Down
8 changes: 4 additions & 4 deletions tests/Controller/RunTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -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.');
Expand All @@ -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']);
}
Expand All @@ -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']);
Expand All @@ -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']);
Expand Down

0 comments on commit a50fa6f

Please sign in to comment.