TestController.php
1.71 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
<?php
/**
*
* @author Adhidarma <adhisimon@gmail.com>
*/
class TestController extends Controller {
function getModel() {
return null;
}
protected function getModels() {
$models[] = new UserModel();
$models[] = new RoleModel();
$models[] = new UserRoleModel();
$models[] = new AgentModel();
return $models;
}
function oke() {
die('oke');
}
function nothing() {
}
function phpinfo() {
phpinfo(); die;
}
function about($f3) {
$f3->set('VIEW_FILE', 'about.html');
}
/**
* install action.
*/
function install() {
$models = $this->getModels();
foreach ($models as $model) {
$model->install();
}
$this->disableAutoRender();
}
/**
* uninstall action
*/
function uninstall($f3) {
$models = $this->getModels();
foreach ($models as $model) {
$model->uninstall();
}
$this->disableAutoRender();
}
/**
* Test routines.
*/
function test($f3) {
$test = new Test();
// UserRoleModel's test
$user_role_model = new UserRoleModel();
$test->expect(
$user_role_model->doesRoleIdBelongsToUserId(1, 1),
'User id 1 has role id 1'
);
$test->expect(
!$user_role_model->doesRoleIdBelongsToUserId(200, 1),
'User id 1 does not has role id 200'
);
$test->expect(
!$user_role_model->doesRoleIdBelongsToUserId(10000, 10000),
'User id 10000 does not has role id 10000'
);
$this->dumpTestResult($test);
$this->disableAutoRender();
}
}