-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #237 from woocommerce/25-01/detect-parse-errors
Detect parse errors
- Loading branch information
Showing
4 changed files
with
63 additions
and
13 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,23 @@ | ||
<?php | ||
|
||
namespace QIT_CLI_Tests\LocalTests; | ||
|
||
use QIT_CLI\App; | ||
use QIT_CLI\LocalTests\PrepareQMLog; | ||
use QIT_CLI_Tests\QITTestCase; | ||
use Spatie\Snapshots\MatchesSnapshots; | ||
|
||
class PrepareQMLogTest extends QITTestCase { | ||
use MatchesSnapshots; | ||
|
||
public function test_parses_fatal_and_parse_errors() { | ||
$debug_log = <<<'TXT' | ||
[10-Jan-2025 17:12:43 UTC] PHP Parse error: syntax error, unexpected '|', expecting variable (T_VARIABLE) in /var/www/html/wp-content/plugins/foo-slug/vendor/phpunit/phpunit/src/Framework/Assert/Functions.php on line 83 | ||
[10-Jan-2025 17:12:43 UTC] PHP Fatal error: Exception thrown without a stack frame in Unknown on line 0 | ||
[10-Jan-2025 17:52:22 UTC] PHP Fatal error: Uncaught Exception: Foo in /var/www/html/wp-content/plugins/foo-slug/foo-slug.php:29 | ||
TXT; | ||
$sut = App::make( PrepareQMLog::class ); | ||
|
||
$this->assertMatchesJsonSnapshot( $sut->extract_error_info( explode( "\n", $debug_log ) ) ); | ||
} | ||
} |
17 changes: 17 additions & 0 deletions
17
...sts/LocalTests/__snapshots__/PrepareQMLogTest__test_parses_fatal_and_parse_errors__1.json
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,17 @@ | ||
[ | ||
{ | ||
"message": " syntax error, unexpected '|', expecting variable (T_VARIABLE)", | ||
"file": "wp-content\/plugins\/foo-slug\/vendor\/phpunit\/phpunit\/src\/Framework\/Assert\/Functions.php", | ||
"line": "83" | ||
}, | ||
{ | ||
"message": " Exception thrown without a stack frame", | ||
"file": "Unknown", | ||
"line": "0" | ||
}, | ||
{ | ||
"message": " Uncaught Exception: Foo", | ||
"file": "wp-content\/plugins\/foo-slug\/foo-slug.php", | ||
"line": "29" | ||
} | ||
] |