Skip to content

Commit

Permalink
Add test for sebastianbergmann#2861
Browse files Browse the repository at this point in the history
  • Loading branch information
SimonHeimberg committed Dec 5, 2017
1 parent 150bb82 commit e50d3b4
Show file tree
Hide file tree
Showing 2 changed files with 93 additions and 0 deletions.
39 changes: 39 additions & 0 deletions tests/Regression/GitHub/2861-data-provider-keys.phpt
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
--TEST--
GH-2861: test names show numeric datasource only for iterators as dataprovider
GH-2639: Second `yield from` is not called from a data provider
--FILE--
<?php
$_SERVER['argv'][1] = '--no-configuration';
$_SERVER['argv'][1] = '--debug';
$_SERVER['argv'][2] = 'Issue2861Test';
$_SERVER['argv'][3] = __DIR__ . '/2861/Issue2861Test.php';

require __DIR__ . '/../../bootstrap.php';

PHPUnit\TextUI\Command::main();
?>
--EXPECTF--
PHPUnit %s by Sebastian Bergmann and contributors.

Runtime:%s
Configuration: %s

Test 'Issue2861Test::testArrayProvider with data set "xyx" (11, 111)' started
%s
Test 'Issue2861Test::testIteratorProvider with data set "bla" (1, 11)' started
%s
Test 'Issue2861Test::testMultipleIteratorProviders with data set "bla" (1, 11)' started
%s
Test 'Issue2861Test::testMultipleIteratorProviders with data set #0 (22, 2)' started
%s
Test 'Issue2861Test::testMultipleIteratorProviders with data set "xyx" (11, 111)' started
%s
Test 'Issue2861Test::testMultipleIteratorProviders with data set #1 (23, 31)' started
%s
Test 'Issue2861Test::testMultipleIteratorProviders with data set #2 (24, 44)' started
%s


Time: %s, Memory: %s

OK (7 tests, 7 assertions)
54 changes: 54 additions & 0 deletions tests/Regression/GitHub/2861/Issue2861Test.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
<?php

use PHPUnit\Framework\TestCase;

class Issue2861Test extends TestCase
{
/**
* @dataProvider arrayProvider
*/
public function testArrayProvider()
{
// shows key as datasource
$this->assertTrue(true);
}

/**
* @dataProvider iteratorProvider
*/
public function testIteratorProvider()
{
// shows numeric datasource
$this->assertTrue(true);
}

/**
* @dataProvider multipleIteratorProvider
*/
public function testMultipleIteratorProviders()
{
// shows mixed datasource
$this->assertTrue(true);
}

public static function arrayProvider()
{
return array(
'xyx' => array(11,111),
);
}

public static function iteratorProvider()
{
yield 'bla' => array(1, 11);
}

public static function multipleIteratorProvider()
{
yield from self::iteratorProvider();
yield array(22, 2);
yield from self::arrayProvider();
yield from array(array(23, 31), array(24, 44));
}

}

0 comments on commit e50d3b4

Please sign in to comment.