Skip to content

Commit abf2f46

Browse files
committed
Merge pull request #191 from brianium/php7
PHP 7 & PHPUnit 5
2 parents 15caf61 + 0aa3e7d commit abf2f46

File tree

9 files changed

+52
-6
lines changed

9 files changed

+52
-6
lines changed

.travis.yml

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,9 @@ matrix:
1616
fast_finish: true
1717
allow_failures:
1818
- env: PHPUNIT_VERSION='*@dev'
19-
- php: 7.0
19+
exclude:
20+
- php: 5.5
21+
env: PHPUNIT_VERSION='5.*@stable'
2022

2123
env:
2224
- PHPUNIT_VERSION='3.7.*@stable'

composer.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,8 @@
99
"brianium/habitat": "1.0.0",
1010
"ext-reflection": "*",
1111
"ext-simplexml": "*",
12-
"ext-pcre": "*"
12+
"ext-pcre": "*",
13+
"composer/semver": "~1.2.0"
1314
},
1415
"type": "library",
1516
"description": "Parallel testing for PHP",

phpunit.xml.dist

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,4 +18,10 @@
1818
<directory>./test/functional/</directory>
1919
</testsuite>
2020
</testsuites>
21+
22+
<filter>
23+
<whitelist processUncoveredFilesFromWhitelist="true">
24+
<directory suffix=".php">src</directory>
25+
</whitelist>
26+
</filter>
2127
</phpunit>

src/ParaTest/Console/Commands/ParaTestCommand.php

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
<?php namespace ParaTest\Console\Commands;
22

3+
use Composer\Semver\Comparator;
34
use Symfony\Component\Console\Command\Command;
45
use Symfony\Component\Console\Input\InputOption;
56
use Symfony\Component\Console\Input\InputInterface;
@@ -20,6 +21,14 @@ public function __construct(Tester $tester)
2021
$this->tester->configure($this);
2122
}
2223

24+
/**
25+
* @return bool
26+
*/
27+
public static function isWhitelistSupported()
28+
{
29+
return Comparator::greaterThanOrEqualTo(\PHPUnit_Runner_Version::id(), '5.0.0');
30+
}
31+
2332
/**
2433
* Ubiquitous configuration options for ParaTest
2534
*/
@@ -35,6 +44,10 @@ protected function configure()
3544
->addOption('coverage-php', null, InputOption::VALUE_REQUIRED, 'Serialize PHP_CodeCoverage object to file.')
3645
->addOption('max-batch-size', 'm', InputOption::VALUE_REQUIRED, 'Max batch size (only for functional mode).', 0)
3746
->addOption('filter', null, InputOption::VALUE_REQUIRED, 'Filter (only for functional mode).');
47+
48+
if (self::isWhitelistSupported()) {
49+
$this->addOption('whitelist', null, InputOption::VALUE_REQUIRED, 'Directory to add to the coverage whitelist.');
50+
}
3851
}
3952

4053
/**

test/functional/PHPUnitTest.php

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -213,6 +213,9 @@ public function testRunWithFatalParseErrorsHasExitCode255()
213213

214214
public function testRunWithFatalRuntimeErrorsHasExitCode1()
215215
{
216+
if (PHP_VERSION_ID >= 70000) {
217+
$this->markTestSkipped('fatals are handled like normal exceptions with php7');
218+
}
216219
$proc = $this->invokeParatest('fatal-tests/UnitTestWithFatalFunctionErrorTest.php', array(
217220
'bootstrap' => BOOTSTRAP
218221
));
@@ -221,6 +224,9 @@ public function testRunWithFatalRuntimeErrorsHasExitCode1()
221224

222225
public function testRunWithFatalRuntimeErrorOutputsError()
223226
{
227+
if (PHP_VERSION_ID >= 70000) {
228+
$this->markTestSkipped('fatals are handled like normal exceptions with php7');
229+
}
224230
$proc = $this->invokeParatest('fatal-tests/UnitTestWithFatalFunctionErrorTest.php', array(
225231
'bootstrap' => BOOTSTRAP
226232
));
@@ -229,6 +235,9 @@ public function testRunWithFatalRuntimeErrorOutputsError()
229235

230236
public function testRunWithFatalRuntimeErrorWithTheWrapperRunnerOutputsError()
231237
{
238+
if (PHP_VERSION_ID >= 70000) {
239+
$this->markTestSkipped('fatals are handled like normal exceptions with php7');
240+
}
232241
$proc = $this->invokeParatest('fatal-tests/UnitTestWithFatalFunctionErrorTest.php', array(
233242
'bootstrap' => BOOTSTRAP,
234243
'runner' => 'WrapperRunner'

test/functional/ParaTest/Runners/PHPUnit/RunnerIntegrationTest.php

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,10 @@
11
<?php namespace ParaTest\Runners\PHPUnit;
22

3+
use ParaTest\Console\Commands\ParaTestCommand;
4+
35
class RunnerIntegrationTest extends \TestBase
46
{
7+
/** @var Runner $runner */
58
protected $runner;
69
protected $options;
710

@@ -19,6 +22,9 @@ public function setUp()
1922
'coverage-php' => sys_get_temp_dir() . DS . 'testcoverage.php',
2023
'bootstrap' => BOOTSTRAP
2124
);
25+
if (ParaTestCommand::isWhitelistSupported()) {
26+
$this->options['whitelist'] = FIXTURES . DS . 'failing-tests';
27+
}
2228
$this->runner = new Runner($this->options);
2329
}
2430

test/functional/WrapperRunnerTest.php

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,9 @@ public function testRunningFewerTestsThanTheWorkersIsPossible()
4242

4343
public function testFatalErrorsAreReported()
4444
{
45+
if (PHP_VERSION_ID >= 70000) {
46+
$this->markTestSkipped('fatals are handled like normal exceptions with php7');
47+
}
4548
$proc = $this->invokeParatest('fatal-tests/UnitTestWithFatalFunctionErrorTest.php', array(
4649
'runner' => 'WrapperRunner',
4750
'processes' => 1,

test/unit/ParaTest/Console/Commands/ParaTestCommandTest.php

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ public function testConstructor()
2828
*/
2929
public function testConfiguredDefinitionWithPHPUnitTester()
3030
{
31-
$expected = new InputDefinition(array(
31+
$options = array(
3232
new InputOption('processes', 'p', InputOption::VALUE_REQUIRED, 'The number of test processes to run.', 5),
3333
new InputOption('functional', 'f', InputOption::VALUE_NONE, 'Run methods instead of suites in separate processes.'),
3434
new InputOption('help', 'h', InputOption::VALUE_NONE, 'Display this help message.'),
@@ -50,7 +50,11 @@ public function testConfiguredDefinitionWithPHPUnitTester()
5050
new InputOption('testsuite', null, InputOption::VALUE_OPTIONAL, 'Filter which testsuite to run'),
5151
new InputOption('max-batch-size', 'm', InputOption::VALUE_REQUIRED, 'Max batch size (only for functional mode).', 0),
5252
new InputOption('filter', null, InputOption::VALUE_REQUIRED, 'Filter (only for functional mode).'),
53-
));
53+
);
54+
if (ParaTestCommand::isWhitelistSupported()) {
55+
$options[] = new InputOption('whitelist', null, InputOption::VALUE_REQUIRED, 'Directory to add to the coverage whitelist.');
56+
}
57+
$expected = new InputDefinition($options);
5458
$definition = $this->command->getDefinition();
5559
$this->assertEquals($expected, $definition);
5660
}

test/unit/ParaTest/Coverage/CoverageMergerTest.php

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,15 +18,17 @@ public function testSimpleMerge()
1818
$firstFile = PARATEST_ROOT . '/src/ParaTest/Logging/LogInterpreter.php';
1919
$secondFile = PARATEST_ROOT . '/src/ParaTest/Logging/MetaProvider.php';
2020

21-
$coverage1 = new \PHP_CodeCoverage();
21+
$filter = new \PHP_CodeCoverage_Filter();
22+
$filter->addFilesToWhitelist([$firstFile, $secondFile]);
23+
$coverage1 = new \PHP_CodeCoverage(null, $filter);
2224
$coverage1->append(
2325
array(
2426
$firstFile => array(35 => 1),
2527
$secondFile => array(34 => 1)
2628
),
2729
'Test1'
2830
);
29-
$coverage2 = new \PHP_CodeCoverage();
31+
$coverage2 = new \PHP_CodeCoverage(null, $filter);
3032
$coverage2->append(
3133
array(
3234
$firstFile => array(35 => 1, 36 => 1)

0 commit comments

Comments
 (0)