/** * 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')); }
/** * testError404 method * * @access public * @return void */ function testError404() { ob_start(); $TestErrorHandler = new TestErrorHandler('error404', array('message' => 'Page not found', 'url' => '/test_error')); $result = ob_get_clean(); $this->assertPattern('/<h2>Not Found<\\/h2>/', $result); $this->assertPattern("/<strong>'\\/test_error'<\\/strong>/", $result); ob_start(); $TestErrorHandler =& new TestErrorHandler('error404', array('message' => 'Page not found')); ob_get_clean(); ob_start(); $TestErrorHandler->error404(array('url' => 'pages/<span id=333>pink</span></id><script>document.body.style.background = t=document.getElementById(333).innerHTML;window.alert(t);</script>', 'message' => 'Page not found')); $result = ob_get_clean(); $this->assertNoPattern('#<script>#', $result); $this->assertNoPattern('#</script>#', $result); }
/** * testError method * * @access public * @return void */ function testError() { ob_start(); $TestErrorHandler = new TestErrorHandler('error404', array('message' => 'Page not found')); ob_clean(); ob_start(); $TestErrorHandler->error(array('code' => 404, 'message' => 'Page not Found', 'name' => "Couldn't find what you were looking for")); $result = ob_get_clean(); $this->assertPattern("/<h2>Couldn't find what you were looking for<\\/h2>/", $result); $this->assertPattern('/Page not Found/', $result); }
/** * testError404 method * * @access public * @return void */ function testError404() { App::build(array( 'views' => array(TEST_CAKE_CORE_INCLUDE_PATH . 'libs' . DS . 'view' . DS) ), true); ob_start(); $TestErrorHandler = new TestErrorHandler('error404', array('message' => 'Page not found', 'url' => '/test_error')); $result = ob_get_clean(); $this->assertPattern('/<h2>Not Found<\/h2>/', $result); $this->assertPattern("/<strong>'\/test_error'<\/strong>/", $result); ob_start(); $TestErrorHandler =& new TestErrorHandler('error404', array('message' => 'Page not found')); ob_get_clean(); ob_start(); $TestErrorHandler->error404(array( 'url' => 'pages/<span id=333>pink</span></id><script>document.body.style.background = t=document.getElementById(333).innerHTML;window.alert(t);</script>', 'message' => 'Page not found' )); $result = ob_get_clean(); $this->assertNoPattern('#<script>#', $result); $this->assertNoPattern('#</script>#', $result); App::build(); }
/** * 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']); }