1414namespace RegexParser \Tests \Integration ;
1515
1616use PHPUnit \Framework \Attributes \DataProvider ;
17- use PHPUnit \Framework \Attributes \DoesNotPerformAssertions ;
1817use PHPUnit \Framework \TestCase ;
1918use RegexParser \NodeVisitor \CompilerNodeVisitor ;
2019use RegexParser \Regex ;
@@ -43,15 +42,15 @@ public function test_round_trip_compilation(string $originalPattern): void
4342 // We suppress errors because we want to catch the false return value
4443 $ isValid = @preg_match ($ recompiled , '' );
4544
46- if ($ isValid === false ) {
45+ if (false === $ isValid ) {
4746 $ error = preg_last_error ();
4847 $ msg = match ($ error ) {
49- PREG_INTERNAL_ERROR => 'PREG_INTERNAL_ERROR ' ,
50- PREG_BACKTRACK_LIMIT_ERROR => 'PREG_BACKTRACK_LIMIT_ERROR ' ,
51- PREG_RECURSION_LIMIT_ERROR => 'PREG_RECURSION_LIMIT_ERROR ' ,
52- PREG_BAD_UTF8_ERROR => 'PREG_BAD_UTF8_ERROR ' ,
53- PREG_BAD_UTF8_OFFSET_ERROR => 'PREG_BAD_UTF8_OFFSET_ERROR ' ,
54- PREG_JIT_STACKLIMIT_ERROR => 'PREG_JIT_STACKLIMIT_ERROR ' ,
48+ \ PREG_INTERNAL_ERROR => 'PREG_INTERNAL_ERROR ' ,
49+ \ PREG_BACKTRACK_LIMIT_ERROR => 'PREG_BACKTRACK_LIMIT_ERROR ' ,
50+ \ PREG_RECURSION_LIMIT_ERROR => 'PREG_RECURSION_LIMIT_ERROR ' ,
51+ \ PREG_BAD_UTF8_ERROR => 'PREG_BAD_UTF8_ERROR ' ,
52+ \ PREG_BAD_UTF8_OFFSET_ERROR => 'PREG_BAD_UTF8_OFFSET_ERROR ' ,
53+ \ PREG_JIT_STACKLIMIT_ERROR => 'PREG_JIT_STACKLIMIT_ERROR ' ,
5554 default => 'Unknown Error '
5655 };
5756 $ this ->fail ("Recompiled regex ' $ recompiled' from ' $ originalPattern' is invalid ( $ msg). " );
@@ -63,16 +62,15 @@ public function test_round_trip_compilation(string $originalPattern): void
6362 // Some recursive/complex patterns might hit generator limits, so we wrap in try/catch
6463 $ sample = $ this ->regexService ->generate ($ originalPattern );
6564
66- if ($ sample !== '' ) {
67- $ this ->assertMatchesRegularExpression (
68- $ recompiled ,
69- $ sample ,
70- "Recompiled regex ' $ recompiled' failed to match sample ' $ sample' generated from ' $ originalPattern' "
71- );
72- }
65+ $ this ->assertMatchesRegularExpression (
66+ $ recompiled ,
67+ $ sample ,
68+ "Recompiled regex ' $ recompiled' failed to match sample ' $ sample' generated from ' $ originalPattern' " ,
69+ );
7370 } catch (\Exception $ e ) {
7471 // If generation fails (e.g. infinite recursion), we skip the sample match test
7572 // but the validity test above is still valuable.
73+ $ this ->markTestSkipped ('Sample generation failed for pattern ' .$ originalPattern .': ' .$ e ->getMessage ());
7674 }
7775 }
7876
0 commit comments