Unittests
[ class tree: Unittests ] [ index: Unittests ] [ all elements ]

Source for file ExceptionTest.php

Documentation is available at ExceptionTest.php

  1. <?php
  2. /**
  3.  * Console Library
  4.  *
  5.  * LICENSE
  6.  *
  7.  * "THE BEER-WARE LICENSE" (Revision 42):
  8.  * "Sven Strittmatter" <ausserirdisch@sven-space.de> wrote this file.
  9.  * As long as you retain this notice you can do whatever you want with
  10.  * this stuff. If we meet some day, and you think this stuff is worth it,
  11.  * you can buy me a beer in return.
  12.  *
  13.  * $Author$
  14.  * $Revisio$
  15.  *
  16.  * @category    Console
  17.  * @package     Unittests
  18.  * @copyright   Copyright (c) 2009 Sven Strittmatter
  19.  */
  20.  
  21. // Call Console_ApplicationTest::main() if this source file is executed directly.
  22. if (!defined('PHPUnit_MAIN_METHOD')) {
  23.     define('PHPUnit_MAIN_METHOD''Console_ExceptionTest::main');
  24. }
  25.  
  26. /**
  27.  * Test helper
  28.  */
  29. require_once(dirname(__FILE__'/../TestHelper.php');
  30.  
  31. /**
  32.  * Console_Loader
  33.  */
  34. require_once('Console/Exception.php');
  35.  
  36. /**
  37.  * @category   Console
  38.  * @package    Unittests
  39.  * @copyright  Copyright (c) 2009 Sven Strittmatter
  40.  */
  41. class Console_ExceptionTest extends PHPUnit_Framework_TestCase {
  42.     /**
  43.      * Runs the test methods of this class.
  44.      *
  45.      * @return void 
  46.      */
  47.     public static function main({
  48.         require_once('PHPUnit/TextUI/TestRunner.php');
  49.         $suite  new PHPUnit_Framework_TestSuite("Console_ExceptionTest");
  50.         $result PHPUnit_TextUI_TestRunner::run($suite);
  51.     }
  52.  
  53.     /**
  54.      * We expect a string like:
  55.      * <pre>
  56.      * Excpetion: EXCEPTION_MESSAGE [Code: EXCPETION_CODE]PHP_EOL;
  57.      * </pre>
  58.      */
  59.     public function testTosTring({
  60.         $parmeters array(
  61.             array('message' => 'Testmessage''code' => 0),
  62.             array('message' => 'Another Message''code' => 5),
  63.             array('message' => 'Error occured''code' => -4),
  64.             array('message' => 'Blaaa ''code' => null),
  65.             array('message' => 'Mor message''code' => false)
  66.         );
  67.  
  68.         foreach ($parmeters as $parameter{
  69.             $expectedString "Excpetion: {$parameter['message']} [Code: . (int) $parameter['code']']' PHP_EOL;
  70.             $exception      new Console_Exception($parameter['message']$parameter['code']);
  71.             $this->assertEquals($expectedString$exception->__toString());
  72.             $this->assertEquals($expectedString$exception '');
  73.         }
  74.     }
  75. }
  76.  
  77. // Call Console_ExceptionTest::main() if this source file is executed directly.
  78. if (PHPUnit_MAIN_METHOD === 'Console_ExceptionTest::main'{
  79. }

Documentation generated on Mon, 17 Aug 2009 15:52:37 +0200 by phpDocumentor 1.4.2