Skip to content

Commit

Permalink
Add test for order of arguments with both depends and dataprovider
Browse files Browse the repository at this point in the history
  • Loading branch information
jnoordsij committed Feb 20, 2023
1 parent d7eeec1 commit ac028c8
Show file tree
Hide file tree
Showing 2 changed files with 61 additions and 0 deletions.
41 changes: 41 additions & 0 deletions tests/_files/DataProviderDependencyResultTest.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
<?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 PHPUnit\TestFixture;

use PHPUnit\Framework\Attributes\DataProvider;
use PHPUnit\Framework\Attributes\Depends;
use PHPUnit\Framework\TestCase;

class DataProviderDependencyResultTest extends TestCase
{
public static function providerMethod()
{
return [
[0, 2],
[1, 1],
];
}

#[DataProvider('providerMethod')]
#[Depends('testDependency')]
public function testAdd($a, $b, $c): void
{
$this->assertSame(2, $c);
$this->assertSame($c, $a + $b);
}

public function testDependency()
{
$a = 2;
$this->assertSame(2, $a);

return $a;
}
}
20 changes: 20 additions & 0 deletions tests/end-to-end/generic/dataprovider-dependency-result.phpt
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
--TEST--
phpunit ../../_files/DataProviderDependencyResultTest.php
--FILE--
<?php declare(strict_types=1);
$_SERVER['argv'][] = '--do-not-cache-result';
$_SERVER['argv'][] = '--no-configuration';
$_SERVER['argv'][] = __DIR__ . '/../../_files/DataProviderDependencyResultTest.php';

require_once __DIR__ . '/../../bootstrap.php';
(new PHPUnit\TextUI\Application)->run($_SERVER['argv']);
--EXPECTF--
PHPUnit %s by Sebastian Bergmann and contributors.

Runtime: %s

... 3 / 3 (100%)

Time: %s, Memory: %s

OK (3 tests, 5 assertions)

0 comments on commit ac028c8

Please sign in to comment.