Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

- Merge [4698], [4699], and [4700].

  • Loading branch information...
commit 9a50b27b455f31e83196d365a27573a7705a151e 1 parent 073a305
@sebastianbergmann authored
View
5 PHPUnit/Extensions/OutputTestCase.php
@@ -159,16 +159,15 @@ public function expectOutputString($expectedString)
}
/**
- * @param array $dependencyInput
* @return mixed
* @throws RuntimeException
*/
- protected function runTest(array $dependencyInput = array())
+ protected function runTest()
{
ob_start();
try {
- $testResult = parent::runTest($dependencyInput);
+ $testResult = parent::runTest();
}
catch (Exception $e) {
View
5 PHPUnit/Extensions/PerformanceTestCase.php
@@ -71,14 +71,13 @@
protected $maxRunningTime = 0;
/**
- * @param array $dependencyInput
* @return mixed
* @throws RuntimeException
*/
- protected function runTest(array $dependencyInput = array())
+ protected function runTest()
{
PHPUnit_Util_Timer::start();
- $testResult = parent::runTest($dependencyInput);
+ $testResult = parent::runTest();
$time = PHPUnit_Util_Timer::stop();
if ($this->maxRunningTime != 0 &&
View
5 PHPUnit/Extensions/SeleniumTestCase.php
@@ -372,16 +372,15 @@ protected function getDriver(array $browser)
}
/**
- * @param array $dependencyInput
* @throws RuntimeException
*/
- protected function runTest(array $dependencyInput = array())
+ protected function runTest()
{
$this->start();
try {
if (!is_file($this->name)) {
- parent::runTest($dependencyInput);
+ parent::runTest();
} else {
$this->runSelenese($this->name);
}
View
5 PHPUnit/Extensions/Story/SeleniumTestCase.php
@@ -161,17 +161,16 @@ protected function _and($contextOrOutcome)
/**
* Run this test's scenario.
*
- * @param array $dependencyInput
* @return mixed
* @throws RuntimeException
*/
- protected function runTest(array $dependencyInput = array())
+ protected function runTest()
{
$autostop = $this->autoStop;
$this->autoStop = FALSE;
try {
- $testResult = parent::runTest($dependencyInput);
+ $testResult = parent::runTest();
$this->scenario->run($this->world);
$this->autoStop = $autostop;
}
View
5 PHPUnit/Extensions/Story/TestCase.php
@@ -179,13 +179,12 @@ protected function _and($contextOrOutcome)
/**
* Run this test's scenario.
*
- * @param array $dependencyInput
* @return mixed
* @throws RuntimeException
*/
- protected function runTest(array $dependencyInput = array())
+ protected function runTest()
{
- $testResult = parent::runTest($dependencyInput);
+ $testResult = parent::runTest();
$this->scenario->run($this->world);
return $testResult;
}
View
7 PHPUnit/Framework/Process/TestCaseMethod.tpl.dist
@@ -5,11 +5,16 @@ function __phpunit_run_isolated_test()
$result->collectRawCodeCoverageInformation({collectCodeCoverageInformation});
$test = new {className}('{methodName}', unserialize('{data}'), '{dataName}');
+ $test->setDependencyInput(unserialize('{dependencyInput}'));
$test->setInIsolation(TRUE);
$test->run($result);
print serialize(
- array('numAssertions' => $test->getNumAssertions(), 'result' => $result)
+ array(
+ 'testResult' => $test->getResult(),
+ 'numAssertions' => $test->getNumAssertions(),
+ 'result' => $result
+ )
);
}
View
78 PHPUnit/Framework/TestCase.php
@@ -231,6 +231,11 @@
protected $dependencies = array();
/**
+ * @var array
+ */
+ protected $dependencyInput = array();
+
+ /**
* @var string
*/
protected $exceptionMessage = NULL;
@@ -541,6 +546,34 @@ public function run(PHPUnit_Framework_TestResult $result = NULL)
$this->result = $result;
+ if (!empty($this->dependencies) && !$this->inIsolation) {
+ $className = get_class($this);
+ $passed = $this->result->passed();
+ $passedKeys = array_keys($passed);
+
+ foreach ($this->dependencies as $dependency) {
+ if (strpos($dependency, '::') === FALSE) {
+ $dependency = $className . '::' . $dependency;
+ }
+
+ if (!in_array($dependency, $passedKeys)) {
+ $result->addError(
+ $this,
+ new PHPUnit_Framework_SkippedTestError(
+ sprintf(
+ 'This test depends on "%s" to pass.', $dependency
+ )
+ ),
+ 0
+ );
+
+ return;
+ } else {
+ $this->dependencyInput[] = $passed[$dependency];
+ }
+ }
+ }
+
if ($this->runTestInSeparateProcess === TRUE &&
$this->inIsolation !== TRUE &&
!$this instanceof PHPUnit_Extensions_SeleniumTestCase &&
@@ -565,6 +598,7 @@ public function run(PHPUnit_Framework_TestResult $result = NULL)
'className' => $class->getName(),
'methodName' => $this->name,
'data' => addcslashes(serialize($this->data), "'"),
+ 'dependencyInput' => addcslashes(serialize($this->dependencyInput), "'"),
'dataName' => $this->dataName,
'collectCodeCoverageInformation' => $collectCodeCoverageInformation ? 'TRUE' : 'FALSE',
'globals' => $this->getGlobalsAsString(),
@@ -584,6 +618,7 @@ public function run(PHPUnit_Framework_TestResult $result = NULL)
$childResult = @unserialize($jobResult['stdout']);
if ($childResult !== FALSE) {
+ $this->testResult = $childResult['testResult'];
$this->numAssertions = $childResult['numAssertions'];
$childResult = $childResult['result'];
@@ -641,33 +676,8 @@ public function run(PHPUnit_Framework_TestResult $result = NULL)
*/
public function runBare()
{
- $dependencyInput = array();
$this->numAssertions = 0;
- if (!empty($this->dependencies)) {
- $className = get_class($this);
- $passed = $this->result->passed();
- $passedKeys = array_keys($passed);
-
- foreach ($this->dependencies as $dependency) {
- if (strpos($dependency, '::') === FALSE) {
- $dependency = $className . '::' . $dependency;
- }
-
- if (!in_array($dependency, $passedKeys)) {
- $this->markTestSkipped(
- sprintf(
- 'This test depends on "%s" to pass.',
-
- $dependency
- )
- );
- } else {
- $dependencyInput[] = $passed[$dependency];
- }
- }
- }
-
// Backup the $GLOBALS array and static attributes.
if ($this->runTestInSeparateProcess !== TRUE && $this->inIsolation !== TRUE) {
if ($this->backupGlobals === NULL || $this->backupGlobals === TRUE) {
@@ -696,7 +706,7 @@ public function runBare()
// Assert pre-conditions.
$this->assertPreConditions();
- $this->testResult = $this->runTest($dependencyInput);
+ $this->testResult = $this->runTest();
// Assert post-conditions.
$this->assertPostConditions();
@@ -772,11 +782,10 @@ public function runBare()
/**
* Override to run the test and assert its state.
*
- * @param array $dependencyInput
* @return mixed
* @throws RuntimeException
*/
- protected function runTest(array $dependencyInput = array())
+ protected function runTest()
{
if ($this->name === NULL) {
throw new RuntimeException(
@@ -795,7 +804,7 @@ protected function runTest(array $dependencyInput = array())
try {
if (empty($this->data)) {
- $testResult = $method->invokeArgs($this, $dependencyInput);
+ $testResult = $method->invokeArgs($this, $this->dependencyInput);
} else {
$testResult = $method->invokeArgs($this, $this->data);
}
@@ -859,6 +868,17 @@ public function setDependencies(array $dependencies)
}
/**
+ * Sets
+ *
+ * @param array $dependencyInput
+ * @since Method available since Release 3.4.0
+ */
+ public function setDependencyInput(array $dependencyInput)
+ {
+ $this->dependencyInput = $dependencyInput;
+ }
+
+ /**
* Calling this method in setUp() has no effect!
*
* @param boolean $backupGlobals
View
3  PHPUnit/Framework/Warning.php
@@ -80,10 +80,9 @@ public function __construct($message = '')
}
/**
- * @param array $dependencyInput
* @throws RuntimeException
*/
- protected function runTest(array $dependencyInput = array())
+ protected function runTest()
{
$this->fail($this->message);
}
View
2  PHPUnit/Tests/TextUI/dataset-log-xml-isolation.phpt
@@ -26,7 +26,6 @@ PHPUnit %s by Sebastian Bergmann.
Failed asserting that <integer:2> matches expected <integer:3>.
%s:%i
-%s:%i
</failure>
</testcase>
<testcase name="testAdd with data set #3" assertions="1" time="%f"/>
@@ -42,7 +41,6 @@ There was 1 failure:
1) testAdd(DataSetTest) with data set #2 (1, 1, 3)
Failed asserting that <integer:2> matches expected <integer:3>.
%s:%i
-%s:%i
FAILURES!
Tests: 4, Assertions: 4, Failures: 1.
View
4 PHPUnit/Tests/TextUI/dependencies-isolation.phpt
@@ -21,7 +21,7 @@ Test Dependencies
DependencyFailureTest
FSS
-Time: %d seconds
+Time: %i seconds
There was 1 failure:
@@ -39,4 +39,4 @@ This test depends on "DependencyFailureTest::testTwo" to pass.
%s:%i
FAILURES!
-Tests: 6, Assertions: 0, Failures: 1, Skipped: 2.
+Tests: 4, Assertions: 0, Failures: 1, Skipped: 2.
View
5 PHPUnit/Tests/TextUI/dependencies.phpt
@@ -20,12 +20,13 @@ Test Dependencies
DependencyFailureTest
FSS
-Time: %d seconds
+Time: %i seconds
There was 1 failure:
1) testOne(DependencyFailureTest)
%s:%i
+%s:%i
There were 2 skipped tests:
@@ -38,4 +39,4 @@ This test depends on "DependencyFailureTest::testTwo" to pass.
%s:%i
FAILURES!
-Tests: 6, Assertions: 0, Failures: 1, Skipped: 2.
+Tests: 4, Assertions: 0, Failures: 1, Skipped: 2.
View
0  ...Tests/TextUI/dependencies-isolation2.phpt → ...Tests/TextUI/dependencies2-isolation.phpt
File renamed without changes
View
9 PHPUnit/Tests/TextUI/failure-isolation.phpt
@@ -31,12 +31,10 @@ Failed asserting that two arrays are equal.
)
%s:%i
-%s:%i
2) testAssertIntegerEqualsInteger(FailureTest)
Failed asserting that <integer:2> matches expected <integer:1>.
%s:%i
-%s:%i
3) testAssertObjectEqualsObject(FailureTest)
Failed asserting that two objects are equal.
@@ -50,12 +48,10 @@ Failed asserting that two objects are equal.
)
%s:%i
-%s:%i
4) testAssertNullEqualsString(FailureTest)
Failed asserting that <string:bar> matches expected <null>.
%s:%i
-%s:%i
5) testAssertStringEqualsString(FailureTest)
Failed asserting that two strings are equal.
@@ -63,7 +59,6 @@ expected string <foo>
difference <xxx>
got string <bar>
%s:%i
-%s:%i
6) testAssertTextEqualsText(FailureTest)
Failed asserting that two strings are equal.
@@ -75,24 +70,20 @@ Failed asserting that two strings are equal.
+baz
%s:%i
-%s:%i
7) testAssertTextSameText(FailureTest)
expected string <foo>
difference <xxx>
got string <bar>
%s:%i
-%s:%i
8) testAssertObjectSameObject(FailureTest)
Failed asserting that two variables reference the same object.
%s:%i
-%s:%i
9) testAssertObjectSameNull(FailureTest)
<null> does not match expected type "object".
%s:%i
-%s:%i
FAILURES!
Tests: 9, Assertions: 9, Failures: 9.
View
18 PHPUnit/Tests/TextUI/failure-verbose-isolation.phpt
@@ -33,8 +33,6 @@ Failed asserting that two arrays are equal.
)
%s:%i
-%s:%i
-%s:%i
2) testAssertIntegerEqualsInteger(FailureTest)
Failed asserting that <integer:2> matches expected <integer:1>.
@@ -42,8 +40,6 @@ expected integer <1>
difference <1>
got integer <2>
%s:%i
-%s:%i
-%s:%i
3) testAssertObjectEqualsObject(FailureTest)
Failed asserting that two objects are equal.
@@ -57,15 +53,11 @@ Failed asserting that two objects are equal.
)
%s:%i
-%s:%i
-%s:%i
4) testAssertNullEqualsString(FailureTest)
Failed asserting that <string:bar> matches expected <null>.
%s:%i
-%s:%i
-%s:%i
5) testAssertStringEqualsString(FailureTest)
Failed asserting that two strings are equal.
@@ -73,8 +65,6 @@ expected string <foo>
difference <xxx>
got string <bar>
%s:%i
-%s:%i
-%s:%i
6) testAssertTextEqualsText(FailureTest)
Failed asserting that two strings are equal.
@@ -86,28 +76,20 @@ Failed asserting that two strings are equal.
+baz
%s:%i
-%s:%i
-%s:%i
7) testAssertTextSameText(FailureTest)
expected string <foo>
difference <xxx>
got string <bar>
%s:%i
-%s:%i
-%s:%i
8) testAssertObjectSameObject(FailureTest)
Failed asserting that two variables reference the same object.
%s:%i
-%s:%i
-%s:%i
9) testAssertObjectSameNull(FailureTest)
<null> does not match expected type "object".
%s:%i
-%s:%i
-%s:%i
FAILURES!
Tests: 9, Assertions: 9, Failures: 9.
View
2  PHPUnit/Tests/_files/Error.php
@@ -1,7 +1,7 @@
<?php
class Error extends PHPUnit_Framework_TestCase
{
- protected function runTest(array $dependencyInput = array())
+ protected function runTest()
{
throw new Exception;
}
View
2  PHPUnit/Tests/_files/Failure.php
@@ -1,7 +1,7 @@
<?php
class Failure extends PHPUnit_Framework_TestCase
{
- protected function runTest(array $dependencyInput = array())
+ protected function runTest()
{
$this->fail();
}
View
2  PHPUnit/Tests/_files/Success.php
@@ -1,7 +1,7 @@
<?php
class Success extends PHPUnit_Framework_TestCase
{
- protected function runTest(array $dependencyInput = array())
+ protected function runTest()
{
}
}
View
2  PHPUnit/Tests/_files/TornDown.php
@@ -8,7 +8,7 @@ protected function tearDown()
$this->tornDown = TRUE;
}
- protected function runTest(array $dependencyInput = array())
+ protected function runTest()
{
throw new Exception;
}
View
2  PHPUnit/Tests/_files/TornDown2.php
@@ -9,7 +9,7 @@ protected function tearDown()
throw new Exception;
}
- protected function runTest(array $dependencyInput = array())
+ protected function runTest()
{
throw new Exception;
}
View
2  PHPUnit/Tests/_files/WasRun.php
@@ -3,7 +3,7 @@ class WasRun extends PHPUnit_Framework_TestCase
{
public $wasRun = FALSE;
- protected function runTest(array $dependencyInput = array())
+ protected function runTest()
{
$this->wasRun = TRUE;
}
View
2  PHPUnit/Util/Filter.php
@@ -411,7 +411,7 @@ public static function getFilteredStacktrace(Exception $e, $filterTests = TRUE,
}
foreach ($eTrace as $frame) {
- if (!self::$filter || (isset($frame['file']) && !self::isFiltered($frame['file'], $filterTests, TRUE))) {
+ if (!self::$filter || (isset($frame['file']) && is_file($frame['file']) && !self::isFiltered($frame['file'], $filterTests, TRUE))) {
if ($asString === TRUE) {
$filteredStacktrace .= sprintf(
"%s:%s\n",
View
2  package.xml
@@ -884,8 +884,8 @@
<file baseinstalldir="/" name="debug.phpt" role="test" />
<file baseinstalldir="/" name="default-isolation.phpt" role="test" />
<file baseinstalldir="/" name="default.phpt" role="test" />
+ <file baseinstalldir="/" name="dependencies2-isolation.phpt" role="test" />
<file baseinstalldir="/" name="dependencies2.phpt" role="test" />
- <file baseinstalldir="/" name="dependencies-isolation2.phpt" role="test" />
<file baseinstalldir="/" name="dependencies-isolation.phpt" role="test" />
<file baseinstalldir="/" name="dependencies.phpt" role="test" />
<file baseinstalldir="/" name="exclude-group-isolation.phpt" role="test" />
Please sign in to comment.
Something went wrong with that request. Please try again.