Level 1
This cannot be done as this is PHPUnit and it's a component outside Laravel. However, you can create a new object in your setUp() function in your test.
How would I inject dependencies that help test my application? I currently have this:
use App\Services\Faker\ListingFaker;
class ListingApiTest extends TestCase
{
protected $listingFaker;
public function __construct(ListingFaker $listingFaker)
{
$this->listingFaker = $listingFaker;
}
and I'm getting the following error:
Catchable fatal error: Argument 1 passed to ListingApiTest::__construct() must be an instance of App\Services\Faker\ListingFaker,
The reason why I cannot use a factory for this is because the functionality to create fake data cannot be done with a factory.
Please or to participate in this conversation.