-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
3 changed files
with
76 additions
and
9 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
<?php | ||
namespace Tests; | ||
use Illuminate\Foundation\Testing\WithoutMiddleware; | ||
use Illuminate\Foundation\Testing\DatabaseMigrations; | ||
use Illuminate\Foundation\Testing\DatabaseTransactions; | ||
use Illuminate\Support\Facades\Event; | ||
use Mockery; | ||
class FriendshipsEventsTest extends TestCase | ||
{ | ||
use DatabaseMigrations; | ||
|
||
public function setUp() | ||
{ | ||
parent::setUp(); | ||
|
||
$this->sender = createUser(); | ||
$this->recipient = createUser(); | ||
} | ||
|
||
public function tearDown() | ||
{ | ||
Mockery::close(); | ||
} | ||
|
||
/** @test */ | ||
public function friend_request_is_sent() | ||
{ | ||
Event::shouldReceive('fire')->once()->withArgs(['friendrequest.sent', Mockery::any()]); | ||
|
||
$this->sender->addfriend($this->recipient); | ||
} | ||
|
||
/** @test */ | ||
public function friend_request_is_accepted() | ||
{ | ||
$this->sender->addfriend($this->recipient); | ||
Event::shouldReceive('fire')->once()->withArgs(['friendrequest.accepted', Mockery::any()]); | ||
|
||
$this->recipient->acceptFriend($this->sender); | ||
} | ||
|
||
/** @test */ | ||
public function friendship_is_cancelled() | ||
{ | ||
$this->sender->addfriend($this->recipient); | ||
$this->recipient->acceptFriend($this->sender); | ||
Event::shouldReceive('fire')->once()->withArgs(['friendship.deleted', Mockery::any()]); | ||
|
||
$this->recipient->deleteFriend($this->sender); | ||
} | ||
} |