79265899

Date: 2024-12-09 17:27:27
Score: 0.5
Natty:
Report link

You didn't provide your UserService class but I think it uses a User Model which means it tries to connect to a database. This fails since in the test environment, the database details (server, port, db name, user, password) are unknown. Please mind that the PHPUnit script will not bootstrap all these »magic« environment details like Laravel does. So, the Model class can't set up the connection (it equals to null). You have to mock a database connection for testing purposes. But, it's in general difficult to test classes oder methods that require a database connection.

Reasons:
  • Long answer (-0.5):
  • No code block (0.5):
  • Low reputation (0.5):
Posted by: Andreas