Added:
trunk/.project
trunk/xyexception-contrib/runtests.sh
trunk/xyexception-tests/all.tests.php
trunk/xyexception-tests/xyexception.test.php
Modified:
trunk/xyexception-contrib/examples/sessiontimedout.exception.php
trunk/xyexception-contrib/makedoc.sh
trunk/xyexception-includes/xyexception.exception.php
Log:
Added Tests
Added: trunk/.project
==============================================================================
--- (empty file)
+++ trunk/.project Sat Mar 24 14:01:26 2007
@@ -0,0 +1,11 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<projectDescription>
+ <name>xyphpexception</name>
+ <comment></comment>
+ <projects>
+ </projects>
+ <buildSpec>
+ </buildSpec>
+ <natures>
+ </natures>
+</projectDescription>
Modified: trunk/xyexception-contrib/examples/sessiontimedout.exception.php
==============================================================================
--- trunk/xyexception-contrib/examples/sessiontimedout.exception.php (original)
+++ trunk/xyexception-contrib/examples/sessiontimedout.exception.php Sat Mar 24 14:01:26 2007
@@ -13,13 +13,13 @@
parent::__construct($message, $code);
}
- protected function GetMailSubject()
+ protected function getMailSubject()
{
return 'SessionTimedOutException in file '.$this->aTrace[0]['File']
.' at line '.$this->aTrace[0]['Line'];
}
- protected function GetMailBody()
+ protected function getMailBody()
{
$sResult = 'SessionTimedOutException in file '.$this->aTrace[0]['File']
.' at line '.$this->aTrace[0]['Line']."\n";
Modified: trunk/xyexception-contrib/makedoc.sh
==============================================================================
--- trunk/xyexception-contrib/makedoc.sh (original)
+++ trunk/xyexception-contrib/makedoc.sh Sat Mar 24 14:01:26 2007
@@ -1,2 +1,2 @@
#!/bin/sh
-phpdoc -t doc/ -f xyexception.exception.php
+phpdoc -t doc/ -f xyexception-includes/xyexception.exception.php
Added: trunk/xyexception-contrib/runtests.sh
==============================================================================
--- (empty file)
+++ trunk/xyexception-contrib/runtests.sh Sat Mar 24 14:01:26 2007
@@ -0,0 +1,2 @@
+#!/bin/sh
+phpunit AllTests xyexception-tests/all.tests.php
Modified: trunk/xyexception-includes/xyexception.exception.php
==============================================================================
--- trunk/xyexception-includes/xyexception.exception.php (original)
+++ trunk/xyexception-includes/xyexception.exception.php Sat Mar 24 14:01:26 2007
@@ -15,7 +15,7 @@
* @package XYException
* @see Exception
*/
-abstract class XYException extends Exception
+class XYException extends Exception
{
public function __construct($message, $code = 0)
{
@@ -141,7 +141,11 @@
* @author Uwe L. Korn <uw...@xhochy.org>
* @return string
*/
- abstract protected function getMailSubject();
+ protected function getMailSubject()
+ {
+ return __CLASS__.' in file '.$this->aTrace[0]['File']
+ .' at line '.$this->aTrace[0]['Line'];
+ }
/**
* Gets the main bod of the Message
@@ -150,6 +154,14 @@
* @author Uwe L. Korn <uw...@xhochy.org>
* @return string
*/
- abstract protected function getMailBody();
-}
-?>
+ protected function getMailBody()
+ {
+ $sResult = __CLASS__.' in file '.$this->aTrace[0]['File']
+ .' at line '.$this->aTrace[0]['Line']."\n";
+ $sResult.= "\nTrace:\n";
+ $sResult.= $this->TraceToString();
+ $sResult.= "\nVars:\n";
+ $sResult.= $this->VarsToString();
+ return $sResult;
+ }
+}
\ No newline at end of file
Added: trunk/xyexception-tests/all.tests.php
==============================================================================
--- (empty file)
+++ trunk/xyexception-tests/all.tests.php Sat Mar 24 14:01:26 2007
@@ -0,0 +1,46 @@
+<?php
+/**
+ * The General Testsuite, executes all Tests
+ *
+ * @author Uwe L. Korn <uw...@xhochy.org>
+ * @package XYException-Tests
+ * @license http://opensource.org/licenses/mit-license.php MIT
+ */
+
+## Defines ##
+
+if (!defined('PHPUnit_MAIN_METHOD')) {
+ define('PHPUnit_MAIN_METHOD', 'AllTests::main');
+}
+
+## Test Includes ##
+
+require_once dirname(__FILE__).'/xyexception.test.php';
+
+## PHPUnit Includes ##
+
+require_once 'PHPUnit/Framework.php';
+require_once 'PHPUnit/TextUI/TestRunner.php';
+
+## The Testsuite ##
+
+class AllTests
+{
+ public static function main()
+ {
+ PHPUnit_TextUI_TestRunner::run(self::suite());
+ }
+
+ public static function suite()
+ {
+ $suite = new PHPUnit_Framework_TestSuite('PHPUnit');
+
+ $suite->addTestSuite('XYExceptionTest');
+
+ return $suite;
+ }
+}
+
+if (PHPUnit_MAIN_METHOD == 'AllTests::main') {
+ AllTests::main();
+}
\ No newline at end of file
Added: trunk/xyexception-tests/xyexception.test.php
==============================================================================
--- (empty file)
+++ trunk/xyexception-tests/xyexception.test.php Sat Mar 24 14:01:26 2007
@@ -0,0 +1,64 @@
+<?php
+/**
+ * This file tests the XYException
+ *
+ * @author Uwe L. Korn <uw...@xhochy.org>
+ * @package XYException-Test
+ * @license http://opensource.org/licenses/mit-license.php MIT
+ */
+
+## Defines ##
+
+define('SCHOORBS_NOGUI',true);
+
+## Main XYException Code Includes ##
+
+require_once dirname(__FILE__).'/../xyexception-includes/xyexception.exception.php';
+
+## PHPUnit Includes ##
+
+require_once 'PHPUnit/Framework.php';
+require_once 'PHPUnit/Extensions/ExceptionTestCase.php';
+
+## Test ##
+
+/**
+ * Testsuite for the XYException class
+ *
+ * @package XYException-Test
+ * @author Uwe L. Korn <uw...@xhochy.org>
+ */
+class XYExceptionTest extends PHPUnit_Extensions_ExceptionTestCase
+{
+ /**
+ * Checks is the Exception throws well
+ *
+ * @author Uwe L. Korn <uw...@xhochy.org>
+ */
+ public function testStandard()
+ {
+ $this->setExpectedException('XYException');
+
+ throw new XYException('testerror',0);
+ }
+
+ public function testAddVar()
+ {
+ $oException = new XYException('testerror',0);
+ $oException->addVar('s','t');
+ $sVars = $oException->VarsToString();
+ if(empty($sVars)) {
+ $this->fail();
+ }
+ }
+
+ public function testAddTrace()
+ {
+ $oException = new XYException('testerror',0);
+ $oException->addTrace(__FILE__, __LINE__, __FUNCTION__, __CLASS__);
+ $sTrace = $oException->TraceToString();
+ if(empty($sTrace)) {
+ $this->fail();
+ }
+ }
+}
\ No newline at end of file