-
-
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.
- Loading branch information
1 parent
a24e959
commit 7a6a4d1
Showing
12 changed files
with
482 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
<?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 function trigger_error; | ||
use PHPUnit\Framework\Attributes\DataProvider; | ||
use PHPUnit\Framework\TestCase; | ||
|
||
final class DataProviderErrorTest extends TestCase | ||
{ | ||
public static function values(): array | ||
{ | ||
trigger_error('message', E_USER_ERROR); | ||
|
||
return [[true], [true]]; | ||
} | ||
|
||
#[DataProvider('values')] | ||
public function testSuccess(bool $value): void | ||
{ | ||
$this->assertTrue($value); | ||
} | ||
} |
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,30 @@ | ||
<?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 function trigger_error; | ||
use PHPUnit\Framework\Attributes\DataProvider; | ||
use PHPUnit\Framework\TestCase; | ||
|
||
final class DataProviderNoticeTest extends TestCase | ||
{ | ||
public static function values(): array | ||
{ | ||
trigger_error('message', E_USER_NOTICE); | ||
|
||
return [[true], [true]]; | ||
} | ||
|
||
#[DataProvider('values')] | ||
public function testSuccess(bool $value): void | ||
{ | ||
$this->assertTrue($value); | ||
} | ||
} |
30 changes: 30 additions & 0 deletions
30
tests/end-to-end/event/_files/DataProviderPhpDeprecationTest.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,30 @@ | ||
<?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 function strlen; | ||
use PHPUnit\Framework\Attributes\DataProvider; | ||
use PHPUnit\Framework\TestCase; | ||
|
||
final class DataProviderPhpDeprecationTest extends TestCase | ||
{ | ||
public static function values(): array | ||
{ | ||
strlen(null); | ||
|
||
return [[true], [true]]; | ||
} | ||
|
||
#[DataProvider('values')] | ||
public function testSuccess(bool $value): void | ||
{ | ||
$this->assertTrue($value); | ||
} | ||
} |
33 changes: 33 additions & 0 deletions
33
tests/end-to-end/event/_files/DataProviderPhpNoticeTest.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,33 @@ | ||
<?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 DataProviderPhpNoticeTest extends TestCase | ||
{ | ||
public static function values(): array | ||
{ | ||
$f = static function (): void | ||
{ | ||
}; | ||
|
||
$a = &$f(); | ||
|
||
return [[true], [true]]; | ||
} | ||
|
||
#[DataProvider('values')] | ||
public function testSuccess(bool $value): void | ||
{ | ||
$this->assertTrue($value); | ||
} | ||
} |
29 changes: 29 additions & 0 deletions
29
tests/end-to-end/event/_files/DataProviderPhpWarningTest.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,29 @@ | ||
<?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 DataProviderPhpWarningTest extends TestCase | ||
{ | ||
public static function values(): array | ||
{ | ||
$a = $b; | ||
|
||
return [[true], [true]]; | ||
} | ||
|
||
#[DataProvider('values')] | ||
public function testSuccess(bool $value): void | ||
{ | ||
$this->assertTrue($value); | ||
} | ||
} |
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,30 @@ | ||
<?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 function trigger_error; | ||
use PHPUnit\Framework\Attributes\DataProvider; | ||
use PHPUnit\Framework\TestCase; | ||
|
||
final class DataProviderWarningTest extends TestCase | ||
{ | ||
public static function values(): array | ||
{ | ||
trigger_error('message', E_USER_WARNING); | ||
|
||
return [[true], [true]]; | ||
} | ||
|
||
#[DataProvider('values')] | ||
public function testSuccess(bool $value): void | ||
{ | ||
$this->assertTrue($value); | ||
} | ||
} |
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,43 @@ | ||
--TEST-- | ||
The right events are emitted in the right order for a successful test that uses a data provider which triggers E_USER_ERROR | ||
--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/DataProviderErrorTest.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\DataProviderErrorTest::values for test method PHPUnit\TestFixture\Event\DataProviderErrorTest::testSuccess) | ||
Data Provider Method Called (PHPUnit\TestFixture\Event\DataProviderErrorTest::values for test method PHPUnit\TestFixture\Event\DataProviderErrorTest::testSuccess) | ||
Data Provider Triggered Error (PHPUnit\TestFixture\Event\DataProviderErrorTest::values) | ||
message | ||
Data Provider Method Finished for PHPUnit\TestFixture\Event\DataProviderErrorTest::testSuccess: | ||
- PHPUnit\TestFixture\Event\DataProviderErrorTest::values | ||
Data Provider Method Finished for PHPUnit\TestFixture\Event\DataProviderErrorTest::testSuccess: | ||
- PHPUnit\TestFixture\Event\DataProviderErrorTest::values | ||
Test Triggered PHPUnit Error (PHPUnit\TestFixture\Event\DataProviderErrorTest::testSuccess) | ||
The data provider specified for PHPUnit\TestFixture\Event\DataProviderErrorTest::testSuccess is invalid | ||
E_USER_ERROR was triggered | ||
Test Runner Triggered Warning (No tests found in class "PHPUnit\TestFixture\Event\DataProviderErrorTest".) | ||
Test Suite Loaded (0 tests) | ||
Event Facade Sealed | ||
Test Runner Started | ||
Test Suite Sorted | ||
Test Runner Execution Started (0 tests) | ||
Test Runner Execution Finished | ||
Test Runner Finished | ||
PHPUnit Finished (Shell Exit Code: 2) |
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,51 @@ | ||
--TEST-- | ||
The right events are emitted in the right order for a successful test that uses a data provider which triggers E_USER_NOTICE | ||
--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/DataProviderNoticeTest.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\DataProviderNoticeTest::values for test method PHPUnit\TestFixture\Event\DataProviderNoticeTest::testSuccess) | ||
Data Provider Method Called (PHPUnit\TestFixture\Event\DataProviderNoticeTest::values for test method PHPUnit\TestFixture\Event\DataProviderNoticeTest::testSuccess) | ||
Data Provider Triggered Notice (PHPUnit\TestFixture\Event\DataProviderNoticeTest::values) | ||
message | ||
Data Provider Method Finished for PHPUnit\TestFixture\Event\DataProviderNoticeTest::testSuccess: | ||
- PHPUnit\TestFixture\Event\DataProviderNoticeTest::values | ||
Data Provider Method Finished for PHPUnit\TestFixture\Event\DataProviderNoticeTest::testSuccess: | ||
- PHPUnit\TestFixture\Event\DataProviderNoticeTest::values | ||
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\DataProviderNoticeTest, 2 tests) | ||
Test Suite Started (PHPUnit\TestFixture\Event\DataProviderNoticeTest::testSuccess, 2 tests) | ||
Test Preparation Started (PHPUnit\TestFixture\Event\DataProviderNoticeTest::testSuccess#0) | ||
Test Prepared (PHPUnit\TestFixture\Event\DataProviderNoticeTest::testSuccess#0) | ||
Test Passed (PHPUnit\TestFixture\Event\DataProviderNoticeTest::testSuccess#0) | ||
Test Finished (PHPUnit\TestFixture\Event\DataProviderNoticeTest::testSuccess#0) | ||
Test Preparation Started (PHPUnit\TestFixture\Event\DataProviderNoticeTest::testSuccess#1) | ||
Test Prepared (PHPUnit\TestFixture\Event\DataProviderNoticeTest::testSuccess#1) | ||
Test Passed (PHPUnit\TestFixture\Event\DataProviderNoticeTest::testSuccess#1) | ||
Test Finished (PHPUnit\TestFixture\Event\DataProviderNoticeTest::testSuccess#1) | ||
Test Suite Finished (PHPUnit\TestFixture\Event\DataProviderNoticeTest::testSuccess, 2 tests) | ||
Test Suite Finished (PHPUnit\TestFixture\Event\DataProviderNoticeTest, 2 tests) | ||
Test Runner Execution Finished | ||
Test Runner Finished | ||
PHPUnit Finished (Shell Exit Code: 0) |
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,53 @@ | ||
--TEST-- | ||
The right events are emitted in the right order for a successful test that uses a data provider which triggers E_DEPRECATED | ||
--XFAIL-- | ||
"Data Provider Triggered PHP Deprecation" event is not emitted | ||
--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/DataProviderPhpDeprecationTest.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\DataProviderPhpDeprecationTest::values for test method PHPUnit\TestFixture\Event\DataProviderPhpDeprecationTest::testSuccess) | ||
Data Provider Method Called (PHPUnit\TestFixture\Event\DataProviderPhpDeprecationTest::values for test method PHPUnit\TestFixture\Event\DataProviderPhpDeprecationTest::testSuccess) | ||
Data Provider Triggered PHP Deprecation (PHPUnit\TestFixture\Event\DataProviderPhpDeprecationTest::values, issue triggered by first-party code calling into first-party code) | ||
strlen(): Passing null to parameter #1 ($string) of type string is deprecated | ||
Data Provider Method Finished for PHPUnit\TestFixture\Event\DataProviderPhpDeprecationTest::testSuccess: | ||
- PHPUnit\TestFixture\Event\DataProviderPhpDeprecationTest::values | ||
Data Provider Method Finished for PHPUnit\TestFixture\Event\DataProviderPhpDeprecationTest::testSuccess: | ||
- PHPUnit\TestFixture\Event\DataProviderPhpDeprecationTest::values | ||
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\DataProviderPhpDeprecationTest, 2 tests) | ||
Test Suite Started (PHPUnit\TestFixture\Event\DataProviderPhpDeprecationTest::testSuccess, 2 tests) | ||
Test Preparation Started (PHPUnit\TestFixture\Event\DataProviderPhpDeprecationTest::testSuccess#0) | ||
Test Prepared (PHPUnit\TestFixture\Event\DataProviderPhpDeprecationTest::testSuccess#0) | ||
Test Passed (PHPUnit\TestFixture\Event\DataProviderPhpDeprecationTest::testSuccess#0) | ||
Test Finished (PHPUnit\TestFixture\Event\DataProviderPhpDeprecationTest::testSuccess#0) | ||
Test Preparation Started (PHPUnit\TestFixture\Event\DataProviderPhpDeprecationTest::testSuccess#1) | ||
Test Prepared (PHPUnit\TestFixture\Event\DataProviderPhpDeprecationTest::testSuccess#1) | ||
Test Passed (PHPUnit\TestFixture\Event\DataProviderPhpDeprecationTest::testSuccess#1) | ||
Test Finished (PHPUnit\TestFixture\Event\DataProviderPhpDeprecationTest::testSuccess#1) | ||
Test Suite Finished (PHPUnit\TestFixture\Event\DataProviderPhpDeprecationTest::testSuccess, 2 tests) | ||
Test Suite Finished (PHPUnit\TestFixture\Event\DataProviderPhpDeprecationTest, 2 tests) | ||
Test Runner Execution Finished | ||
Test Runner Finished | ||
PHPUnit Finished (Shell Exit Code: 0) |
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,51 @@ | ||
--TEST-- | ||
The right events are emitted in the right order for a successful test that uses a data provider which triggers E_NOTICE | ||
--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/DataProviderPhpNoticeTest.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\DataProviderPhpNoticeTest::values for test method PHPUnit\TestFixture\Event\DataProviderPhpNoticeTest::testSuccess) | ||
Data Provider Method Called (PHPUnit\TestFixture\Event\DataProviderPhpNoticeTest::values for test method PHPUnit\TestFixture\Event\DataProviderPhpNoticeTest::testSuccess) | ||
Data Provider Triggered PHP Notice (PHPUnit\TestFixture\Event\DataProviderPhpNoticeTest::values) | ||
Only variables should be assigned by reference | ||
Data Provider Method Finished for PHPUnit\TestFixture\Event\DataProviderPhpNoticeTest::testSuccess: | ||
- PHPUnit\TestFixture\Event\DataProviderPhpNoticeTest::values | ||
Data Provider Method Finished for PHPUnit\TestFixture\Event\DataProviderPhpNoticeTest::testSuccess: | ||
- PHPUnit\TestFixture\Event\DataProviderPhpNoticeTest::values | ||
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\DataProviderPhpNoticeTest, 2 tests) | ||
Test Suite Started (PHPUnit\TestFixture\Event\DataProviderPhpNoticeTest::testSuccess, 2 tests) | ||
Test Preparation Started (PHPUnit\TestFixture\Event\DataProviderPhpNoticeTest::testSuccess#0) | ||
Test Prepared (PHPUnit\TestFixture\Event\DataProviderPhpNoticeTest::testSuccess#0) | ||
Test Passed (PHPUnit\TestFixture\Event\DataProviderPhpNoticeTest::testSuccess#0) | ||
Test Finished (PHPUnit\TestFixture\Event\DataProviderPhpNoticeTest::testSuccess#0) | ||
Test Preparation Started (PHPUnit\TestFixture\Event\DataProviderPhpNoticeTest::testSuccess#1) | ||
Test Prepared (PHPUnit\TestFixture\Event\DataProviderPhpNoticeTest::testSuccess#1) | ||
Test Passed (PHPUnit\TestFixture\Event\DataProviderPhpNoticeTest::testSuccess#1) | ||
Test Finished (PHPUnit\TestFixture\Event\DataProviderPhpNoticeTest::testSuccess#1) | ||
Test Suite Finished (PHPUnit\TestFixture\Event\DataProviderPhpNoticeTest::testSuccess, 2 tests) | ||
Test Suite Finished (PHPUnit\TestFixture\Event\DataProviderPhpNoticeTest, 2 tests) | ||
Test Runner Execution Finished | ||
Test Runner Finished | ||
PHPUnit Finished (Shell Exit Code: 0) |
Oops, something went wrong.