Skip to content

Commit

Permalink
Closes #3379
Browse files Browse the repository at this point in the history
  • Loading branch information
sebastianbergmann committed Nov 3, 2018
1 parent ef4c1be commit a7d935d
Show file tree
Hide file tree
Showing 6 changed files with 98 additions and 0 deletions.
7 changes: 7 additions & 0 deletions ChangeLog-7.4.md
Expand Up @@ -2,6 +2,12 @@

All notable changes of the PHPUnit 7.4 release series are documented in this file using the [Keep a CHANGELOG](http://keepachangelog.com/) principles.

## [7.4.4] - 2018-MM-DD

### Fixed

* Fixed [#3379](https://github.com/sebastianbergmann/phpunit/issues/3379): Dependent test of skipped test has status `-1`

## [7.4.3] - 2018-10-23

### Changed
Expand Down Expand Up @@ -31,6 +37,7 @@ All notable changes of the PHPUnit 7.4 release series are documented in this fil
* Implemented [#3284](https://github.com/sebastianbergmann/phpunit/issues/3284): Ability to reorder tests based on execution time
* Implemented [#3290](https://github.com/sebastianbergmann/phpunit/issues/3290): Ability to load a PHP script before any code of PHPUnit itself is loaded

[7.4.4]: https://github.com/sebastianbergmann/phpunit/compare/7.4.3...7.4.4
[7.4.3]: https://github.com/sebastianbergmann/phpunit/compare/7.4.2...7.4.3
[7.4.2]: https://github.com/sebastianbergmann/phpunit/compare/7.4.1...7.4.2
[7.4.1]: https://github.com/sebastianbergmann/phpunit/compare/7.4.0...7.4.1
Expand Down
4 changes: 4 additions & 0 deletions src/Framework/TestCase.php
Expand Up @@ -1720,7 +1720,10 @@ private function handleDependencies(): bool
}

if (!isset($passedKeys[$dependency])) {
$this->status = BaseTestRunner::STATUS_SKIPPED;

$this->result->startTest($this);

$this->result->addError(
$this,
new SkippedTestError(
Expand All @@ -1731,6 +1734,7 @@ private function handleDependencies(): bool
),
0
);

$this->result->endTest($this, 0);

return false;
Expand Down
20 changes: 20 additions & 0 deletions tests/end-to-end/regression/GitHub/3379.phpt
@@ -0,0 +1,20 @@
--TEST--
GH-3379: Dependent test of skipped test has status -1
--FILE--
<?php
$_SERVER['argv'][1] = '--configuration';
$_SERVER['argv'][2] = __DIR__ . '/3379/';

require __DIR__ . '/../../../bootstrap.php';
PHPUnit\TextUI\Command::main();
--EXPECTF--
PHPUnit %s by Sebastian Bergmann and contributors.

Skipped test testOne, status: 1
SSkipped test testTwo, status: 1
S 2 / 2 (100%)

Time: %s, Memory: %s

OK, but incomplete, skipped, or risky tests!
Tests: 2, Assertions: 0, Skipped: 2.
28 changes: 28 additions & 0 deletions tests/end-to-end/regression/GitHub/3379/Issue3379Test.php
@@ -0,0 +1,28 @@
<?php declare(strict_types=1);
/*
* This file is part of PHPUnit.
*
* (c) Sebastian Bergmann <sebastian@phpunit.de>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
namespace Test;

use PHPUnit\Framework\TestCase;

class Issue3379Test extends TestCase
{
public function testOne(): void
{
$this->markTestSkipped();
}

/**
* @depends testOne
*/
public function testTwo(): void
{
$this->assertTrue(true);
}
}
26 changes: 26 additions & 0 deletions tests/end-to-end/regression/GitHub/3379/Issue3379TestListener.php
@@ -0,0 +1,26 @@
<?php declare(strict_types=1);
/*
* This file is part of PHPUnit.
*
* (c) Sebastian Bergmann <sebastian@phpunit.de>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/

use PHPUnit\Framework\Test;
use PHPUnit\Framework\TestCase;
use PHPUnit\Framework\TestListener;
use PHPUnit\Framework\TestListenerDefaultImplementation;

class Issue3379TestListener implements TestListener
{
use TestListenerDefaultImplementation;

public function addSkippedTest(Test $test, \Throwable $t, float $time): void
{
if ($test instanceof TestCase) {
print 'Skipped test ' . $test->getName() . ', status: ' . $test->getStatus() . \PHP_EOL;
}
}
}
13 changes: 13 additions & 0 deletions tests/end-to-end/regression/GitHub/3379/phpunit.xml
@@ -0,0 +1,13 @@
<?xml version="1.0" encoding="UTF-8"?>
<phpunit xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:noNamespaceSchemaLocation="https://schema.phpunit.de/7.4/phpunit.xsd">
<testsuites>
<testsuite name="default">
<directory suffix="Test.php">.</directory>
</testsuite>
</testsuites>

<listeners>
<listener class="Issue3379TestListener" file="./Issue3379TestListener.php"/>
</listeners>
</phpunit>

0 comments on commit a7d935d

Please sign in to comment.