Closed Firtzberg closed 2 years ago
This package is great! I just wanted to share some thoughts.
Inside tests using MatchesSnpashots trait I started adding this handy function.
MatchesSnpashots
public function snapshotConstraint(): Constraint { return self::callback(function ($argument) { $this->assertMatchesJsonSnapshot([$argument]); return true; }); }
Within a test case using mocks where I don't care what the parameter value exactly is, but want to make sure it didn't change I do the following
// Find record in cache $this->redisMock->expects(self::once()) ->method('get') // Compare key to key snapshot ->with($this->snapshotConstraint()) ->willReturn(json_encode($data, JSON_THROW_ON_ERROR));
I guess this can be implemented in a better way by defining a new constraint class extending the PHPUnit Constraint.
This package is great! I just wanted to share some thoughts.
Inside tests using
MatchesSnpashots
trait I started adding this handy function.Within a test case using mocks where I don't care what the parameter value exactly is, but want to make sure it didn't change I do the following
I guess this can be implemented in a better way by defining a new constraint class extending the PHPUnit Constraint.