Skip to content

Commit

Permalink
Make test to test abstract dataproviders and dataproviders in abstrac…
Browse files Browse the repository at this point in the history
…t classes
  • Loading branch information
wgevaert authored and sebastianbergmann committed Oct 7, 2019
1 parent de4c447 commit 516d288
Show file tree
Hide file tree
Showing 3 changed files with 87 additions and 4 deletions.
56 changes: 56 additions & 0 deletions tests/_files/AbstractVariousIterableDataProviderTest.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
<?php declare(strict_types=1);
/*
* This file is part of PHPUnit.
*
* (c) Sebastian Bergmann <[email protected]>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
abstract class AbstractVariousIterableDataProviderTest
{
abstract public function asArrayProvider();

abstract public function asIteratorProvider();

abstract public function asTraversableProvider();

public function asArrayProviderInParent()
{
return [
['J'],
['K'],
['L'],
];
}

public function asIteratorProviderInParent()
{
yield ['M'];

yield ['N'];

yield ['O'];
}

public function asTraversableProviderInParent()
{
return new WrapperIteratorAggregate([
['P'],
['Q'],
['R'],
]);
}

/**
* @dataProvider asArrayProvider
* @dataProvider asIteratorProvider
* @dataProvider asTraversableProvider
* @dataProvider asArrayProviderInParent
* @dataProvider asIteratorProviderInParent
* @dataProvider asTraversableProviderInParent
*/
public function testAbstract(): void
{
}
}
8 changes: 4 additions & 4 deletions tests/_files/VariousIterableDataProviderTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,9 @@
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
class VariousIterableDataProviderTest
class VariousIterableDataProviderTest extends AbstractVariousIterableDataProviderTest
{
public static function asArrayProvider()
public function asArrayProvider()
{
return [
['A'],
Expand All @@ -18,7 +18,7 @@ public static function asArrayProvider()
];
}

public static function asIteratorProvider()
public function asIteratorProvider()
{
yield ['D'];

Expand All @@ -27,7 +27,7 @@ public static function asIteratorProvider()
yield ['F'];
}

public static function asTraversableProvider()
public function asTraversableProvider()
{
return new WrapperIteratorAggregate([
['G'],
Expand Down
27 changes: 27 additions & 0 deletions tests/unit/Util/TestTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -911,6 +911,33 @@ public function testMultipleYieldIteratorDataProviders(): void
$this->assertEquals(3, $cCount);
}

public function testWithAbstractVariousIterableDataProviders(): void
{
$dataSets = Test::getProvidedData(\VariousIterableDataProviderTest::class, 'testAbstract');

$this->assertEquals([
['A'],
['B'],
['C'],
['D'],
['E'],
['F'],
['G'],
['H'],
['I'],
['J'],
['K'],
['L'],
['M'],
['N'],
['O'],
['P'],
['Q'],
['R'],

], $dataSets);
}

public function testWithVariousIterableDataProviders(): void
{
$dataSets = Test::getProvidedData(\VariousIterableDataProviderTest::class, 'test');
Expand Down

0 comments on commit 516d288

Please sign in to comment.