-
Notifications
You must be signed in to change notification settings - Fork 10.8k
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
phpunit error "must be a array or ArrayAccess" #18280
Comments
Please ask on the forums, we try to keep this repo for bug reporting only. |
@themsaid yeah well, I'm not asking how to use anything, or trying to get help for checking the keys of a hash, I thought it was a bug. I can make an algorithm for checking each key if I want to, but I wanted to use the method that figures in your documentation, thanks anyways. |
@nisevi sorry, we're just trying to narrow down the issues in this repo to only include actual framework bugs. |
+1 to this as a bug |
Happens to me too. I think is a bug. |
If it's a bug, at least include complete steps to reproduce. Current steps to reproduce require depend on the codebase of @nisevi, which we don't have. |
@GuidoHendriks if I'm not wrong with the specifications I wrote you should be able to reproduce it since you will have to create an app with:
and just write some test to try it, right? |
@nisevi My point exactly. We'd have to create a new app which does the same as yours does. There are some blanks that we'd have to fill in ourselves. We don't see the data that actually is returned by the request while the behaviour depends on it. If you would create a new project, what steps would you need to take to reproduce this issue? For example, if you can do it with just a route that returns a hardcoded array and a test along with it, that's a lot easier for people trying to reproduce or solve this issue. |
I had the same issue. This should fix this. |
Maybe it will helps to some one, I hope:
So when I have set the correct URI and make a call to an existed route: '/api/v1/user/1' - this issue was gone. |
As above in case someone can use my input. In my case, it was happening because I was specifying the structure should return an array when it actually was just a simple object. Using the example from the original question.
so basically to validate the following json response:
the json structure definition should look like:
But if the key "data" is not an array, then the above should be like:
Hope this helps to someone. |
It happens to me when array of objects with one prop as follows:
It raises an error like this: When I add another prop to categories the error converts to failure. @taylorotwell |
This issue still happening on Laravel 8, I'm stuck on it!!! |
Everything works correctly for GET request: $this->getJson($this->baseUri())
->assertOk()
->assertJsonStructure([
'data' => [
'*' => ['id', 'key', 'value', 'type', 'description', 'is_encrypted', 'created_at', 'updated_at']
]
]); But when I want to make same assertion after patch request: $this->patch($this->baseUri() . "/$setting->id", $request) // or ->patchJson - they both don't work...
->assertOk()
->assertJsonStructure([
'data' => [
'*' => ['id', 'key', 'value', 'type', 'description', 'is_encrypted', 'created_at', 'updated_at']
]
]); It fails:
|
Description:
When running tests with phpunit I get:
Steps To Reproduce:
I'm trying to validate this structure:
If I wrongly change (on purpose) one of the expected keys inside "data" I get the expected behavior:
However if everything is ok with the keys, I get:
I asked on phpunit repository, here and they suggest to take a look at the code on the Laravel framework here.
Please let me know if you need more info regarding this issue.
The text was updated successfully, but these errors were encountered: