public function checkModifyException(Zend_Exception $exception) { if (preg_match('/Duplicate entry.*for key (2|\'nickname\')/i', $exception->getMessage())) { $this->_setError('nicknameExists'); return false; } if (preg_match('/Duplicate entry.*for key (3|\'name\')/i', $exception->getMessage())) { $this->_setError('nameExists'); return false; } return true; }
public function testExceptions() { // Ohne Mail $exception = new Kwf_Exception(); $view = $this->_processException($exception); $this->assertEquals($view->message, $exception->getMessage()); $this->assertTrue($view->debug); $this->assertEquals($view->template, 'error.tpl'); // Mit Mail Zend_Registry::get('config')->debug->error->log = true; Kwf_Config::deleteValueCache('debug.error.log'); $exception = new Kwf_Exception(); $view = $this->_processException($exception); $this->assertEquals($view->message, $exception->getMessage()); $this->assertFalse($view->debug); $this->assertEquals($view->template, 'error.tpl'); // Nicht-Kwf_Exception mit Mail Zend_Registry::get('config')->debug->error->log = true; Kwf_Config::deleteValueCache('debug.error.log'); $e = new Zend_Exception(); $exception = new Kwf_Exception_Other($e); $view = $this->_processException($exception); $this->assertEquals($view->message, $e->getMessage()); $this->assertFalse($view->debug); $this->assertEquals($view->template, 'error.tpl'); Zend_Registry::get('config')->debug->error->log = false; Kwf_Config::deleteValueCache('debug.error.log'); // Kwf_Exception_NoLog mit Debug Zend_Registry::get('config')->debug->error->log = true; Kwf_Config::deleteValueCache('debug.error.log'); $exception = new Kwf_Exception_NoLog(); $view = $this->_processException($exception); $this->assertEquals($view->message, $exception->getMessage()); $this->assertFalse($view->debug); Zend_Registry::get('config')->debug->error->log = false; Kwf_Config::deleteValueCache('debug.error.log'); $this->assertEquals($view->template, 'error.tpl'); // Kwf_Exception_NoLog ohne Debug $exception = new Kwf_Exception_NoLog(); $view = $this->_processException($exception); $this->assertEquals($view->message, $exception->getMessage()); $this->assertTrue($view->debug); $this->assertEquals($view->template, 'error.tpl'); // Kwf_Exception_NotFound $exception = new Kwf_Exception_NotFound(); $view = $this->_processException($exception); $this->assertEquals($view->message, $exception->getMessage()); $this->assertEquals($view->template, 'error404.tpl'); // Nicht-Kwf_Exception $exception = new Exception(); $view = $this->_processException($exception); $this->assertEquals($view->message, $exception->getMessage()); $this->assertEquals($view->template, 'error.tpl'); // ClientException $exception = new Kwf_ClientException(); $view = $this->_processException($exception); $this->assertEquals($view->message, $exception->getMessage()); $this->assertEquals($view->template, 'error-client.tpl'); }
public function checkModifyException(Zend_Exception $exception) { if (preg_match('/Duplicate entry.*for key (\'membership\'|2)/i', $exception->getMessage())) { $this->_setError('membershipExists'); return false; } return true; }
public function testExceptions() { // Ohne Mail $exception = new Kwf_Exception(); $view = $this->_processException($exception); $this->assertEquals($view->message, $exception->getMessage()); $this->assertTrue($view->debug); $this->assertEquals($view->template, 'error.tpl'); // Mit Mail Kwf_Exception_Abstract::$logErrors = true; $exception = new Kwf_Exception(); $view = $this->_processException($exception); $this->assertEquals($view->message, $exception->getMessage()); $this->assertFalse($view->debug); $this->assertEquals($view->template, 'error.tpl'); // Nicht-Kwf_Exception mit Mail Kwf_Exception_Abstract::$logErrors = true; $e = new Zend_Exception(); $exception = new Kwf_Exception_Other($e); $view = $this->_processException($exception); $this->assertEquals($view->message, $e->getMessage()); $this->assertFalse($view->debug); $this->assertEquals($view->template, 'error.tpl'); Kwf_Exception_Abstract::$logErrors = null; // Kwf_Exception_NoLog mit Debug Kwf_Exception_Abstract::$logErrors = true; $exception = new Kwf_Exception_NoLog(); $view = $this->_processException($exception); $this->assertEquals($view->message, $exception->getMessage()); $this->assertFalse($view->debug); Kwf_Exception_Abstract::$logErrors = null; $this->assertEquals($view->template, 'error.tpl'); // Kwf_Exception_NoLog ohne Debug $exception = new Kwf_Exception_NoLog(); $view = $this->_processException($exception); $this->assertEquals($view->message, $exception->getMessage()); $this->assertTrue($view->debug); $this->assertEquals($view->template, 'error.tpl'); // Kwf_Exception_NotFound $exception = new Kwf_Exception_NotFound(); $view = $this->_processException($exception); $this->assertEquals($view->message, $exception->getMessage()); $this->assertEquals($view->template, 'error404.tpl'); // Nicht-Kwf_Exception $exception = new Exception(); $view = $this->_processException($exception); $this->assertEquals($view->message, $exception->getMessage()); $this->assertEquals($view->template, 'error.tpl'); // ClientException $exception = new Kwf_ClientException(); $view = $this->_processException($exception); $this->assertEquals($view->message, $exception->getMessage()); $this->assertEquals($view->template, 'error-client.tpl'); }
public function testMessage() { $e = new Zend_Exception('msg'); $this->assertEquals('msg', $e->getMessage()); }