-
-
Notifications
You must be signed in to change notification settings - Fork 155
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Make sure
dg/bypass-finals
works with Infection (#1728)
* Add tests to make sure `bypass-finals` lib does not lead to escaped mutants * Test dg/bypass-finals@7c08b98 * Tests different approaches * Use the latest `master` of `db/bypass-finals` * Update `db/bypass-finals` to the latest commit to check if the issue is fixed * Update `conflict` section with new version of `dg/bypass-finals` * Run `composer update --lock` * Update `expected-output.txt` to fix e2e test * Fix incorrect versions * Run `composer update --lock` * For some unknown reason, MSI has decreased with no changes in `src`
- Loading branch information
1 parent
b66257a
commit cac814f
Showing
11 changed files
with
140 additions
and
3 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 |
---|---|---|
|
@@ -12,7 +12,7 @@ on: | |
|
||
env: | ||
MIN_MSI: 71.35 | ||
MIN_COVERED_MSI: 86.54 | ||
MIN_COVERED_MSI: 86.50 | ||
|
||
jobs: | ||
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
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
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,10 @@ | ||
# Ensures Infection works with `dg/bypass-finals` | ||
|
||
* https://github.com/dg/bypass-finals/issues/9 | ||
* https://github.com/infection/infection/issues/1275 | ||
|
||
## Summary | ||
|
||
`dg/bypass-finals` before version 1.4.1 overridden Infection's Stream Wrapper and Infection did not create any Mutants. | ||
|
||
This tests ensures that starting from 1.4.1 `dg/bypass-finals` works good and do not "disables" Infection's Stream Wrapper. |
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 @@ | ||
{ | ||
"require-dev": { | ||
"phpunit/phpunit": "^9.5.5", | ||
"dg/bypass-finals": "^1.4.1" | ||
}, | ||
"autoload": { | ||
"psr-4": { | ||
"Stream_Wrapper_Execution\\": "src/" | ||
} | ||
}, | ||
"autoload-dev": { | ||
"psr-4": { | ||
"Stream_Wrapper_Execution\\Test\\": "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,10 @@ | ||
Total: 5 | ||
|
||
Killed: 5 | ||
Errored: 0 | ||
Syntax Errors: 0 | ||
Escaped: 0 | ||
Timed Out: 0 | ||
Skipped: 0 | ||
Ignored: 0 | ||
Not Covered: 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,15 @@ | ||
{ | ||
"timeout": 5, | ||
"source": { | ||
"directories": [ | ||
"src" | ||
] | ||
}, | ||
"logs": { | ||
"summary": "infection.log" | ||
}, | ||
"tmpDir": ".", | ||
"mutators": { | ||
"@default": true | ||
} | ||
} |
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 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<phpunit xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" | ||
xsi:noNamespaceSchemaLocation="./vendor/phpunit/phpunit/phpunit.xsd" | ||
bootstrap="./vendor/autoload.php" | ||
colors="true" | ||
> | ||
<testsuites> | ||
<testsuite name="Test Suite"> | ||
<directory>./tests/</directory> | ||
</testsuite> | ||
</testsuites> | ||
|
||
<coverage> | ||
<include> | ||
<directory>./src/</directory> | ||
</include> | ||
</coverage> | ||
</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,13 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
namespace Stream_Wrapper_Execution; | ||
|
||
final class FinalClass | ||
{ | ||
public function get(): int | ||
{ | ||
return 1; | ||
} | ||
} |
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 @@ | ||
<?php | ||
|
||
namespace Stream_Wrapper_Execution; | ||
|
||
class SourceClass | ||
{ | ||
private $finalClass; | ||
|
||
public function __construct(FinalClass $finalClass) | ||
{ | ||
$this->finalClass = $finalClass; | ||
} | ||
|
||
public function getOne(): int | ||
{ | ||
return $this->finalClass->get(); | ||
} | ||
} |
37 changes: 37 additions & 0 deletions
37
tests/e2e/Stream_Wrapper_Execution/tests/SourceClassTest.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,37 @@ | ||
<?php | ||
|
||
namespace Stream_Wrapper_Execution\Test; | ||
|
||
use Stream_Wrapper_Execution\FinalClass; | ||
use Stream_Wrapper_Execution\SourceClass; | ||
use PHPUnit\Framework\TestCase; | ||
use DG\BypassFinals; | ||
|
||
class SourceClassTest extends TestCase | ||
{ | ||
public static function setUpBeforeClass(): void | ||
{ | ||
parent::setUpBeforeClass(); | ||
|
||
BypassFinals::enable(); | ||
} | ||
|
||
|
||
public function test_returns_one() | ||
{ | ||
$sourceClass = new SourceClass(new FinalClass()); | ||
|
||
$this->assertSame(1, $sourceClass->getOne()); | ||
} | ||
|
||
public function test_final_class_can_be_mocked() | ||
{ | ||
$mock = $this->createMock(FinalClass::class); | ||
|
||
$mock->expects(self::once())->method('get')->willReturn(1); | ||
|
||
$sourceClass = new SourceClass($mock); | ||
|
||
self::assertSame(1, $sourceClass->getOne()); | ||
} | ||
} |