浏览代码

Fix listener test

Bubka 3 年之前
父节点
当前提交
64da81b5a7

+ 12 - 0
tests/Unit/Listeners/CleanIconStorageTest.php

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

+ 19 - 7
tests/Unit/Listeners/DissociateTwofaccountFromGroupTest.php

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