-
-
Notifications
You must be signed in to change notification settings - Fork 247
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Testing the value of a prop #227
Comments
Also, the demo app uses a macro instead: |
I think $response->assertInertia(function (Assert $page) {
$page->component('Ads');
// Check if the 'foo' key exists
$page->has('foo');
// Check if 'foo' has the expected value 'bar'
$page->where('foo', 'bar');
}); |
Yes, that works. But what if I'd wanted to |
I suppose you could do this: // Assuming your data looks like this:
// [
// 'foo' => ['some' => 'array'],
// ]
$response->assertInertia(function (Assert $page) {
// $foo will be ['some' => 'array']
$foo = $page->prop('foo');
// Use PHPUnit assertions on the prop
$this->assertArrayHasKey('some', $foo);
}); |
Hey @Livijn I assume you are refering to this PR #220 ? This comment made me come here to comment:
However this is not true at all as you will find new laravel versions having a very similar JSON assertion built in to laravel: laravel/framework#36454 . On this PR you'll find a very extensive description on how to use it. IMHO: @claudiodekker 's work has been amazing on the tester and if pingcrm is not using it yet it just means, the core team didn't have to time to convert it. PingCRM is not aimed to be feature complete nor to achieve feature parity. It's just a demo project laying out the very fundamentic way inertia is helping you as a developer |
That is true. However, that PR was merged merely 1 day before i posted this issue. So this is still a pretty atypical way of testing in Laravel. After playing around with this new method of testing, I have grown fond of it. I guess the idea had to marinate a bit. |
Totally, we're breaking new ground here @Livijn 😎
🙌 |
🤣 great, now i am hungry and want to lighten up the bbq. |
First off, I've looked through a couple of PRs that tried to ease the use of testing with Inertia. I'm not sure why you chose the "unorthodox" way that you did. The testing that exists in Laravel doesn't use closures like this, which is why it feels strange.
So, now to my question. How do I test that a prop is equal to a value?
Based of the name I thought
$page->has('foo', ['some', 'array']);
would work, but it seems thehas()
method only allows integers.The text was updated successfully, but these errors were encountered: