com phpruntests: Refactored test and added comments.: tests/configuration/preconditions/rtIfParallelHasPcntlTest.php

From: Date: Sat, 25 Apr 2009 15:39:09 +0000
Subject: com phpruntests: Refactored test and added comments.: tests/configuration/preconditions/rtIfParallelHasPcntlTest.php
Groups: php.qa 
Request: Send a blank email to php-qa+get-66522@lists.php.net to get a copy of this message
Commit: c881d818c271ffa8fe0ac580d8a8af5ee83027ce Author: Stefan Priebsch <spriebsch@php.net> Sat, 25 Apr 2009 15:39:09 +0000 Parents: b82d0be7a8e0935688ae40482392f3f423b1c38e Branches: master Link: http://git.php.net/?p=phpruntests.git;a=commitdiff;h=c881d818c271ffa8fe0ac580d8a8af5ee83027ce Log: Refactored test and added comments. Changed paths: M tests/configuration/preconditions/rtIfParallelHasPcntlTest.php Diff: diff --git a/tests/configuration/preconditions/rtIfParallelHasPcntlTest.php b/tests/configuration/preconditions/rtIfParallelHasPcntlTest.php index d3a4036..fd7b21a 100644 --- a/tests/configuration/preconditions/rtIfParallelHasPcntlTest.php +++ b/tests/configuration/preconditions/rtIfParallelHasPcntlTest.php @@ -1,49 +1,83 @@ <?php +/** + * rtIfParallelHasPcntlTest + * + * @category Testing + * @package RUNTESTS + * @author Zoe Slattery <zoe@php.net> + * @author Stefan Priebsch <spriebsch@php.net> + * @copyright 2009 The PHP Group + * @license http://www.php.net/license/3_01.txt PHP License 3.01 + * @link http://qa.php.net/ + */ require_once 'PHPUnit/Framework.php'; require_once dirname(__FILE__) . '../../../../src/rtAutoload.php'; +/** + * Tests for rtIfParallelHasPcntlTest precondition. + * + * @category Testing + * @package RUNTESTS + * @author Zoe Slattery <zoe@php.net> + * @author Stefan Priebsch <spriebsch@php.net> + * @copyright 2009 The PHP Group + * @license http://www.php..net/license/3_01.txt PHP License 3.01 + * @link http://qa.php.net/ + */ class rtIfParallelHasPcntlTest extends PHPUnit_Framework_TestCase { - public function testLoaded() + protected function setUp() { - $clo = new rtCommandLineOptions(); - $clo->parse(array('run-tests.php', '-z')); - $env = rtEnvironmentVariables::getInstance(); - - $pre = new rtIfParallelHasPcntl(); + $this->preCondition = new rtIfParallelHasPcntl(); + $this->commandLine = new rtCommandLineOptions(); - $this->assertEquals(extension_loaded('pcntl'), $pre->check($clo, $env)); + $this->environment = rtEnvironmentVariables::getInstance(); } - - public function testLoaded2() + + protected function tearDown() { - $clo = new rtCommandLineOptions(); - $env = rtEnvironmentVariables::getInstance(); - $env->setVariable('TEST_PHP_PARALLEL', true); - - $pre = new rtIfParallelHasPcntl(); + unset($this->preCondition); + unset($this->commandLine); + unset($this->environment); + } - $this->assertTrue($pre->check($clo, $env)); + /** + * Ensure that check (wether pcntl is loaded) works + * when parallel test execution is requested by command line option. + */ + public function testCheckWhenCommandLineOptionIsSet() + { + $this->commandLine->parse(array('run-tests.php', '-z')); + + $this->assertEquals(extension_loaded('pcntl'), $this->preCondition->check($this->commandLine, $this->environment)); } - - public function testNotRequired() + + /** + * Ensure that check (wether pcntl is loaded) works + * when parallel test execution is requested by environment variable. + */ + public function testCheckWhenEnvironmentVariableIsSet() { - $clo = new rtCommandLineOptions(); - $env = rtEnvironmentVariables::getInstance(); + $this->environment->setVariable('TEST_PHP_PARALLEL', true); - $pre = new rtIfParallelHasPcntl(); + $this->assertTrue($this->preCondition->check($this->commandLine, $this->environment)); + } - $this->assertTrue($pre->check($clo, $env)); + /** + * Ensure that check returns true when no parallel test execution is requested. + */ + public function testCheckWhenParallelExecutionIsNotRequired() + { + $this->assertTrue($this->preCondition->check($this->commandLine, $this->environment)); } + /** + * Ensure that the error message is correct. + */ public function testgetMessage() { - $pre = new rtIfParallelHasPcntl(); - - $this->assertEquals($pre->getMessage('pcntlNotLoaded'), rtText::get('pcntlNotLoaded')); + $this->assertEquals($this->preCondition->getMessage('pcntlNotLoaded'), rtText::get('pcntlNotLoaded')); } - - //Not sure how to check if it's not loaded? } ?>

« previous php.qa (#66522) next »