-
-
Notifications
You must be signed in to change notification settings - Fork 2.2k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Deprecate invalid named arguments in data providers
- Loading branch information
1 parent
d2f7eb2
commit 646a15b
Showing
3 changed files
with
121 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
31 changes: 31 additions & 0 deletions
31
tests/end-to-end/event/_files/InvalidParameterNameDataProviderTest.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
<?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. | ||
*/ | ||
namespace PHPUnit\TestFixture\Event; | ||
|
||
use PHPUnit\Framework\Attributes\DataProvider; | ||
use PHPUnit\Framework\TestCase; | ||
|
||
final class InvalidParameterNameDataProviderTest extends TestCase | ||
{ | ||
public static function values(): array | ||
{ | ||
return [ | ||
['value1' => true, 'value2' => true], | ||
['value3' => true, 'value4' => true], | ||
]; | ||
} | ||
|
||
#[DataProvider('values')] | ||
public function testSuccess(bool $value1, bool $value2): void | ||
{ | ||
$this->assertTrue($value1); | ||
$this->assertTrue($value2); | ||
} | ||
} |
54 changes: 54 additions & 0 deletions
54
tests/end-to-end/event/data-provider-invalid-argument-name.phpt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
--TEST-- | ||
The right events are emitted in the right order for a test that uses a data provider that is not static | ||
--FILE-- | ||
<?php declare(strict_types=1); | ||
$traceFile = tempnam(sys_get_temp_dir(), __FILE__); | ||
|
||
$_SERVER['argv'][] = '--do-not-cache-result'; | ||
$_SERVER['argv'][] = '--no-configuration'; | ||
$_SERVER['argv'][] = '--no-output'; | ||
$_SERVER['argv'][] = '--log-events-text'; | ||
$_SERVER['argv'][] = $traceFile; | ||
$_SERVER['argv'][] = __DIR__ . '/_files/InvalidParameterNameDataProviderTest.php'; | ||
|
||
require __DIR__ . '/../../bootstrap.php'; | ||
|
||
(new PHPUnit\TextUI\Application)->run($_SERVER['argv']); | ||
|
||
print file_get_contents($traceFile); | ||
|
||
unlink($traceFile); | ||
--EXPECTF-- | ||
PHPUnit Started (PHPUnit %s using %s) | ||
Test Runner Configured | ||
Data Provider Method Called (PHPUnit\TestFixture\Event\InvalidParameterNameDataProviderTest::values for test method PHPUnit\TestFixture\Event\InvalidParameterNameDataProviderTest::testSuccess) | ||
Data Provider Method Finished for PHPUnit\TestFixture\Event\InvalidParameterNameDataProviderTest::testSuccess: | ||
- PHPUnit\TestFixture\Event\InvalidParameterNameDataProviderTest::values | ||
Test Triggered PHPUnit Deprecation (PHPUnit\TestFixture\Event\InvalidParameterNameDataProviderTest::testSuccess#1) | ||
Providing invalid named argument $value3 for method PHPUnit\TestFixture\Event\InvalidParameterNameDataProviderTest::testSuccess() is deprecated and will not be supported in PHPUnit 11.0. | ||
Test Triggered PHPUnit Deprecation (PHPUnit\TestFixture\Event\InvalidParameterNameDataProviderTest::testSuccess#1) | ||
Providing invalid named argument $value4 for method PHPUnit\TestFixture\Event\InvalidParameterNameDataProviderTest::testSuccess() is deprecated and will not be supported in PHPUnit 11.0. | ||
Test Suite Loaded (2 tests) | ||
Event Facade Sealed | ||
Test Runner Started | ||
Test Suite Sorted | ||
Test Runner Execution Started (2 tests) | ||
Test Suite Started (PHPUnit\TestFixture\Event\InvalidParameterNameDataProviderTest, 2 tests) | ||
Test Suite Started (PHPUnit\TestFixture\Event\InvalidParameterNameDataProviderTest::testSuccess, 2 tests) | ||
Test Preparation Started (PHPUnit\TestFixture\Event\InvalidParameterNameDataProviderTest::testSuccess#0) | ||
Test Prepared (PHPUnit\TestFixture\Event\InvalidParameterNameDataProviderTest::testSuccess#0) | ||
Assertion Succeeded (Constraint: is true, Value: true) | ||
Assertion Succeeded (Constraint: is true, Value: true) | ||
Test Passed (PHPUnit\TestFixture\Event\InvalidParameterNameDataProviderTest::testSuccess#0) | ||
Test Finished (PHPUnit\TestFixture\Event\InvalidParameterNameDataProviderTest::testSuccess#0) | ||
Test Preparation Started (PHPUnit\TestFixture\Event\InvalidParameterNameDataProviderTest::testSuccess#1) | ||
Test Prepared (PHPUnit\TestFixture\Event\InvalidParameterNameDataProviderTest::testSuccess#1) | ||
Assertion Succeeded (Constraint: is true, Value: true) | ||
Assertion Succeeded (Constraint: is true, Value: true) | ||
Test Passed (PHPUnit\TestFixture\Event\InvalidParameterNameDataProviderTest::testSuccess#1) | ||
Test Finished (PHPUnit\TestFixture\Event\InvalidParameterNameDataProviderTest::testSuccess#1) | ||
Test Suite Finished (PHPUnit\TestFixture\Event\InvalidParameterNameDataProviderTest::testSuccess, 2 tests) | ||
Test Suite Finished (PHPUnit\TestFixture\Event\InvalidParameterNameDataProviderTest, 2 tests) | ||
Test Runner Execution Finished | ||
Test Runner Finished | ||
PHPUnit Finished (Shell Exit Code: 0) |