The error "Unknown named parameter $user" occurs because you are trying to mock the service in your test, but the constructor of the class being tested has named parameters. To resolve this issue, you can use the getMockBuilder method from PHPUnit to create a mock object of the service and pass it as an argument to the constructor.
Here's an example of how you can modify your test to mock the service:
use PHPUnit\Framework\TestCase;
class YourTestClassTest extends TestCase
{
public function testYourMethod()
{
// Create a mock object of the service
$serviceMock = $this->getMockBuilder(Service::class)
->disableOriginalConstructor()
->getMock();
// Create an instance of the class being tested, passing the mock service as an argument
$yourClass = new YourClass($serviceMock);
// Perform your test assertions
// ...
}
}
Make sure to replace Service with the actual class name of your service. This way, you can mock the service and pass it as an argument to the constructor without encountering the "Unknown named parameter" error.