/** * A method to test the class constructor. */ function testOA_Task_Runner() { // Test constructor for user with non-existing account // Set the error handling class' handleErrors() method as // the error handler for PHP for this test. $oTestErrorHandler = new TestErrorHandler(); PEAR::pushErrorHandling(PEAR_ERROR_CALLBACK, array(&$oTestErrorHandler, 'handleErrors')); $doUsers = OA_Dal::factoryDO('users'); $doUsers->default_account_id = -1; $oPermUser = new OA_Permission_User($doUsers); $this->assertEqual(count($oTestErrorHandler->aErrors), 1); $this->assertEqual($oTestErrorHandler->aErrors[0]->message, 'Could not find the specified account'); $oTestErrorHandler->reset(); // Unset the error handler PEAR::popErrorHandling(); // Test for user with existing account $doUsers = OA_Dal::staticGetDO('users', $this->userId); $oPermUser = new OA_Permission_User($doUsers); $this->assertTrue(is_object($oPermUser)); $this->assertTrue(is_a($oPermUser, 'OA_Permission_User')); }
/** * A method to test the getConfigByFileName() method. */ function deprecated_testGetConfigByFileName() { // Set the error handling class' handleErrors() method as // the error handler for PHP for this test. $oTestErrorHandler = new TestErrorHandler(); PEAR::pushErrorHandling(PEAR_ERROR_CALLBACK, array(&$oTestErrorHandler, 'handleErrors')); // Test a config file that does not exist $result = MAX_Plugin::getConfigByFileName('foo'); $this->assertEqual(count($oTestErrorHandler->aErrors), 1); $this->assertEqual($oTestErrorHandler->aErrors[0]->message, "Config file 'foo' does not exist."); $this->assertFalse($result); $oTestErrorHandler->reset(); // Unset the error handler PEAR::popErrorHandling(); // Test a config file that does exist $result = MAX_Plugin::getConfigByFileName(MAX_PATH . '/plugins/geotargeting/default.plugin.conf.php'); $this->assertTrue(is_array($result)); $this->assertEqual(count($result), 2); $this->assertEqual($result['type'], 'none'); $this->assertFalse($result['saveStats']); // Test a config file that does exist, with sections $result = MAX_Plugin::getConfigByFileName(MAX_PATH . '/plugins/geotargeting/default.plugin.conf.php', true); $this->assertTrue(is_array($result)); $this->assertEqual(count($result), 1); $this->assertTrue(is_array($result['geotargeting'])); $this->assertEqual(count($result['geotargeting']), 2); $this->assertEqual($result['geotargeting']['type'], 'none'); $this->assertFalse($result['geotargeting']['saveStats']); }