spriebsch Sat Apr 25 15:39:09 2009 UTC
Modified files:
/phpruntests/tests/configuration/preconditions
rtIfParallelHasPcntlTest.php
Log:
Refactored test and added comments.
http://cvs.php.net/viewvc.cgi/phpruntests/tests/configuration/preconditions/rtIfParallelHasPcntlTest.php?r1=1.3&r2=1.4&diff_format=u
Index:
phpruntests/tests/configuration/preconditions/rtIfParallelHasPcntlTest.php
diff -u
phpruntests/tests/configuration/preconditions/rtIfParallelHasPcntlTest.php:1.3
phpruntests/tests/configuration/preconditions/rtIfParallelHasPcntlTest.php:1.4
---
phpruntests/tests/configuration/preconditions/rtIfParallelHasPcntlTest.php:1.3
Sat Apr 25 15:13:24 2009
+++ phpruntests/tests/configuration/preconditions/rtIfParallelHasPcntlTest.php
Sat Apr 25 15:39:09 2009
@@ -1,49 +1,83 @@
<?php
+/**
+ * rtIfParallelHasPcntlTest
+ *
+ * @category Testing
+ * @package RUNTESTS
+ * @author Zoe Slattery <[email protected]>
+ * @author Stefan Priebsch <[email protected]>
+ * @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 <[email protected]>
+ * @author Stefan Priebsch <[email protected]>
+ * @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?
}
?>
--
PHP CVS Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php