Skip to content

Commit

Permalink
Merge branch '6.4'
Browse files Browse the repository at this point in the history
  • Loading branch information
sebastianbergmann committed Nov 10, 2017
2 parents da2da40 + 0a858ae commit 82ef0b2
Show file tree
Hide file tree
Showing 6 changed files with 79 additions and 2 deletions.
7 changes: 7 additions & 0 deletions ChangeLog-5.7.md
Expand Up @@ -2,6 +2,12 @@

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

## [5.7.24] - 2017-MM-DD

### Fixed

* Fixed [#2833](https://github.com/sebastianbergmann/phpunit/issues/2833): Test class loaded during data provider execution is not discovered

## [5.7.23] - 2017-10-15

### Fixed
Expand Down Expand Up @@ -183,6 +189,7 @@ All notable changes of the PHPUnit 5.7 release series are documented in this fil
* The `--tap` and `--log-tap` commandline options have been deprecated
* The `--self-update` and `--self-upgrade` commandline options have been deprecated (PHAR binary only)

[5.7.24]: https://github.com/sebastianbergmann/phpunit/compare/5.7.23...5.7.24
[5.7.23]: https://github.com/sebastianbergmann/phpunit/compare/5.7.22...5.7.23
[5.7.22]: https://github.com/sebastianbergmann/phpunit/compare/5.7.21...5.7.22
[5.7.21]: https://github.com/sebastianbergmann/phpunit/compare/5.7.20...5.7.21
Expand Down
7 changes: 7 additions & 0 deletions ChangeLog-6.4.md
Expand Up @@ -2,6 +2,12 @@

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

## [6.4.5] - 2017-MM-DD

### Fixed

* Fixed [#2833](https://github.com/sebastianbergmann/phpunit/issues/2833): Test class loaded during data provider execution is not discovered

## [6.4.4] - 2017-11-08

### Fixed
Expand Down Expand Up @@ -51,6 +57,7 @@ All notable changes of the PHPUnit 6.4 release series are documented in this fil

* Fixed [#2750](https://github.com/sebastianbergmann/phpunit/issues/2750): Useless call to `array_map()`

[6.4.5]: https://github.com/sebastianbergmann/phpunit/compare/6.4.4...6.4.5
[6.4.4]: https://github.com/sebastianbergmann/phpunit/compare/6.4.3...6.4.4
[6.4.3]: https://github.com/sebastianbergmann/phpunit/compare/6.4.2...6.4.3
[6.4.2]: https://github.com/sebastianbergmann/phpunit/compare/6.4.1...6.4.2
Expand Down
12 changes: 10 additions & 2 deletions src/Framework/TestSuite.php
Expand Up @@ -99,6 +99,11 @@ class TestSuite implements Test, SelfDescribing, IteratorAggregate
*/
private $iteratorFilter;

/**
* @var array
*/
private $declaredClasses;

/**
* Constructs a new TestSuite:
*
Expand All @@ -123,6 +128,8 @@ class TestSuite implements Test, SelfDescribing, IteratorAggregate
*/
public function __construct($theClass = '', $name = '')
{
$this->declaredClasses = \get_declared_classes();

$argumentsValid = false;

if (\is_object($theClass) &&
Expand Down Expand Up @@ -317,7 +324,7 @@ public function addTestFile($filename)
// test class itself. Figure out the actual test class.
$classes = \get_declared_classes();
$filename = Fileloader::checkAndLoad($filename);
$newClasses = \array_diff(\get_declared_classes(), $classes);
$newClasses = \array_diff(\get_declared_classes(), $this->declaredClasses);

// The diff is empty in case a parent class (with test methods) is added
// AFTER a child class that inherited from it. To account for that case,
Expand All @@ -327,7 +334,8 @@ public function addTestFile($filename)
// On the assumption that test classes are defined first in files,
// process discovered classes in approximate LIFO order, so as to
// avoid unnecessary reflection.
$this->foundClasses = \array_merge($newClasses, $this->foundClasses);
$this->foundClasses = \array_merge($newClasses, $this->foundClasses);
$this->declaredClasses = \get_declared_classes();
}

// The test class's name must match the filename, either in full, or as
Expand Down
17 changes: 17 additions & 0 deletions tests/TextUI/dataprovider-pair.phpt
@@ -0,0 +1,17 @@
--TEST--
phpunit ../_files/DataProviderPair
--FILE--
<?php
$_SERVER['argv'][1] = '--no-configuration';
$_SERVER['argv'][2] = __DIR__ . '/../_files/DataProviderPair';

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

.. 2 / 2 (100%)

Time: %s, Memory: %s

OK (2 tests, 2 assertions)
23 changes: 23 additions & 0 deletions tests/_files/DataProviderPair/FirstTest.php
@@ -0,0 +1,23 @@
<?php

namespace Foo;

use PHPUnit\Framework\TestCase;

class FirstTest extends TestCase
{
/**
* @dataProvider provide
*/
public function testFirst($x)
{
$this->assertTrue(true);
}

public function provide()
{
SecondTest::DUMMY;

return [[true]];
}
}
15 changes: 15 additions & 0 deletions tests/_files/DataProviderPair/SecondTest.php
@@ -0,0 +1,15 @@
<?php

namespace Foo;

use PHPUnit\Framework\TestCase;

class SecondTest extends TestCase
{
const DUMMY = 'dummy';

public function testSecond()
{
$this->assertTrue(true);
}
}

0 comments on commit 82ef0b2

Please sign in to comment.