-
-
Notifications
You must be signed in to change notification settings - Fork 1.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix compatibility with PHPUnit error expectations
- Loading branch information
1 parent
9a21fc8
commit 9af25fc
Showing
6 changed files
with
117 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
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,52 @@ | ||
<?php | ||
|
||
class ErrorExpectationsCest | ||
{ | ||
|
||
public function _before(\CliGuy $I) | ||
{ | ||
$I->amInPath('tests/data/error_handling'); | ||
} | ||
|
||
public function expectNoticeWorks(\CliGuy $I) | ||
{ | ||
$this->skipIfNot72($I); | ||
|
||
$I->executeCommand('run tests/unit/ErrorExceptionTest.php:test_notice'); | ||
$I->seeInShellOutput("OK ("); | ||
} | ||
|
||
public function expectWarningWorks(\CliGuy $I) | ||
{ | ||
$this->skipIfNot72($I); | ||
|
||
$I->executeCommand('run tests/unit/ErrorExceptionTest.php:test_warning'); | ||
$I->seeInShellOutput('OK ('); | ||
} | ||
|
||
public function expectErrorWorks(\CliGuy $I) | ||
{ | ||
$this->skipIfNot72($I); | ||
|
||
$I->executeCommand('run tests/unit/ErrorExceptionTest.php:test_error'); | ||
$I->seeInShellOutput('OK ('); | ||
} | ||
|
||
public function expectDeprecationWorks(\CliGuy $I) | ||
{ | ||
$this->skipIfNot72($I); | ||
$I->markTestSkipped('This test is just to reproduce that is doesnt work. It will fail because nothing has been implemented'); | ||
|
||
$I->executeCommand('run tests/unit/ErrorExceptionTest.php:test_deprecation'); | ||
$I->seeInShellOutput('OK ('); | ||
} | ||
|
||
private function skipIfNot72(CliGuy $I) | ||
{ | ||
if(PHP_VERSION_ID < 70200) { | ||
$I->markTestSkipped('expectXXX is only available on 7.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,13 @@ | ||
actor: Tester | ||
paths: | ||
tests: tests | ||
log: tests/_output | ||
data: tests/_data | ||
support: tests/_support | ||
envs: tests/_envs | ||
suites: | ||
unit: | ||
path: . | ||
modules: | ||
enabled: | ||
- Asserts |
Empty file.
35 changes: 35 additions & 0 deletions
35
tests/data/error_handling/tests/unit/ErrorExceptionTest.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,35 @@ | ||
<?php | ||
|
||
class ErrorExceptionTest extends \PHPUnit\Framework\TestCase | ||
{ | ||
|
||
public function test_notice() | ||
{ | ||
$this->expectNotice(); | ||
$this->expectNoticeMessage('foobar'); | ||
trigger_error('foobar', E_USER_NOTICE); | ||
} | ||
|
||
public function test_warning() | ||
{ | ||
$this->expectWarning(); | ||
$this->expectWarningMessage('foobar'); | ||
trigger_error('foobar', E_USER_WARNING); | ||
} | ||
|
||
public function test_error() | ||
{ | ||
$this->expectError(); | ||
$this->expectErrorMessage('foobar'); | ||
trigger_error('foobar', E_USER_ERROR); | ||
} | ||
|
||
public function test_deprecation() | ||
{ | ||
// This test fails. | ||
$this->expectDeprecation(); | ||
$this->expectDeprecationMessage('foobar'); | ||
trigger_error('foobar', E_USER_DEPRECATED); | ||
} | ||
|
||
} |
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