This commit is contained in:
Marley Rae 2022-04-28 12:19:17 -07:00
parent 7b77a131ac
commit 0afc8911db

View file

@ -15,7 +15,7 @@
'status' => 'current', 'status' => 'current',
'slug' => faker()->slug(2), 'slug' => faker()->slug(2),
'title' => faker()->sentence(), 'title' => faker()->sentence(),
'opened' => faker()->dateTimeThisMonth(), 'opened' => '04/14/2022',
'hold_member_updates' => faker()->boolean(), 'hold_member_updates' => faker()->boolean(),
'notify_pending' => faker()->boolean(), 'notify_pending' => faker()->boolean(),
]; ];
@ -43,28 +43,28 @@
unset($this->request['categories']); unset($this->request['categories']);
$response = $this->actingAs($this->user)->post('/fanatic/owned', $this->request); $response = $this->actingAs($this->user)->post('/fanatic/owned', $this->request);
$response->assertInvalid(); $response->assertInvalid(['categories']);
}); });
it('fails non-array categories', function () { it('fails non-array categories', function () {
$this->request['categories'] = 'This is not an array.'; $this->request['categories'] = 'This is not an array.';
$response = $this->actingAs($this->user)->post('/fanatic/owned', $this->request); $response = $this->actingAs($this->user)->post('/fanatic/owned', $this->request);
$response->assertInvalid(); $response->assertInvalid(['categories']);
}); });
it('fails empty categories array', function () { it('fails empty categories array', function () {
$this->request['categories'] = []; $this->request['categories'] = [];
$response = $this->actingAs($this->user)->post('/fanatic/owned', $this->request); $response = $this->actingAs($this->user)->post('/fanatic/owned', $this->request);
$response->assertInvalid(); $response->assertInvalid(['categories']);
}); });
it('fails non-numeric category item', function () { it('fails non-numeric category item', function () {
$this->request['categories'][] = 'a'; $this->request['categories'][] = 'a';
$response = $this->actingAs($this->user)->post('/fanatic/owned', $this->request); $response = $this->actingAs($this->user)->post('/fanatic/owned', $this->request);
$response->assertInvalid(); $response->assertInvalid(['categories.3']);
}); });
it('fails non-existant category', function () { it('fails non-existant category', function () {
@ -72,91 +72,91 @@
$this->request['categories'][] = $invalidCat; $this->request['categories'][] = $invalidCat;
$response = $this->actingAs($this->user)->post('/fanatic/owned', $this->request); $response = $this->actingAs($this->user)->post('/fanatic/owned', $this->request);
$response->assertInvalid(); $response->assertInvalid(['categories.3']);
}); });
it('fails missing subject', function () { it('fails missing subject', function () {
unset($this->request['subject']); unset($this->request['subject']);
$response = $this->actingAs($this->user)->post('/fanatic/owned', $this->request); $response = $this->actingAs($this->user)->post('/fanatic/owned', $this->request);
$response->assertInvalid(); $response->assertInvalid(['subject']);
}); });
it('fails non-string subject', function () { it('fails non-string subject', function () {
$this->request['subject'] = 39502; $this->request['subject'] = 39502;
$response = $this->actingAs($this->user)->post('/fanatic/owned', $this->request); $response = $this->actingAs($this->user)->post('/fanatic/owned', $this->request);
$response->assertInvalid(); $response->assertInvalid(['subject']);
}); });
it('fails missing status', function () { it('fails missing status', function () {
unset($this->request['status']); unset($this->request['status']);
$response = $this->actingAs($this->user)->post('/fanatic/owned', $this->request); $response = $this->actingAs($this->user)->post('/fanatic/owned', $this->request);
$response->assertInvalid(); $response->assertInvalid(['status']);
}); });
it('fails non-valid status', function () { it('fails non-valid status', function () {
$this->request['status'] = 'This is not a correct status.'; $this->request['status'] = 'This is not a correct status.';
$response = $this->actingAs($this->user)->post('/fanatic/owned', $this->request); $response = $this->actingAs($this->user)->post('/fanatic/owned', $this->request);
$response->assertInvalid(); $response->assertInvalid(['status']);
}); });
it('fails missing slug', function () { it('fails missing slug', function () {
unset($this->request['slug']); unset($this->request['slug']);
$response = $this->actingAs($this->user)->post('/fanatic/owned', $this->request); $response = $this->actingAs($this->user)->post('/fanatic/owned', $this->request);
$response->assertInvalid(); $response->assertInvalid(['slug']);
}); });
it('fails non-valid slug format', function () { it('fails non-valid slug format', function () {
$this->request['slug'] = 'This is not a valid slug.'; $this->request['slug'] = 'This is not a valid slug.';
$response = $this->actingAs($this->user)->post('/fanatic/owned', $this->request); $response = $this->actingAs($this->user)->post('/fanatic/owned', $this->request);
$response->assertInvalid(); $response->assertInvalid(['slug']);
}); });
it('allows null title', function () { it('allows null title', function () {
unset($this->request['title']); unset($this->request['title']);
$response = $this->actingAs($this->user)->post('/fanatic/owned', $this->request); $response = $this->actingAs($this->user)->post('/fanatic/owned', $this->request);
$response->assertValid(); $response->assertValid(['title']);
}); });
it('fails non-string title', function () { it('fails non-string title', function () {
$this->request['title'] = 494920; $this->request['title'] = 494920;
$response = $this->actingAs($this->user)->post('/fanatic/owned', $this->request); $response = $this->actingAs($this->user)->post('/fanatic/owned', $this->request);
$response->assertInvalid(); $response->assertInvalid(['title']);
}); });
it('allows null opened', function () { it('allows null opened', function () {
unset($this->request['opened']); unset($this->request['opened']);
$response = $this->actingAs($this->user)->post('/fanatic/owned', $this->request); $response = $this->actingAs($this->user)->post('/fanatic/owned', $this->request);
$response->assertValid(); $response->assertValid(['opened']);
}); });
it('fails non-date opened', function () { it('fails non-date opened', function () {
$this->request['opened'] = 'This is not a date.'; $this->request['opened'] = 'This is not a date.';
$response = $this->actingAs($this->user)->post('/fanatic/owned', $this->request); $response = $this->actingAs($this->user)->post('/fanatic/owned', $this->request);
$response->assertInvalid(); $response->assertInvalid(['opened']);
}); });
it('allows null hold_member_updates', function () { it('allows null hold_member_updates', function () {
unset($this->request['hold_member_updates']); unset($this->request['hold_member_updates']);
$response = $this->actingAs($this->user)->post('/fanatic/owned', $this->request); $response = $this->actingAs($this->user)->post('/fanatic/owned', $this->request);
$response->assertValid(); $response->assertValid(['hold_member_updates']);
}); });
it('fails non-bool hold_member_updates', function () { it('fails non-bool hold_member_updates', function () {
$this->request['holds_member_updates'] = 'This is not a boolean.'; $this->request['hold_member_updates'] = 'This is not a boolean.';
$response = $this->actingAs($this->user)->post('/fanatic/owned', $this->request); $response = $this->actingAs($this->user)->post('/fanatic/owned', $this->request);
$response->assertInvalid(); $response->assertInvalid(['hold_member_updates']);
}); });
it('saves model to database', function () { it('saves model to database', function () {