Commit c68b710a authored by bvipul's avatar bvipul

Added page delete test and remaining blog category test

parent 4de44480
......@@ -12,8 +12,8 @@ trait BlogCategoryRelationship
/**
* BlogCategories belongs to relationship with state.
*/
public function createdBy()
public function creator()
{
return $this->belongsTo(User::class, 'created_by', 'id');
return $this->belongsTo(User::class, 'created_by');
}
}
<?php
namespace Tests\Feature;
namespace Tests\Feature\Backend;
use Tests\TestCase;
use App\Models\BlogCategories\BlogCategory;
......@@ -45,15 +45,16 @@ class ManageBlogCategoriesTest extends TestCase
->assertSessionHasErrors('name');
}
// public function a_blog_category_requires_a_name_while_updating()
// {
// $this->actingAs($this->admin)->withExceptionHandling();
/** @test */
public function a_blog_category_requires_a_name_while_updating()
{
$this->actingAs($this->admin)->withExceptionHandling();
// $category = create(BlogCategory::class);
$category = create(BlogCategory::class);
// $this->post(route('admin.blogCategories.store'), $category->toArray())
// ->assertSessionHasErrors('name');
// }
$this->patch(route('admin.blogCategories.update', $category), ['name' => ''])
->assertSessionHasErrors('name');
}
/** @test */
public function a_user_can_update_a_blog_category()
......
......@@ -124,4 +124,16 @@ class ManagePagesTest extends TestCase
->post(route('admin.pages.store'), $page3)
->assertSessionHasErrors('description');
}
/** @test */
public function a_user_can_delete_a_page()
{
$this->actingAs($this->admin);
$page = create(Page::class);
$this->delete(route('admin.pages.destroy', $page));
$this->assertDatabaseMissing(config('module.pages.table'), ['name' => $page->name, 'id' => $page->id, 'deleted_at' => null]);
}
}
<?php
namespace Tests\Unit;
namespace Tests\Unit\Models;
use Tests\TestCase;
use App\Models\Access\User\User;
use App\Models\BlogCategories\BlogCategory;
use Illuminate\Foundation\Testing\WithFaker;
use Illuminate\Foundation\Testing\RefreshDatabase;
class BlogCategoryTest extends TestCase
{
/**
* A basic test example.
*
* @return void
*/
public function testExample()
/** @test */
public function it_has_a_creator()
{
$this->assertTrue(true);
$this->actingAs($this->admin);
$category = create(BlogCategory::class, ['created_by' => access()->id()]);
$this->assertInstanceOf(User::class, $category->creator);
$this->assertEquals($category->creator->id, access()->id());
}
}
<?php
namespace Tests\Unit;
namespace Tests\Unit\Models;
use Tests\TestCase;
use App\Models\Page\Page;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment