Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Data Provider with \ at the end of the name breaks with process isolation #1337

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion src/Framework/TestCase.php
Original file line number Diff line number Diff line change
Expand Up @@ -631,11 +631,13 @@ public function run(PHPUnit_Framework_TestResult $result = null)
}

$data = var_export(serialize($this->data), true);
$dataName = var_export($this->dataName, true);
$dependencyInput = var_export(serialize($this->dependencyInput), true);
$includePath = var_export(get_include_path(), true);
// must do these fixes because TestCaseMethod.tpl has unserialize('{data}') in it, and we can't break BC
// the lines above used to use addcslashes() rather than var_export(), which breaks null byte escape sequences
$data = "'." . $data . ".'";
$dataName = "'.(" . $dataName . ").'";
$dependencyInput = "'." . $dependencyInput . ".'";
$includePath = "'." . $includePath . ".'";

Expand All @@ -648,7 +650,7 @@ public function run(PHPUnit_Framework_TestResult $result = null)
'methodName' => $this->name,
'collectCodeCoverageInformation' => $coverage,
'data' => $data,
'dataName' => $this->dataName,
'dataName' => $dataName,
'dependencyInput' => $dependencyInput,
'constants' => $constants,
'globals' => $globals,
Expand Down
21 changes: 21 additions & 0 deletions tests/Regression/GitHub/1337.phpt
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
--TEST--
GH-1300: Data Provider with \ at the end of the name breaks with process isolation
--FILE--
<?php

$_SERVER['argv'][1] = '--no-configuration';
$_SERVER['argv'][2] = '--process-isolation';
$_SERVER['argv'][3] = 'Issue1337Test';
$_SERVER['argv'][4] = dirname(__FILE__).'/1337/Issue1337Test.php';

require __DIR__ . '/../../bootstrap.php';
PHPUnit_TextUI_Command::main();
?>
--EXPECTF--
PHPUnit %s by Sebastian Bergmann.

..

Time: %s, Memory: %sMb

OK (2 tests, 2 assertions)
19 changes: 19 additions & 0 deletions tests/Regression/GitHub/1337/Issue1337Test.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
<?php
class Issue1337Test extends PHPUnit_Framework_TestCase
{
/**
* @dataProvider dataProvider
*/
public function testProvider($a)
{
$this->assertTrue($a);
}

public function dataProvider()
{
return array(
'c:\\'=>array(true),
0.9=>array(true)
);
}
}