18
18
class ConfigControllerTest extends BatchmakeControllerTest
19
19
{
20
20
21
- protected $ kwBatchmakeComponent ;
22
21
23
22
24
23
/** set up tests*/
25
24
public function setUp ()
26
25
{
27
26
$ this ->setupDatabase (array ('default ' ));
27
+ $ this ->_daos = array ('User ' );
28
28
$ this ->_models = array ('User ' );
29
29
$ this ->enabledModules = array ('batchmake ' );
30
30
parent ::setUp ();
31
- if (!isset ($ this ->kwBatchmakeComponent ))
32
- {
33
- require_once BASE_PATH .'/modules/batchmake/controllers/components/KWBatchmakeComponent.php ' ;
34
- $ this ->kwBatchmakeComponent = new Batchmake_KWBatchmakeComponent ($ this ->setupAndGetConfig ());
35
- }
36
31
}
37
32
38
33
39
34
35
+
40
36
/** test index action*/
41
37
public function testIndexAction ()
42
38
{
43
- $ this ->dispatchUrI ("/batchmake/config/index " );
39
+ // first try to bring up the page without logging in, should get an exception
40
+ $ usersFile = $ this ->loadData ('User ' , 'default ' );
41
+ $ nullUserDao = null ;
42
+ foreach ($ usersFile as $ userDao )
43
+ {
44
+ if ($ userDao ->getFirstname () === 'Admin ' )
45
+ {
46
+ $ adminUserDao = $ userDao ;
47
+ }
48
+ else if ($ userDao ->getFirstname () === 'FirstName1 ' )
49
+ {
50
+ $ nonAdminUserDao = $ userDao ;
51
+ }
52
+ }
53
+
54
+ $ withException = true ;
55
+ $ page = '/batchmake/config/index ' ;
56
+ $ this ->params = array ();
57
+ $ this ->getRequest ()->setMethod ('GET ' );
58
+ $ this ->dispatchUrI ($ page , $ nullUserDao , $ withException );
59
+
60
+ // now login with a non-admin account, should get an exception
61
+ $ this ->resetAll ();
62
+ $ this ->params = array ();
63
+ $ this ->getRequest ()->setMethod ('GET ' );
64
+ $ this ->dispatchUrI ($ page , $ nonAdminUserDao , $ withException );
65
+
66
+ // now login with an admin account
67
+ $ this ->resetAll ();
68
+ $ this ->params = array ();
69
+ $ this ->getRequest ()->setMethod ('GET ' );
70
+ $ this ->dispatchUrI ($ page , $ adminUserDao );
71
+
44
72
$ body = $ this ->getBody ();
45
73
46
74
$ this ->assertModule ("batchmake " );
@@ -52,20 +80,6 @@ public function testIndexAction()
52
80
}
53
81
54
82
$ 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
83
}
70
84
71
85
0 commit comments