com phpruntests: Fixed test and removed obsolete code from rtPreConditionList.: src/configuration/rtPreConditionList.php
tests/configuration/rtPreconditionListTest.php

From: Date: Wed, 13 May 2009 11:10:54 +0000
Subject: com phpruntests: Fixed test and removed obsolete code from rtPreConditionList.: src/configuration/rtPreConditionList.php
tests/configuration/rtPreconditionListTest.php
Groups: php.qa 
Request: Send a blank email to php-qa+get-66466@lists.php.net to get a copy of this message
Commit: 19463bc7841e3bd8a0b83ae7da5f1a2a33a8d6c4 Author: Stefan Priebsch <spriebsch@php.net> Wed, 13 May 2009 11:10:54 +0000 Parents: 6f659c91ffb4a45024946fc15150e013d250f421 Branches: master Link: http://git.php.net/?p=phpruntests.git;a=commitdiff;h=19463bc7841e3bd8a0b83ae7da5f1a2a33a8d6c4 Log: Fixed test and removed obsolete code from rtPreConditionList. Changed paths: M src/configuration/rtPreConditionList.php M tests/configuration/rtPreconditionListTest.php Diff: diff --git a/src/configuration/rtPreConditionList.php b/src/configuration/rtPreConditionList.php index 440ddfc..4f06157 100644 --- a/src/configuration/rtPreConditionList.php +++ b/src/configuration/rtPreConditionList.php @@ -25,7 +25,7 @@ abstract class rtPreConditionList static public function getInstance($os = 'Unix') { if ($os == 'Windows') { - return new rtWinPreconditionList('Windows'); + return new rtWinPreConditionList(); } else { return new rtUnixPreConditionList(); } @@ -37,34 +37,19 @@ abstract class rtPreConditionList * @param rtCommandLineOptions $commandLine * @param rtEnvironmentVariables $environmentVariables * @return boolean + * @todo modify to check all preconditions, and return a list of failed ones */ public function check(rtRuntestsConfiguration $config) { foreach ($this->preConditions as $preCon) { $p = new $preCon; - // if (!$p->check($commandLine, $environmentVariables)) { if (!$p->check($config)) { - die($p->getMessage()); + throw new Exception($p->getMessage()); } } return true; } - - /** - * Test to ensure that a particular pre-condition exists (used in testing) - * - * @param string $pc - * @return boolean - */ - public function hasPreCondition($pc) - { - if (in_array($pc, $this->preConditions)) { - return true; - } - - return false; - } } ?> diff --git a/tests/configuration/rtPreconditionListTest.php b/tests/configuration/rtPreconditionListTest.php index 0f283c7..937aa9a 100644 --- a/tests/configuration/rtPreconditionListTest.php +++ b/tests/configuration/rtPreconditionListTest.php @@ -1,36 +1,65 @@ <?php +/** + * rtPreCondtionListTest + * + * @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 rtPreCondtionListTest 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 rtPreCondtionListTest extends PHPUnit_Framework_TestCase { - protected $clo; - protected $env; - protected $ge; - - public function setUp() + protected function setUp() { - $this->clo = new rtCommandLineOptions(); - $this->clo->parse(array('run-tests.php', '-p', 'some-php-exe', 'a-test.phpt')); + $this->preConditionList = rtPreConditionList::getInstance(); + } - $this->env = rtEnvironmentVariables::getInstance(); - $this->env->getUserSuppliedVariables(); + protected function tearDown() + { + unset($this->preConditionList); } public function testCheck() { - $sl = rtPreConditionList::getInstance(); + $php = trim(shell_exec("which php")); + + $preConditionList = rtPreConditionList::getInstance(); + $runtestsConfiguration = rtRuntestsConfiguration::getInstance(array('run-tests.php', '-p', $php, 'a-test.phpt')); + $runtestsConfiguration->configure(); + + $this->assertTrue($preConditionList->check($runtestsConfiguration)); + } + + public function testGetInstanceOnUnix() + { + $preConditionList = rtPreConditionList::getInstance('Unix'); - $this->assertTrue($sl->check($this->clo, $this->env)); + $this->assertTrue($preConditionList instanceOf rtUnixPreConditionList); } - public function testUnix() + public function testGetInstanceOnWindows() { - $sl = rtPreConditionList::getInstance(); - $sl->adaptList(); + $preConditionList = rtPreConditionList::getInstance('Windows'); - $this->assertTrue($sl->hasPreCondition('rtIfParallelHasPcntl')); + $this->assertTrue($preConditionList instanceOf rtWinPreConditionList); } } ?>

« previous php.qa (#66466) next »