Ticket #151: tasks_ext_phpunit_GroupStuff-151.patch
| File tasks_ext_phpunit_GroupStuff-151.patch, 3.2 kB (added by dirk.thomas@4wdmedia.de, 1 year ago) |
|---|
-
PHPUnitTask.php
old new 44 44 private $printsummary = false; 45 45 private $testfailed = false; 46 46 private $codecoverage = false; 47 private $groups = array(); 48 private $excludeGroups = array(); 47 49 48 50 /** 49 51 * Initialize Task. … … 78 80 if (version_compare($version, "3.0.0") >= 0) 79 81 { 80 82 PHPUnitUtil::$installedVersion = 3; 83 if (version_compare($version, "3.2.0") >= 0) 84 { 85 PHPUnitUtil::$installedMinorVersion = 2; 86 } 81 87 } 82 88 else 83 89 { … … 153 159 $this->codecoverage = $codecoverage; 154 160 } 155 161 162 function setGroups($groups) 163 { 164 if (PHPUnitUtil::$installedVersion < 3 || (PHPUnitUtil::$installedVersion == 3 && PHPUnitUtil::$installedMinorVersion < 2)) 165 { 166 $this->log("The 'groups' attribute is only available with PHPUnit 3.2.0 or newer", Project::MSG_WARN); 167 } 168 $token = ' ,;'; 169 $this->groups = array(); 170 $tok = strtok($groups, $token); 171 while ($tok !== false) { 172 $this->groups[] = $tok; 173 $tok = strtok($token); 174 } 175 } 176 177 function setExcludeGroups($excludeGroups) 178 { 179 if (PHPUnitUtil::$installedVersion < 3 || (PHPUnitUtil::$installedVersion == 3 && PHPUnitUtil::$installedMinorVersion < 2)) 180 { 181 $this->log("The 'excludeGroups' attribute is only available with PHPUnit 3.2.0 or newer", Project::MSG_WARN); 182 } 183 $token = ' ,;'; 184 $this->excludeGroups = array(); 185 $tok = strtok($groups, $token); 186 while ($tok !== false) { 187 $this->excludeGroups[] = $tok; 188 $tok = strtok($token); 189 } 190 } 191 156 192 /** 157 193 * Add a new formatter to all tests of this task. 158 194 * … … 255 291 */ 256 292 private function execute($suite) 257 293 { 258 $runner = new PHPUnitTestRunner($suite, $this->project );294 $runner = new PHPUnitTestRunner($suite, $this->project, $this->groups, $this->excludeGroups); 259 295 260 296 $runner->setCodecoverage($this->codecoverage); 261 297 -
PHPUnitTestRunner.php
old new 46 46 47 47 private $project = NULL; 48 48 49 function __construct($suite, Project $project) 49 private $groups = array(); 50 private $excludeGroups = array(); 51 52 function __construct($suite, Project $project, $groups = array(), $excludeGroups = array()) 50 53 { 51 54 $this->suite = $suite; 52 55 $this->project = $project; 56 $this->groups = $groups; 57 $this->excludeGroups = $excludeGroups; 53 58 $this->retCode = self::SUCCESS; 54 59 } 55 60 … … 88 93 $res->addListener($formatter); 89 94 } 90 95 91 $this->suite->run($res );96 $this->suite->run($res, false, $this->groups, $this->excludeGroups); 92 97 93 98 if ($this->codecoverage) 94 99 { -
PHPUnitUtil.php
old new 30 30 class PHPUnitUtil 31 31 { 32 32 /** 33 * Installed PHPUnit version33 * Installed PHPUnit major version 34 34 */ 35 35 public static $installedVersion = 2; 36 36 37 /** 38 * Installed PHPUnit minor version 39 */ 40 public static $installedMinorVersion = 0; 41 37 42 protected static $definedClasses = array(); 38 43 39 44 /**
