fix: pipes not allowing to modify original value

This commit is contained in:
Nuno Maduro
2024-01-25 16:10:16 +00:00
parent 887bed3d45
commit 95cd550524
7 changed files with 40 additions and 6 deletions

View File

@ -21,6 +21,23 @@ test('pass', function () {
expect($this->snapshotable)->toMatchSnapshot();
});
expect()->pipe('toMatchSnapshot', function (Closure $next) {
if (is_string($this->value)) {
$this->value = preg_replace(
'/name="_token" value=".*"/',
'name="_token" value="1"',
$this->value
);
}
return $next();
});
test('pass using pipes', function () {
expect('<input type="hidden" name="_token" value="'.random_int(1, 999).'" />')
->toMatchSnapshot();
});
test('pass with `__toString`', function () {
TestSuite::getInstance()->snapshots->save($this->snapshotable);