I am trying to write a test class for a shopping cart. Here is what I have:
ShoppingCartTest.php
class ShoppingCartTest extends TestCase { use DatabaseTransactions; protected $shoppingCart; public function __construct() { $this->shoppingCart = resolve('App\Classes\Billing\ShoppingCart'); } public function a_product_can_be_added_to_and_retrieved_from_the_shopping_cart() {
However, when I run phpunit, it looks like Laravel cannot resolve my ShoppingCartClass.
Here is the error:
Fatal error: Uncaught exception 'Illuminate\Contracts\Container\BindingResolutionException' with message 'Unresolvable dependency resolving [Parameter #0 [ <required> $app ]] in class Illuminate\Support\Manager' in C:\Development Server\EasyPHP-Devserver-16.1\eds-www\nrponline\vendor\laravel\framework\src\Illuminate\Container\Container.php:850
I have a ShoppingCart class that is allowed on a number of different controllers.
Why doesn't Laravel allow this during my tests?
I referenced this post , but still no luck.
source share