Skip to content

Commit

Permalink
remove MocksApplicationServices trait
Browse files Browse the repository at this point in the history
  • Loading branch information
hkp22 committed Feb 14, 2023
1 parent d57d1e8 commit b4ba8fa
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 12 deletions.
17 changes: 11 additions & 6 deletions tests/Unit/ModelBannedEventTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,32 +2,37 @@

namespace Qirolab\Tests\Laravel\Bannable\Unit;

use Illuminate\Foundation\Testing\Concerns\MocksApplicationServices;
use Illuminate\Support\Facades\Event;
use Qirolab\Laravel\Bannable\Events\ModelWasBanned;
use Qirolab\Tests\Laravel\Bannable\Stubs\Models\User;
use Qirolab\Tests\Laravel\Bannable\TestCase;

class ModelBannedEventTest extends TestCase
{
use MocksApplicationServices;
protected function setUp(): void
{
parent::setUp();

Event::fake([ModelWasBanned::class]);
}

/** @test */
public function it_can_fire_event_on_helper_call()
{
$this->expectsEvents(ModelWasBanned::class);

$entity = $this->createUser(User::class);

$entity->ban();

Event::assertDispatched(ModelWasBanned::class);
}

/** @test */
public function it_can_fire_event_on_relation_create()
{
$this->expectsEvents(ModelWasBanned::class);

$entity = $this->createUser(User::class);

$entity->bans()->create();

Event::assertDispatched(ModelWasBanned::class);
}
}
17 changes: 11 additions & 6 deletions tests/Unit/ModelUnbannedEventTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,31 +2,36 @@

namespace Qirolab\Tests\Laravel\Bannable\Unit;

use Illuminate\Foundation\Testing\Concerns\MocksApplicationServices;
use Illuminate\Support\Facades\Event;
use Qirolab\Laravel\Bannable\Events\ModelWasUnbanned;
use Qirolab\Tests\Laravel\Bannable\TestCase;

class ModelUnbannedEventTest extends TestCase
{
use MocksApplicationServices;
protected function setUp(): void
{
parent::setUp();

Event::fake([ModelWasUnbanned::class]);
}

/** @test */
public function it_can_fire_event_on_helper_call()
{
$this->expectsEvents(ModelWasUnbanned::class);

$ban = $this->createBan();

$ban->bannable->unban();

Event::assertDispatched(ModelWasUnbanned::class);
}

/** @test */
public function it_can_fire_event_on_relation_delete()
{
$this->expectsEvents(ModelWasUnbanned::class);

$ban = $this->createBan();

$ban->delete();

Event::assertDispatched(ModelWasUnbanned::class);
}
}

0 comments on commit b4ba8fa

Please sign in to comment.