DissociateTwofaccountFromGroupTest.php 1.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152
  1. <?php
  2. namespace Tests\Unit\Listeners;
  3. use App\Events\GroupDeleting;
  4. use App\Listeners\DissociateTwofaccountFromGroup;
  5. use App\Models\Group;
  6. use App\Models\TwoFAccount;
  7. use Illuminate\Support\Facades\Event;
  8. use Mockery\MockInterface;
  9. use Tests\TestCase;
  10. /**
  11. * @covers \App\Listeners\DissociateTwofaccountFromGroup
  12. */
  13. class DissociateTwofaccountFromGroupTest extends TestCase
  14. {
  15. /**
  16. * @test
  17. *
  18. * @runInSeparateProcess
  19. *
  20. * @preserveGlobalState disabled
  21. */
  22. public function test_twofaccount_is_released_on_group_deletion()
  23. {
  24. $this->mock('alias:' . TwoFAccount::class, function (MockInterface $twoFAccount) {
  25. $twoFAccount->shouldReceive('where->update')
  26. ->once()
  27. ->andReturn(1);
  28. });
  29. $group = Group::factory()->make();
  30. $event = new GroupDeleting($group);
  31. $listener = new DissociateTwofaccountFromGroup();
  32. $this->assertNull($listener->handle($event));
  33. }
  34. /**
  35. * @test
  36. */
  37. public function test_DissociateTwofaccountFromGroup_listen_to_groupDeleting_event()
  38. {
  39. Event::fake();
  40. Event::assertListening(
  41. GroupDeleting::class,
  42. DissociateTwofaccountFromGroup::class
  43. );
  44. }
  45. }