Files
Test-Eloquent-Relationships/tests/Feature/RelationshipsTest.php
T
2021-11-22 07:26:10 +02:00

33 lines
776 B
PHP

<?php
namespace Tests\Feature;
use App\Models\Task;
use App\Models\User;
use Illuminate\Foundation\Testing\RefreshDatabase;
use Tests\TestCase;
class RelationshipsTest extends TestCase
{
use RefreshDatabase;
// TASK: find out why this relationship fails, and fix it in Eloquent Model
public function test_user_create_task()
{
$user = User::factory()->create();
$response = $this->actingAs($user)->post('/tasks', [
'name' => 'Some task'
]);
$response->assertStatus(200);
}
// TASK: this table throws an error, fix it
public function test_task_with_no_user()
{
Task::create(['name' => 'Some task']);
$response = $this->get('/tasks');
$response->assertStatus(200);
}
}