@@ -25,6 +25,7 @@ class ConfigControllerTest extends BatchmakeControllerTest
25
25
public function setUp ()
26
26
{
27
27
$ this ->setupDatabase (array ('default ' ));
28
+ $ this ->_daos = array ('User ' );
28
29
$ this ->_models = array ('User ' );
29
30
$ this ->enabledModules = array ('batchmake ' );
30
31
parent ::setUp ();
@@ -37,10 +38,43 @@ public function setUp()
37
38
38
39
39
40
41
+
40
42
/** test index action*/
41
43
public function testIndexAction ()
42
44
{
43
- $ this ->dispatchUrI ("/batchmake/config/index " );
45
+ // first try to bring up the page without logging in, should get an exception
46
+ $ usersFile = $ this ->loadData ('User ' , 'default ' );
47
+ $ nullUserDao = null ;
48
+ foreach ($ usersFile as $ userDao )
49
+ {
50
+ if ($ userDao ->getFirstname () === 'Admin ' )
51
+ {
52
+ $ adminUserDao = $ userDao ;
53
+ }
54
+ else if ($ userDao ->getFirstname () === 'FirstName1 ' )
55
+ {
56
+ $ nonAdminUserDao = $ userDao ;
57
+ }
58
+ }
59
+
60
+ $ withException = true ;
61
+ $ page = '/batchmake/config/index ' ;
62
+ $ this ->params = array ();
63
+ $ this ->getRequest ()->setMethod ('GET ' );
64
+ $ this ->dispatchUrI ($ page , $ nullUserDao , $ withException );
65
+
66
+ // now login with a non-admin account, should get an exception
67
+ $ this ->resetAll ();
68
+ $ this ->params = array ();
69
+ $ this ->getRequest ()->setMethod ('GET ' );
70
+ $ this ->dispatchUrI ($ page , $ nonAdminUserDao , $ withException );
71
+
72
+ // now login with an admin account
73
+ $ this ->resetAll ();
74
+ $ this ->params = array ();
75
+ $ this ->getRequest ()->setMethod ('GET ' );
76
+ $ this ->dispatchUrI ($ page , $ adminUserDao );
77
+
44
78
$ body = $ this ->getBody ();
45
79
46
80
$ this ->assertModule ("batchmake " );
@@ -52,20 +86,6 @@ public function testIndexAction()
52
86
}
53
87
54
88
$ this ->assertQuery ("form#configForm " );
55
- $ applicationConfig = $ this ->setupAndGetConfig ();
56
- $ this ->params = array ();
57
- $ this ->params [MIDAS_BATCHMAKE_TMP_DIR_PROPERTY ] = $ applicationConfig [MIDAS_BATCHMAKE_TMP_DIR_PROPERTY ];
58
- $ this ->params [MIDAS_BATCHMAKE_BIN_DIR_PROPERTY ] = $ applicationConfig [MIDAS_BATCHMAKE_BIN_DIR_PROPERTY ];
59
- $ this ->params [MIDAS_BATCHMAKE_SCRIPT_DIR_PROPERTY ] = $ applicationConfig [MIDAS_BATCHMAKE_SCRIPT_DIR_PROPERTY ];
60
- $ this ->params [MIDAS_BATCHMAKE_APP_DIR_PROPERTY ] = $ applicationConfig [MIDAS_BATCHMAKE_APP_DIR_PROPERTY ];
61
- $ this ->params [MIDAS_BATCHMAKE_DATA_DIR_PROPERTY ] = $ applicationConfig [MIDAS_BATCHMAKE_DATA_DIR_PROPERTY ];
62
- $ this ->params [MIDAS_BATCHMAKE_CONDOR_BIN_DIR_PROPERTY ] = $ applicationConfig [MIDAS_BATCHMAKE_CONDOR_BIN_DIR_PROPERTY ];
63
- // @TODO get these tests to a better state, testing more
64
- // luckily, almost all of the functionality goes through KWBatchmakeComponent
65
- // which is reasonably well tested
66
- $ this ->params ['submit ' ] = 'submitConfig ' ;
67
- $ this ->request ->setMethod ('POST ' );
68
- $ this ->dispatchUrI ("/batchmake/config " , null , true );
69
89
}
70
90
71
91
0 commit comments