You requested 1 items, but there are only 0 items available.
I have problem for example this test returns You requested 1 items, but there are only 0 items available. I was trying to dd($car) but i dont see anything in console what looks like dd of variable.
public function test_car_details_is_rendering_properly()
{
$user = User::factory()->create();
$this->actingAs($user);
$car = Car::factory()->create();
$response = $this->get("/cars/$car->id");
$response->assertStatus(200);
}
@Sinnbeck hard to say im just doing php artisan test
• Tests\Feature\CarTest > car details is rendering properly
PHPUnit\Framework\ExceptionWrapper
You requested 1 items, but there are only 0 items available.
at C:\xampp\htdocs\inzynierka\vendor\laravel\framework\src\Illuminate\Collections\Arr.php:632
628▕
629▕ $count = count($array);
630▕
631▕ if ($requested > $count) {
➜ 632▕ throw new InvalidArgumentException(
633▕ "You requested {$requested} items, but there are only {$count} items available."
634▕ );
635▕ }
636▕
1 C:\xampp\htdocs\inzynierka\vendor\phpunit\phpunit\phpunit:98
PHPUnit\TextUI\Command::main()
@tykus Oh this is the same error but for another test
• Tests\Feature\CarTest > car update form is rendering properly
PHPUnit\Framework\ExceptionWrapper
You requested 1 items, but there are only 0 items available.
at C:\xampp\htdocs\inzynierka\vendor\laravel\framework\src\Illuminate\Collections\Arr.php:632
628▕
629▕ $count = count($array);
630▕
631▕ if ($requested > $count) {
➜ 632▕ throw new InvalidArgumentException(
633▕ "You requested {$requested} items, but there are only {$count} items available."
634▕ );
635▕ }
636▕
1 C:\xampp\htdocs\inzynierka\vendor\phpunit\phpunit\phpunit:98
PHPUnit\TextUI\Command::main()
@raloseq So either Type or CarModel is empty (the tables), so you cannot get a random item. Create at least one of each before the factory for Car is run