You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
class HtmlJsonMatcher {
use PHPMatcherAssertions;
publicstaticfunctionassertHtml($expectedJsonPattern, string$html, string$variable): void
{
// some other asserts// extract javascript variable to match against the created componentpreg_match_all('/(<script>([\s\S^?]+?)var ' . $variable . ' =)([\s\S^?]+?)<\/script>/', $text, $matches);
$content = trim(trim($matches[3][0]), ';');
// convert javascript object to json via json5 library$contentJson = json_encode(json5_decode($content), \JSON_PRETTY_PRINT);
// following fails while assertMatchesPattern is not able to be used in a static methodself::assertMatchesPattern($expectedJson, $contentJson);
// more asserts
}
}
Sure it is possible to move things and not relay on static method here. But as all other assertions of PHPUnit are able to be used in static methods it would be nice to have possibility to use also assertMatchesPattern in static methods.
Sometimes I get into cases where I want to use the
assertMatchesPattern
like other assertions in a static method.Maybe the
assertMatchesPattern
could be changed from:As it would be a bc break it could only be done in a new major release.
The text was updated successfully, but these errors were encountered: