-
-
Notifications
You must be signed in to change notification settings - Fork 1
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
Showing
6 changed files
with
136 additions
and
2 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,34 @@ | ||
name: Test | ||
|
||
on: | ||
push: | ||
|
||
jobs: | ||
run-tests: | ||
runs-on: ubuntu-latest | ||
|
||
strategy: | ||
fail-fast: false | ||
matrix: | ||
php: ['8.2'] | ||
phpunit: ['9', '10'] | ||
|
||
name: "PHP ${{ matrix.php }} with PHPUnit ${{ matrix.phpunit }}" | ||
|
||
steps: | ||
- name: Checkout code | ||
uses: actions/checkout@v2 | ||
|
||
- name: Install PHP ${{ matrix.php }} | ||
uses: shivammathur/setup-php@v2 | ||
with: | ||
php-version: ${{ matrix.php }} | ||
ini-values: zend.assertions=1, error_reporting=-1, display_errors=On | ||
tools: phpunit:${{ matrix.phpunit }} | ||
coverage: none | ||
|
||
- name: Dump autoload | ||
run: composer du | ||
|
||
- name: Run tests | ||
run: phpunit |
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 |
---|---|---|
@@ -1,5 +1,16 @@ | ||
# Bug Report Reproduction Scenarios | ||
|
||
This repository contains reproduction scenarios for various bugs I've found and reported. | ||
## PHPUnit 10 break error_get_last() | ||
|
||
There's nothing of significance in the `main` branch, but for each (open) bug report, there will be a separate branch which can be checked out to reproduce the specific issue reported. | ||
### Description | ||
|
||
See issue https://github.com/sebastianbergmann/phpunit/issues/5428 | ||
|
||
|
||
### How to reproduce | ||
|
||
* Check out this branch | ||
* Run `composer install` | ||
* Run `vendor/bin/phpunit` | ||
|
||
Or have a look at the GitHub Actions output for this branch: https://github.com/jrfnl/bug-report-reproduction-scenarios/actions |
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,18 @@ | ||
{ | ||
"name": "jrfnl/phpunit-5428", | ||
"description": "Testing", | ||
"license": "MIT", | ||
"require-dev": { | ||
"phpunit/phpunit": "^9.3 || ^10.1" | ||
}, | ||
"autoload": { | ||
"psr-4": { | ||
"Jrf\\PHPUnit10\\Scenario\\": "src/" | ||
} | ||
}, | ||
"autoload-dev": { | ||
"psr-4": { | ||
"Jrf\\PHPUnit10\\Scenario\\Tests\\": "tests/" | ||
} | ||
} | ||
} |
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,16 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<phpunit | ||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" | ||
xsi:noNamespaceSchemaLocation="https://schema.phpunit.de/10.1/phpunit.xsd" | ||
bootstrap="vendor/autoload.php" | ||
displayDetailsOnTestsThatTriggerErrors="true" | ||
displayDetailsOnTestsThatTriggerWarnings="true" | ||
displayDetailsOnTestsThatTriggerNotices="true" | ||
displayDetailsOnTestsThatTriggerDeprecations="true" | ||
> | ||
<testsuites> | ||
<testsuite name="POC"> | ||
<directory suffix="Test.php">tests</directory> | ||
</testsuite> | ||
</testsuites> | ||
</phpunit> |
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 | ||
|
||
namespace Jrf\PHPUnit10\Scenario; | ||
|
||
use Exception; | ||
|
||
class Foo | ||
{ | ||
/** | ||
* Real world example. | ||
*/ | ||
public function methodA($fileName) | ||
{ | ||
$stream_handle = @fopen($fileName, 'wb'); | ||
if ($stream_handle === false) { | ||
$error = error_get_last(); | ||
throw new Exception($error['message']); | ||
} | ||
|
||
return $stream_handle; | ||
} | ||
|
||
/** | ||
* Minimal test case. | ||
*/ | ||
public function methodB() | ||
{ | ||
@trigger_error('Triggering', E_USER_WARNING); | ||
return error_get_last(); | ||
} | ||
} |
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,24 @@ | ||
<?php | ||
|
||
namespace Jrf\PHPUnit10\Scenario\Tests; | ||
|
||
use Exception; | ||
use Jrf\PHPUnit10\Scenario\Foo; | ||
use PHPUnit\Framework\TestCase; | ||
|
||
class FooTest extends TestCase | ||
{ | ||
|
||
public function testMethodA() { | ||
$fileName = tempnam(sys_get_temp_dir(), 'RLT') . '/missing/directory'; | ||
|
||
$this->expectException(Exception::class); | ||
$this->expectExceptionMessage('Failed to open stream'); | ||
|
||
(new Foo)->methodA($fileName); | ||
} | ||
|
||
public function testMethodB() { | ||
$this->assertSame('Triggering', (new Foo)->methodB()['message']); | ||
} | ||
} |