1818class ConfigControllerTest extends BatchmakeControllerTest
1919 {
2020
21- protected $ kwBatchmakeComponent ;
2221
2322
2423 /** set up tests*/
2524 public function setUp ()
2625 {
2726 $ this ->setupDatabase (array ('default ' ));
27+ $ this ->_daos = array ('User ' );
2828 $ this ->_models = array ('User ' );
2929 $ this ->enabledModules = array ('batchmake ' );
3030 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- }
3631 }
3732
3833
3934
35+
4036 /** test index action*/
4137 public function testIndexAction ()
4238 {
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+
4472 $ body = $ this ->getBody ();
4573
4674 $ this ->assertModule ("batchmake " );
@@ -52,20 +80,6 @@ public function testIndexAction()
5280 }
5381
5482 $ 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 );
6983 }
7084
7185
0 commit comments