Commit ec1d8544 authored by Viral Solani's avatar Viral Solani

add test cases for History

parent 2fb7e180
<?php
use Tests\BrowserKitTestCase;
/**
* Class HistoryRenderTypeTest.
*/
class HistoryRenderTypeTest extends BrowserKitTestCase
{
public function testViewOnlyHasHistoryOfType()
{
$this->actingAs($this->admin);
history()
->withType('User')
->withText('trans("history.backend.users.created") '.$this->user->name)
->withEntity($this->user->id)
->withIcon('plus')
->withClass('bg-green')
->log();
history()
->withType('User')
->withText('trans("history.backend.users.updated") '.$this->user->name)
->withEntity($this->user->id)
->withIcon('pencil')
->withClass('bg-blue')
->log();
history()
->withType('User')
->withText('trans("history.backend.users.deleted") '.$this->user->name)
->withEntity($this->user->id)
->withIcon('trash')
->withClass('bg-red')
->log();
history()
->withType('Role')
->withText('trans("history.backend.roles.created") '.$this->adminRole->name)
->withEntity($this->adminRole->id)
->withIcon('plus')
->withClass('bg-red')
->log();
history()
->withType('Role')
->withText('trans("history.backend.roles.updated") '.$this->adminRole->name)
->withEntity($this->adminRole->id)
->withIcon('pencil')
->withClass('bg-red')
->log();
history()
->withType('Role')
->withText('trans("history.backend.roles.deleted") ')
->withEntity($this->adminRole->id)
->withIcon('trash')
->withClass('bg-red')
->log();
$this->visit('/admin/access/user')
->see('<strong>'.$this->admin->name.'</strong> created user '.$this->user->name)
->see('<strong>'.$this->admin->name.'</strong> updated user '.$this->user->name)
->see('<strong>'.$this->admin->name.'</strong> deleted user '.$this->user->name)
->dontSee('<strong>'.$this->admin->name.'</strong> created role '.$this->adminRole->name)
->dontSee('<strong>'.$this->admin->name.'</strong> updated role '.$this->adminRole->name)
->dontSee('<strong>'.$this->admin->name.'</strong> deleted role '.$this->adminRole->name);
}
}
<?php <?php
namespace Tests\Feature\Backend\History;
use Tests\BrowserKitTestCase; use Tests\BrowserKitTestCase;
/** /**
...@@ -7,7 +9,8 @@ use Tests\BrowserKitTestCase; ...@@ -7,7 +9,8 @@ use Tests\BrowserKitTestCase;
*/ */
class HistoryLogTest extends BrowserKitTestCase class HistoryLogTest extends BrowserKitTestCase
{ {
public function testHistoryLogByTypeNameFunction() /** @test **/
public function history_log_by_type_name_function()
{ {
$this->actingAs($this->admin); $this->actingAs($this->admin);
...@@ -32,7 +35,8 @@ class HistoryLogTest extends BrowserKitTestCase ...@@ -32,7 +35,8 @@ class HistoryLogTest extends BrowserKitTestCase
->see('<strong>'.$this->admin->name.'</strong> '.trans('history.backend.users.created').$this->user->name); ->see('<strong>'.$this->admin->name.'</strong> '.trans('history.backend.users.created').$this->user->name);
} }
public function testHistoryLogByTypeIdFunction() /** @test **/
public function history_log_By_TypeId_Function()
{ {
$this->actingAs($this->admin); $this->actingAs($this->admin);
......
<?php <?php
use App\Models\Access\User\User; namespace Tests\Feature\Backend\History;
use Tests\BrowserKitTestCase; use Tests\BrowserKitTestCase;
use App\Models\Access\User\User;
/** /**
* Class HistoryRenderEntityTest. * Class HistoryRenderEntityTest.
*/ */
class HistoryRenderEntityTest extends BrowserKitTestCase class HistoryRenderEntityTest extends BrowserKitTestCase
{ {
public function testViewOnlyHasHistoryOfEntity() /** @test **/
public function users_can_see_history_of_entity()
{ {
$this->actingAs($this->admin); $this->actingAs($this->admin);
......
<?php <?php
namespace Tests\Feature\Backend\History;
use Tests\BrowserKitTestCase; use Tests\BrowserKitTestCase;
/** /**
...@@ -7,7 +9,8 @@ use Tests\BrowserKitTestCase; ...@@ -7,7 +9,8 @@ use Tests\BrowserKitTestCase;
*/ */
class HistoryRenderTest extends BrowserKitTestCase class HistoryRenderTest extends BrowserKitTestCase
{ {
public function testDashboardDisplaysHistory() /** @test **/
public function admin_users_can_see_history_on_dashboard()
{ {
$this->actingAs($this->admin); $this->actingAs($this->admin);
...@@ -23,23 +26,8 @@ class HistoryRenderTest extends BrowserKitTestCase ...@@ -23,23 +26,8 @@ class HistoryRenderTest extends BrowserKitTestCase
->see('<strong>'.$this->admin->name.'</strong> '.trans('history.backend.users.created').$this->user->name); ->see('<strong>'.$this->admin->name.'</strong> '.trans('history.backend.users.created').$this->user->name);
} }
public function testTypeDisplaysHistory() /** @test **/
{ public function admin_users_can_see_history_on_user_show_page()
$this->actingAs($this->admin);
history()
->withType('User')
->withText(trans('history.backend.users.created').$this->user->name)
->withEntity($this->user->id)
->withIcon('plus')
->withClass('bg-green')
->log();
$this->visit('/admin/access/user')
->see('<strong>'.$this->admin->name.'</strong> '.trans('history.backend.users.created').$this->user->name);
}
public function testEntityDisplaysHistory()
{ {
$this->actingAs($this->admin); $this->actingAs($this->admin);
......
<?php <?php
namespace Tests\Feature; namespace Tests\Feature\Backend;
use App\Models\Page\Page; use App\Models\Page\Page;
use Tests\TestCase; use Tests\TestCase;
......
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