Changeset 61a14c5


Ignore:
Timestamp:
11/01/11 15:12:20 (7 months ago)
Author:
mrook
Branches:
master
Children:
a81c6c9
Parents:
d401315
git-author:
Michiel Rook <mrook@…> (11/01/11 15:12:20)
git-committer:
Michiel Rook <mrook@…> (11/01/11 15:12:20)
Message:

Refactoring

Location:
classes/phing/tasks/ext/phpunit
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • classes/phing/tasks/ext/phpunit/BatchTest.php

    r07f823b r61a14c5  
    166166     * @return array an array of tests. 
    167167     */ 
    168     public function elements() 
     168    protected function elements() 
    169169    { 
    170170        $filenames = $this->getFilenames(); 
     
    191191     * Returns a testsuite containing all the tests in this batch 
    192192     * 
     193     * @deprecated 
    193194     * @return PHPUnit_Framework_TestSuite 
    194195     */ 
     
    206207        return $suite; 
    207208    } 
     209     
     210    /** 
     211     * Add the tests in this batchtest to a test suite 
     212     * @param PHPUnit_Framework_TestSuite $suite 
     213     */ 
     214    public function addToTestSuite(PHPUnit_Framework_TestSuite $suite) 
     215    { 
     216        foreach ($this->elements() as $element) { 
     217            $suite->addTestSuite(new ReflectionClass($element)); 
     218        } 
     219    } 
     220     
    208221} 
  • classes/phing/tasks/ext/phpunit/PHPUnitTask.php

    r07f823b r61a14c5  
    242242        } 
    243243         
    244         foreach ($this->formatters as $fe) 
    245         { 
    246             $formatter = $fe->getFormatter(); 
    247  
    248             if ($fe->getUseFile()) 
    249             { 
    250                 $destFile = new PhingFile($fe->getToDir(), $fe->getOutfile()); 
    251                  
    252                 $writer = new FileWriter($destFile->getAbsolutePath()); 
    253  
    254                 $formatter->setOutput($writer); 
    255             } 
    256             else 
    257             { 
    258                 $formatter->setOutput($this->getDefaultOutput()); 
    259             } 
    260  
    261             $formatter->startTestRun(); 
    262         } 
    263          
    264244        $suite = new PHPUnit_Framework_TestSuite('AllTests'); 
    265245         
    266246        foreach ($this->batchtests as $batchtest) 
    267247        { 
    268             $elements = $batchtest->elements(); 
    269              
    270             foreach ($elements as $element) { 
    271                 $suite->addTestSuite(new ReflectionClass($element)); 
    272             } 
    273              
    274             //$suite->addTestSuite($batchtest->getTestSuite()); 
     248            $batchtest->addToTestSuite($suite); 
    275249        } 
    276250         
    277251        $this->execute($suite); 
    278          
    279         foreach ($this->formatters as $fe) 
    280         { 
    281             $formatter = $fe->getFormatter(); 
    282             $formatter->endTestRun(); 
    283         } 
    284252         
    285253        if ($this->testfailed) 
     
    323291            $formatter = $fe->getFormatter(); 
    324292 
     293            if ($fe->getUseFile()) 
     294            { 
     295                $destFile = new PhingFile($fe->getToDir(), $fe->getOutfile()); 
     296                 
     297                $writer = new FileWriter($destFile->getAbsolutePath()); 
     298 
     299                $formatter->setOutput($writer); 
     300            } 
     301            else 
     302            { 
     303                $formatter->setOutput($this->getDefaultOutput()); 
     304            } 
     305 
    325306            $runner->addFormatter($formatter); 
     307 
     308            $formatter->startTestRun(); 
    326309        } 
    327310         
    328311        $runner->run($suite); 
    329312 
     313        foreach ($this->formatters as $fe) 
     314        { 
     315            $formatter = $fe->getFormatter(); 
     316            $formatter->endTestRun(); 
     317        } 
     318         
    330319        $retcode = $runner->getRetCode(); 
    331320         
Note: See TracChangeset for help on using the changeset viewer.