Fix listener test

This commit is contained in:
Bubka 2022-07-18 16:35:25 +02:00
parent 879cfac701
commit 64da81b5a7
2 changed files with 32 additions and 8 deletions

View File

@ -7,6 +7,7 @@ use App\Events\TwoFAccountDeleted;
use Tests\TestCase; use Tests\TestCase;
use App\Listeners\CleanIconStorage; use App\Listeners\CleanIconStorage;
use Illuminate\Support\Facades\Storage; use Illuminate\Support\Facades\Storage;
use Illuminate\Support\Facades\Event;
/** /**
@ -30,4 +31,15 @@ class CleanIconStorageTest extends TestCase
$this->assertNull($listener->handle($event)); $this->assertNull($listener->handle($event));
} }
public function test_CleanIconStorage_listen_to_TwoFAccountDeleted_event()
{
Event::fake();
Event::assertListening(
TwoFAccountDeleted::class,
CleanIconStorage::class
);
}
} }

View File

@ -4,21 +4,33 @@ namespace Tests\Unit\Listeners;
use App\Models\Group; use App\Models\Group;
use App\Events\GroupDeleting; use App\Events\GroupDeleting;
use Tests\FeatureTestCase; use Tests\TestCase;
use App\Listeners\DissociateTwofaccountFromGroup; use App\Listeners\DissociateTwofaccountFromGroup;
use Illuminate\Support\Facades\Event;
/** /**
* @covers \App\Listeners\DissociateTwofaccountFromGroup * @covers \App\Listeners\DissociateTwofaccountFromGroup
*/ */
class DissociateTwofaccountFromGroupTest extends FeatureTestCase class DissociateTwofaccountFromGroupTest extends TestCase
{ {
public function test_twofaccount_is_released_on_group_deletion() // public function test_twofaccount_is_released_on_group_deletion()
{ // {
$group = Group::factory()->make(); // $group = Group::factory()->make();
$event = new GroupDeleting($group); // $event = new GroupDeleting($group);
$listener = new DissociateTwofaccountFromGroup(); // $listener = new DissociateTwofaccountFromGroup();
$this->assertNull($listener->handle($event)); // $this->assertNull($listener->handle($event));
// }
public function test_DissociateTwofaccountFromGroup_listen_to_groupDeleting_event()
{
Event::fake();
Event::assertListening(
GroupDeleting::class,
DissociateTwofaccountFromGroup::class
);
} }
} }