Closed Kalec closed 6 years ago
Hmm can you share a repo that demonstrates this? Even after a fresh composer update
(I even tried on Laravel 5.6 as well) I still get a passing test suite without any changes:
One difference I noticed is that in the repo, the code for the orders
method is this:
public function orders()
{
return Order::whereIn('id', $this->tickets()->pluck('order_id'));
}
...with no get()
on the end like in your example.
Adam, yes, sorry, I was trying things and I copied the wrong line. You are right, the code should be without the get()
however, it still produces the errors.
I don't understand though, I just cloned this repo, and have the same errors. Must be something in my local environment then?
In case anyone is interested, I managed to fix the problem. I had PHPUnit installed globally on my machine, and it seems that this was the source of the problems. Once I removed the global version of PHPUnit (even though it was the exact same version that was running locally with the project) all the tests went straight back to green. I reinstalled PHPUnit globally to confirm and sure enough, the errors returned. I came to the conclusion that it's not worth having PHPUnit installed globally.
For anybody reading - it's usually best to use the version of the tools provided in the project. It solves this problem, along with many others (such as people who don't have it installed globally).
I am getting several instances of this error both in my own code and also when cloning directly from this repo.
I have narrowed it down to the "Hack" in the concert model to establish the relationship with the orders, but I can't figure out how to solve it.
currently the code is
Changing the implementation of the "order" relationship to a standard "belongsToMany" like this
fixes all but the "calculating_the_revenue_in_dollars" test in Unit\ConcertTest. My guess is that whereIn is returning a Collection, but an array was expected in the controller. Anyone can see if I'm on the right track? and if so, can you suggest a way to fix it?
To reproduce, I cloned this repo, added .env, .env.dusk.local, .env.testing, phpunit.xml, then composer install, npm install, gulp and phpunit. Running on PHP 7.1.8