Task 2 - array validation

This commit is contained in:
PovilasKorop
2021-11-29 12:52:36 +02:00
parent 4b02ab4815
commit b2e5f809ab
4 changed files with 57 additions and 0 deletions
+19
View File
@@ -2,6 +2,7 @@
namespace Tests\Feature;
use App\Models\User;
use Illuminate\Foundation\Testing\RefreshDatabase;
use Tests\TestCase;
@@ -23,4 +24,22 @@ class ValidationTest extends TestCase
$response = $this->post('posts', ['title' => 'Some title']);
$response->assertSessionHasErrors('title')->assertStatus(302);
}
public function test_array_validation()
{
$user = User::factory()->create();
// Post without name and email should fail
$response = $this->actingAs($user)->post('profile');
$response->assertStatus(302);
// Post with name and email should succeed
$response = $this->actingAs($user)->post('profile', [
'profile' => [
'name' => 'Some name',
'email' => 'some@email.com'
]
]);
$response->assertStatus(200);
}
}