forked from mtierltd/timetracker
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathSimpleControllersTest.php
More file actions
100 lines (87 loc) · 4.55 KB
/
SimpleControllersTest.php
File metadata and controls
100 lines (87 loc) · 4.55 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
<?php
namespace OCA\TimeTracker\Tests\Unit\Controller;
use PHPUnit\Framework\TestCase;
use OCP\IRequest;
use OCP\IUserSession;
use OCP\AppFramework\Http\TemplateResponse;
use OCA\TimeTracker\Controller\ClientsController;
use OCA\TimeTracker\Controller\DashboardController;
use OCA\TimeTracker\Controller\GoalsController;
use OCA\TimeTracker\Controller\PageController;
use OCA\TimeTracker\Controller\ProjectsController;
use OCA\TimeTracker\Controller\ReportsController;
use OCA\TimeTracker\Controller\TagsController;
use OCA\TimeTracker\Controller\TimelinesAdminController;
use OCA\TimeTracker\Controller\TimelinesController;
class SimpleControllersTest extends TestCase {
private $request;
private $userSession;
private $appName = 'timetracker';
protected function setUp(): void {
$this->request = $this->createMock(IRequest::class);
$this->userSession = $this->createMock(IUserSession::class);
}
public function testClientsController() {
$controller = new ClientsController($this->appName, $this->request, $this->userSession);
$response = $controller->index();
$this->assertInstanceOf(TemplateResponse::class, $response);
$this->assertEquals('index', $response->getTemplateName());
$this->assertEquals('content/clients', $response->getParams()['appPage']);
}
public function testDashboardController() {
$controller = new DashboardController($this->appName, $this->request, $this->userSession);
$response = $controller->index();
$this->assertInstanceOf(TemplateResponse::class, $response);
$this->assertEquals('index', $response->getTemplateName());
$this->assertEquals('content/dashboard', $response->getParams()['appPage']);
}
public function testGoalsController() {
$controller = new GoalsController($this->appName, $this->request, $this->userSession);
$response = $controller->index();
$this->assertInstanceOf(TemplateResponse::class, $response);
$this->assertEquals('index', $response->getTemplateName());
$this->assertEquals('content/goals', $response->getParams()['appPage']);
}
public function testPageController() {
$controller = new PageController($this->appName, $this->request, $this->userSession);
$response = $controller->index();
$this->assertInstanceOf(TemplateResponse::class, $response);
$this->assertEquals('index', $response->getTemplateName());
$this->assertEquals('content/index', $response->getParams()['appPage']);
}
public function testProjectsController() {
$controller = new ProjectsController($this->appName, $this->request, $this->userSession);
$response = $controller->index();
$this->assertInstanceOf(TemplateResponse::class, $response);
$this->assertEquals('index', $response->getTemplateName());
$this->assertEquals('content/projects', $response->getParams()['appPage']);
}
public function testReportsController() {
$controller = new ReportsController($this->appName, $this->request, $this->userSession);
$response = $controller->index();
$this->assertInstanceOf(TemplateResponse::class, $response);
$this->assertEquals('index', $response->getTemplateName());
$this->assertEquals('content/reports', $response->getParams()['appPage']);
}
public function testTagsController() {
$controller = new TagsController($this->appName, $this->request, $this->userSession);
$response = $controller->index();
$this->assertInstanceOf(TemplateResponse::class, $response);
$this->assertEquals('index', $response->getTemplateName());
$this->assertEquals('content/tags', $response->getParams()['appPage']);
}
public function testTimelinesAdminController() {
$controller = new TimelinesAdminController($this->appName, $this->request, $this->userSession);
$response = $controller->index();
$this->assertInstanceOf(TemplateResponse::class, $response);
$this->assertEquals('index', $response->getTemplateName());
$this->assertEquals('content/timelines-admin', $response->getParams()['appPage']);
}
public function testTimelinesController() {
$controller = new TimelinesController($this->appName, $this->request, $this->userSession);
$response = $controller->index();
$this->assertInstanceOf(TemplateResponse::class, $response);
$this->assertEquals('index', $response->getTemplateName());
$this->assertEquals('content/timelines', $response->getParams()['appPage']);
}
}