Source for file AbstractTest.php
Documentation is available at AbstractTest.php
* "THE BEER-WARE LICENSE" (Revision 42):
* "Sven Strittmatter" <ausserirdisch@sven-space.de> wrote this file.
* As long as you retain this notice you can do whatever you want with
* this stuff. If we meet some day, and you think this stuff is worth it,
* you can buy me a beer in return.
* @copyright Copyright (c) 2009 Sven Strittmatter
// Call Console_ApplicationTest::main() if this source file is executed directly.
if (!defined('PHPUnit_MAIN_METHOD')) {
define('PHPUnit_MAIN_METHOD', 'Console_Application_AbstractTest::main');
require_once(dirname(__FILE__ ) . '/../../TestHelper.php');
* Console_Application_Abstract
require_once('Console/Application/Abstract.php');
private $callCounter = 0;
public static $disablePcntl = false;
return $this->callCounter;
protected function run() {
protected function setUp($maxExecutionTime = 10, $memoryLimit = '32M') {
parent::setUp($maxExecutionTime, $memoryLimit);
protected function onError($errorData) {
if (self::$disablePcntl) {
* @subpackage Console_Application
* @copyright Copyright (c) 2009 Sven Strittmatter
private $applicationFixture;
* Runs the test methods of this class.
public static function main() {
require_once('PHPUnit/TextUI/TestRunner.php');
$suite = new PHPUnit_Framework_TestSuite("Console_Application_AbstractTest");
$result = PHPUnit_TextUI_TestRunner::run($suite);
public function setUp() {
$this->applicationFixture = null;
$this->applicationFixture->execute();
$this->assertTrue($this->applicationFixture->isExecuted());
$this->applicationFixture->execute();
// We assume that the template method execute() calls
$this->assertEquals(2, $this->applicationFixture->setUpCalled);
$this->assertTrue($this->applicationFixture->isExecuted());
$this->applicationFixture->execute();
// We assume that the template method execute() calls
// findConsoleParameters() second.
$this->assertEquals(1, $this->applicationFixture->findConsoleParametersCalled);
$this->assertTrue($this->applicationFixture->isExecuted());
$this->applicationFixture->retValFindParams = false;
$this->applicationFixture->execute();
$this->assertEquals(1, $this->applicationFixture->findConsoleParametersCalled);
$this->assertFalse($this->applicationFixture->setUpCalled);
$this->assertFalse($this->applicationFixture->runCalled);
$this->assertFalse($this->applicationFixture->tearDownCalled);
$this->assertFalse($this->applicationFixture->isExecuted());
$this->applicationFixture->execute();
// We assume that the template method execute() calls
$this->assertEquals(3, $this->applicationFixture->runCalled);
$this->assertTrue($this->applicationFixture->isExecuted());
$this->applicationFixture->execute();
// We assume that the template method execute() calls
$this->assertEquals(4, $this->applicationFixture->tearDownCalled);
$this->assertTrue($this->applicationFixture->isExecuted());
$this->applicationFixture->thowsExceptionInRun = true;
$this->applicationFixture->execute();
$this->assertEquals(4, $this->applicationFixture->onErrorCalled);
$this->assertFalse($this->applicationFixture->tearDownCalled);
$this->assertTrue($this->applicationFixture->isExecuted());
$this->markTestIncomplete();
$expectedString = "\tconcrete.sh -v : Sets the script in verbose mode." . PHP_EOL;
$expectedString .= "\tconcrete.sh -h : prints this help message." . PHP_EOL . PHP_EOL;
$expectedString .= 'For bug reporting or issues contact: foo@bar.de' . PHP_EOL;
$usageString = $this->applicationFixture->getHelpMessage();
$this->assertEquals($expectedString, $usageString);
$expectedString = "\tconcrete.sh -v : Sets the script in verbose mode." . PHP_EOL;
$expectedString .= "\tconcrete.sh -h : prints this help message." . PHP_EOL . PHP_EOL;
$expectedString .= 'Written by Sven Strittmatter.' . PHP_EOL;
$expectedString .= 'For bug reporting or issues contact: ich@weltraumschaf.de' . PHP_EOL;
$usageString = $this->applicationFixture->getHelpMessage('Sven Strittmatter', 'ich@weltraumschaf.de');
$this->assertEquals($expectedString, $usageString);
$this->assertEquals('' . PHP_EOL, $this->applicationFixture->echoMsg());
$this->assertEquals('test message' . PHP_EOL, $this->applicationFixture->echoMsg('test message'));
* @todo should be renamed to displayMessage()
$this->markTestIncomplete();
$this->setExpectedException('RuntimeException');
$this->markTestIncomplete('On Mac OS the function pcntl_signal_dispatch() does not exists!');
$this->assertTrue($this->applicationFixture->sigTermCalled);
$this->markTestIncomplete('On Mac OS the function pcntl_signal_dispatch() does not exists!');
$this->assertTrue($this->applicationFixture->sigIntCalled);
$this->markTestIncomplete('On Mac OS the function pcntl_signal_dispatch() does not exists!');
$this->assertTrue($this->applicationFixture->sigHangUpCalled);
$this->markTestIncomplete();
$this->markTestIncomplete();
// Call Console_ApplicationTest::main() if this source file is executed directly.
|