markhuot / craft-pest

https://craft-pest.com
Other
38 stars 11 forks source link

More flexible assertLocation() #66

Closed ostark closed 1 year ago

ostark commented 1 year ago

Honestly, I don't know a good solution, but when testing the last step of the Commerce checkout process I'm in the need to skip query parameters because it's dynamic.

Ideas:

assertLocation(string $location, array $parts = null)
assertLocation(string $location, bool $skipQuery = false)
assertLocation(string $location, bool $pathOnly = false) 

do you have a better idea?

markhuot commented 1 year ago

I added a parts param to ->assertLocation allowing you to specify which parts (via PHP’s parse_url) are checked. E.g.,

$response->assertLocation(‘/foo’, [‘path’]);

There’s also a sugar method for this common use case,

$response->assertLocationPath(‘/foo’);

https://github.com/markhuot/craft-pest/blob/b82df3a4a01e98e153f32f8dd2dcd02a76c13d39/docs/assertions/response.md