Skip to content

Commit

Permalink
Fix tests.
Browse files Browse the repository at this point in the history
  • Loading branch information
daniel-cintra committed Jun 3, 2024
1 parent 4f45d74 commit f208982
Show file tree
Hide file tree
Showing 3 changed files with 34 additions and 34 deletions.
22 changes: 11 additions & 11 deletions stubs/modules/Blog/Tests/AuthorTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -22,12 +22,12 @@

afterEach(function () {
if ($this->author->image) {
Storage::disk('public')->delete('blog/'.$this->author->image);
Storage::disk('public')->delete('blog/' . $this->author->image);
}
});

test('author list can be rendered', function () {
$response = $this->loggedRequest->get('/blog-author');
$response = $this->loggedRequest->get('/admin/blog-author');

$response->assertStatus(200);

Expand All @@ -49,7 +49,7 @@
});

test('author create page can be rendered', function () {
$response = $this->loggedRequest->get('/blog-author/create');
$response = $this->loggedRequest->get('/admin/blog-author/create');

$response->assertStatus(200);

Expand All @@ -60,7 +60,7 @@
});

test('author can be created', function () {
$response = $this->loggedRequest->post('/blog-author', [
$response = $this->loggedRequest->post('/admin/blog-author', [
'name' => 'New Name',
'bio' => 'New Bio',
'email' => 'new@email.com',
Expand All @@ -70,13 +70,13 @@

$authors = Author::all();

$response->assertRedirect('/blog-author');
$response->assertRedirect('/admin/blog-author');
$this->assertCount(2, $authors);
$this->assertEquals('New Name', $authors->last()->name);
});

test('author edit page can be rendered', function () {
$response = $this->loggedRequest->get('/blog-author/'.$this->author->id.'/edit');
$response = $this->loggedRequest->get('/admin/blog-author/' . $this->author->id . '/edit');

$response->assertStatus(200);

Expand All @@ -99,14 +99,14 @@
});

test('author can be updated', function () {
$response = $this->loggedRequest->put('/blog-author/'.$this->author->id, [
$response = $this->loggedRequest->put('/admin/blog-author/' . $this->author->id, [
'name' => 'New Name',
'email' => 'new@email.com',
]);

$response->assertRedirect('/blog-author');
$response->assertRedirect('/admin/blog-author');

$redirectResponse = $this->loggedRequest->get('/blog-author');
$redirectResponse = $this->loggedRequest->get('/admin/blog-author');
$redirectResponse->assertInertia(
fn (Assert $page) => $page
->component('BlogAuthor/AuthorIndex')
Expand All @@ -125,9 +125,9 @@
});

test('author can be deleted', function () {
$response = $this->loggedRequest->delete('/blog-author/'.$this->user->id);
$response = $this->loggedRequest->delete('/admin/blog-author/' . $this->user->id);

$response->assertRedirect('/blog-author');
$response->assertRedirect('/admin/blog-author');

$this->assertCount(0, Author::all());
});
22 changes: 11 additions & 11 deletions stubs/modules/Blog/Tests/CategoryTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -23,12 +23,12 @@

afterEach(function () {
if ($this->category->image) {
Storage::disk('public')->delete('blog/'.$this->category->image);
Storage::disk('public')->delete('blog/' . $this->category->image);
}
});

test('category list can be rendered', function () {
$response = $this->loggedRequest->get('/blog-category');
$response = $this->loggedRequest->get('/admin/blog-category');

$response->assertStatus(200);

Expand All @@ -48,7 +48,7 @@
});

test('category create page can be rendered', function () {
$response = $this->loggedRequest->get('/blog-category/create');
$response = $this->loggedRequest->get('/admin/blog-category/create');

$response->assertStatus(200);

Expand All @@ -59,7 +59,7 @@
});

test('category can be created', function () {
$response = $this->loggedRequest->post('/blog-category', [
$response = $this->loggedRequest->post('/admin/blog-category', [
'name' => 'Name',
'description' => 'Description',
'is_visible' => true,
Expand All @@ -69,13 +69,13 @@

$categories = Category::all();

$response->assertRedirect('/blog-category');
$response->assertRedirect('/admin/blog-category');
$this->assertCount(2, $categories);
$this->assertEquals('Name', $categories->last()->name);
});

test('category edit page can be rendered', function () {
$response = $this->loggedRequest->get('/blog-category/'.$this->category->id.'/edit');
$response = $this->loggedRequest->get('/admin/blog-category/' . $this->category->id . '/edit');

$response->assertStatus(200);

Expand All @@ -99,14 +99,14 @@
});

test('category can be updated', function () {
$response = $this->loggedRequest->put('/blog-category/'.$this->category->id, [
$response = $this->loggedRequest->put('/admin/blog-category/' . $this->category->id, [
'name' => 'New Name',
'is_visible' => true,
]);

$response->assertRedirect('/blog-category');
$response->assertRedirect('/admin/blog-category');

$redirectResponse = $this->loggedRequest->get('/blog-category');
$redirectResponse = $this->loggedRequest->get('/admin/blog-category');
$redirectResponse->assertInertia(
fn (Assert $page) => $page
->component('BlogCategory/CategoryIndex')
Expand All @@ -123,9 +123,9 @@
});

test('category can be deleted', function () {
$response = $this->loggedRequest->delete('/blog-category/'.$this->user->id);
$response = $this->loggedRequest->delete('/admin/blog-category/' . $this->user->id);

$response->assertRedirect('/blog-category');
$response->assertRedirect('/admin/blog-category');

$this->assertCount(0, Category::all());
});
24 changes: 12 additions & 12 deletions stubs/modules/Blog/Tests/PostTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -22,12 +22,12 @@

afterEach(function () {
if ($this->post->image) {
Storage::disk('public')->delete('blog/'.$this->post->image);
Storage::disk('public')->delete('blog/' . $this->post->image);
}
});

test('post list can be rendered', function () {
$response = $this->loggedRequest->get('/blog-post');
$response = $this->loggedRequest->get('/admin/blog-post');

$response->assertStatus(200);

Expand All @@ -47,7 +47,7 @@
});

test('post create page can be rendered', function () {
$response = $this->loggedRequest->get('/blog-post/create');
$response = $this->loggedRequest->get('/admin/blog-post/create');

$response->assertStatus(200);

Expand All @@ -58,7 +58,7 @@
});

test('post can be created', function () {
$response = $this->loggedRequest->post('/blog-post', [
$response = $this->loggedRequest->post('/admin/blog-post', [
'blog_author_id' => null,
'blog_category_id' => null,
'title' => 'Post Title',
Expand All @@ -71,13 +71,13 @@

$posts = Post::all();

$response->assertRedirect('/blog-post');
$response->assertRedirect('/admin/blog-post');
$this->assertCount(2, $posts);
$this->assertEquals('Post Title', $posts->last()->title);
});

test('post edit page can be rendered', function () {
$response = $this->loggedRequest->get('/blog-post/'.$this->post->id.'/edit');
$response = $this->loggedRequest->get('/admin/blog-post/' . $this->post->id . '/edit');

$response->assertStatus(200);

Expand All @@ -98,13 +98,13 @@
->where('meta_tag_title', $this->post->meta_tag_title)
->where('meta_tag_description', $this->post->meta_tag_description)
->where('tags', [])
->where('published_at', $this->post->published_at->toJSON())
->where('published_at', $this->post->published_at->toDateString())
)
);
});

test('post can be updated', function () {
$response = $this->loggedRequest->put('/blog-post/'.$this->post->id, [
$response = $this->loggedRequest->put('/admin/blog-post/' . $this->post->id, [
'blog_author_id' => null,
'blog_category_id' => null,
'title' => 'New Post Title',
Expand All @@ -114,9 +114,9 @@
'published_at' => '2023-12-13',
]);

$response->assertRedirect('/blog-post');
$response->assertRedirect('/admin/blog-post');

$redirectResponse = $this->loggedRequest->get('/blog-post');
$redirectResponse = $this->loggedRequest->get('/admin/blog-post');
$redirectResponse->assertInertia(
fn (Assert $page) => $page
->component('BlogPost/PostIndex')
Expand All @@ -133,9 +133,9 @@
});

test('post can be deleted', function () {
$response = $this->loggedRequest->delete('/blog-post/'.$this->user->id);
$response = $this->loggedRequest->delete('/admin/blog-post/' . $this->user->id);

$response->assertRedirect('/blog-post');
$response->assertRedirect('/admin/blog-post');

$this->assertCount(0, Post::all());
});

0 comments on commit f208982

Please sign in to comment.