spriebsch               Wed May 13 11:10:55 2009 UTC

  Modified files:              
    /phpruntests/src/configuration      rtPreConditionList.php 
    /phpruntests/tests/configuration    rtPreconditionListTest.php 
  Log:
  Fixed test and removed obsolete code from rtPreConditionList.
  
  
http://cvs.php.net/viewvc.cgi/phpruntests/src/configuration/rtPreConditionList.php?r1=1.4&r2=1.5&diff_format=u
Index: phpruntests/src/configuration/rtPreConditionList.php
diff -u phpruntests/src/configuration/rtPreConditionList.php:1.4 
phpruntests/src/configuration/rtPreConditionList.php:1.5
--- phpruntests/src/configuration/rtPreConditionList.php:1.4    Wed May  6 
20:45:42 2009
+++ phpruntests/src/configuration/rtPreConditionList.php        Wed May 13 
11:10:54 2009
@@ -25,7 +25,7 @@
     static public function getInstance($os = 'Unix')
     {
         if ($os == 'Windows') {
-            return new rtWinPreconditionList('Windows');
+            return new rtWinPreConditionList();
         } else {
             return new rtUnixPreConditionList();
         }
@@ -37,34 +37,19 @@
      * @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;
-    }
 }
 ?>
http://cvs.php.net/viewvc.cgi/phpruntests/tests/configuration/rtPreconditionListTest.php?r1=1.3&r2=1.4&diff_format=u
Index: phpruntests/tests/configuration/rtPreconditionListTest.php
diff -u phpruntests/tests/configuration/rtPreconditionListTest.php:1.3 
phpruntests/tests/configuration/rtPreconditionListTest.php:1.4
--- phpruntests/tests/configuration/rtPreconditionListTest.php:1.3      Fri Apr 
24 09:42:01 2009
+++ phpruntests/tests/configuration/rtPreconditionListTest.php  Wed May 13 
11:10:54 2009
@@ -1,36 +1,65 @@
 <?php
+/**
+ * rtPreCondtionListTest
+ *
+ * @category  Testing
+ * @package   RUNTESTS
+ * @author    Zoe Slattery <z...@php.net>
+ * @author    Stefan Priebsch <sprieb...@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 <z...@php.net>
+ * @author    Stefan Priebsch <sprieb...@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);
     }
 }
 ?>



-- 
PHP CVS Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

Reply via email to