Laravel Unit Tests. I can’t instantiate the class

Asked

Viewed 106 times

1

my problem apparently is simple but I can not solve.

I decided to do tests on my application, and at first I had problems

I run the following command line to run the test:

vendor/bin/phpunit

In the test I’m just instantiating the User class:

$user = \Escola\User;

And I get the following error message:

[Symfony\Component\Debug\Exception\FatalErrorException]  
Undefined constant 'Escola\User'                                                                                         
Fatal error: Undefined constant 'Escola\User' in  
/home/f15/Desktop/escola/tests/PedidoTest.php on line 11
  • tried to put a new before \Escola\User ?

1 answer

1


You need to use the keyword new to instantiate something

$user = new \Escola\User;
  • 2

    Thanks buddy. Now it’s gone :)

  • Not at all. I don’t know if you know, but you can always mark the answer that helped you the most as correct. Just mark the V on the left side of the response

  • Scheduled. I had checked the time, but I needed to wait about 5 min. So I just booked the night. Thanks again!!!! :)

Browser other questions tagged

You are not signed in. Login or sign up in order to post.