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

Source for file ApplicationTest.php

Documentation is available at ApplicationTest.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_ApplicationTest::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/Application.php');
  35. require_once('Console/Application/Abstract.php');
  36.  
  37.     public static $didSomething false;
  38.  
  39.     protected function run({
  40.         self::$didSomething true;
  41.     }
  42. }
  43.  
  44.  
  45. /**
  46.  * @category   Console
  47.  * @package    Unittests
  48.  * @copyright  Copyright (c) 2009 Sven Strittmatter
  49.  */
  50. class Console_ApplicationTest extends PHPUnit_Framework_TestCase {
  51.     /**
  52.      * Runs the test methods of this class.
  53.      *
  54.      * @return void 
  55.      */
  56.     public static function main({
  57.         require_once('PHPUnit/TextUI/TestRunner.php');
  58.         $suite  new PHPUnit_Framework_TestSuite("Console_ApplicationTest");
  59.         $result PHPUnit_TextUI_TestRunner::run($suite);
  60.     }
  61.  
  62.     public function tearDown({
  63.         TestApplication::$didSomething false;
  64.     }
  65.  
  66.     /**
  67.      *
  68.      */
  69.     public function testRunApplication({
  70.         $this->assertFalse(TestApplication::$didSomething);
  71.         Console_Application::execute('Test');
  72.         $this->assertTrue(TestApplication::$didSomething);
  73.     }
  74.  
  75.     public function testReturnsExecutedApplication({
  76.         $application Console_Application::execute('Test');
  77.         $this->assertTrue($application->isExecuted());
  78.     }
  79.  
  80.     public function testExecutesApplicationFromDirecotry({
  81.         $application Console_Application::execute('HelloWorld'TESTS_CONSOLE_APPLICATION_LOCATION);
  82.         $this->assertTrue($application->isExecuted());
  83.     }
  84.  
  85.     public function testThrowsExceptionOnFileIsNotReadable({
  86.         $this->setExpectedException('Console_Exception');
  87.         Console_Application::execute('DoesNotExists');
  88.     }
  89.  
  90.         $this->setExpectedException('Console_Exception');
  91.         Console_Application::execute('BadTest');
  92.     }
  93.  
  94.     public function testSetsPhpEnviroment({
  95.         $this->markTestIncomplete();
  96.     }
  97. }
  98.  
  99. // Call Console_ApplicationTest::main() if this source file is executed directly.
  100. if (PHPUnit_MAIN_METHOD === 'Console_ApplicationTest::main'{
  101. }

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