diff --git a/.travis.yml b/.travis.yml index cdc75f8..171803a 100644 --- a/.travis.yml +++ b/.travis.yml @@ -6,6 +6,7 @@ services: php: - 5.6 - 7.0 + - 7.2 addons: code_climate: @@ -20,7 +21,7 @@ cache: - $HOME/.composer/cache install: - - COMPOSER_DISCARD_CHANGES=1 composer install --dev --prefer-source --no-interaction + - COMPOSER_DISCARD_CHANGES=1 composer install --prefer-source --no-interaction before_script: - mysql -u root -e 'set global innodb_large_prefix=1;' @@ -33,7 +34,7 @@ before_script: - yes | cp tests/config/friendships.php vendor/laravel/laravel/config/friendships.php - yes | cp tests/Stub_User.php vendor/laravel/laravel/app/User.php - cd vendor/laravel/laravel - - composer update --dev --prefer-source --no-interaction + - composer update --prefer-source --no-interaction - perl -pi -w -e "s/'engine' => null,/'engine' => 'InnoDB ROW_FORMAT=DYNAMIC',/g;" config/database.php - php artisan migrate - cd - diff --git a/composer.json b/composer.json index b215aec..9acf41d 100644 --- a/composer.json +++ b/composer.json @@ -24,6 +24,8 @@ "php": ">=5.4.0" }, "require-dev": { + "beyondcode/laravel-dump-server": "^1.2", + "nunomaduro/collision": "3.*", "phpunit/phpunit" : "5.*", "fzaninotto/faker": "~1.4", "laravel/laravel": "5.*", diff --git a/src/Traits/Friendable.php b/src/Traits/Friendable.php index e19e7f0..4c58691 100755 --- a/src/Traits/Friendable.php +++ b/src/Traits/Friendable.php @@ -32,7 +32,7 @@ public function befriend(Model $recipient) $this->friends()->save($friendship); - Event::fire('friendships.sent', [$this, $recipient]); + Event::dispatch('friendships.sent', [$this, $recipient]); return $friendship; @@ -47,7 +47,7 @@ public function unfriend(Model $recipient) { $deleted = $this->findFriendship($recipient)->delete(); - Event::fire('friendships.cancelled', [$this, $recipient]); + Event::dispatch('friendships.cancelled', [$this, $recipient]); return $deleted; } @@ -93,7 +93,7 @@ public function acceptFriendRequest(Model $recipient) 'status' => Status::ACCEPTED, ]); - Event::fire('friendships.accepted', [$this, $recipient]); + Event::dispatch('friendships.accepted', [$this, $recipient]); return $updated; } @@ -109,7 +109,7 @@ public function denyFriendRequest(Model $recipient) 'status' => Status::DENIED, ]); - Event::fire('friendships.denied', [$this, $recipient]); + Event::dispatch('friendships.denied', [$this, $recipient]); return $updated; } @@ -191,7 +191,7 @@ public function blockFriend(Model $recipient) $this->friends()->save($friendship); - Event::fire('friendships.blocked', [$this, $recipient]); + Event::dispatch('friendships.blocked', [$this, $recipient]); return $friendship; } @@ -205,7 +205,7 @@ public function unblockFriend(Model $recipient) { $deleted = $this->findFriendship($recipient)->whereSender($this)->delete(); - Event::fire('friendships.unblocked', [$this, $recipient]); + Event::dispatch('friendships.unblocked', [$this, $recipient]); return $deleted; } diff --git a/tests/FriendshipsEventsTest.php b/tests/FriendshipsEventsTest.php index dc335fb..2249ff9 100644 --- a/tests/FriendshipsEventsTest.php +++ b/tests/FriendshipsEventsTest.php @@ -11,34 +11,34 @@ class FriendshipsEventsTest extends TestCase { // use DatabaseTransactions; - - public function setUp() + + public function setUp(): void { parent::setUp(); - + $this->sender = createUser(); $this->recipient = createUser(); } - - public function tearDown() + + public function tearDown(): void { Mockery::close(); } - + /** @test */ public function friend_request_is_sent() { - Event::shouldReceive('fire')->once()->withArgs(['friendships.sent', Mockery::any()]); - + Event::shouldReceive('dispatch')->once()->withArgs(['friendships.sent', Mockery::any()]); + $this->sender->befriend($this->recipient); } - + /** @test */ public function friend_request_is_accepted() { $this->sender->befriend($this->recipient); - Event::shouldReceive('fire')->once()->withArgs(['friendships.accepted', Mockery::any()]); - + Event::shouldReceive('dispatch')->once()->withArgs(['friendships.accepted', Mockery::any()]); + $this->recipient->acceptFriendRequest($this->sender); } @@ -46,8 +46,8 @@ public function friend_request_is_accepted() public function friend_request_is_denied() { $this->sender->befriend($this->recipient); - Event::shouldReceive('fire')->once()->withArgs(['friendships.denied', Mockery::any()]); - + Event::shouldReceive('dispatch')->once()->withArgs(['friendships.denied', Mockery::any()]); + $this->recipient->denyFriendRequest($this->sender); } @@ -56,29 +56,29 @@ public function friend_is_blocked() { $this->sender->befriend($this->recipient); $this->recipient->acceptFriendRequest($this->sender); - Event::shouldReceive('fire')->once()->withArgs(['friendships.blocked', Mockery::any()]); - + Event::shouldReceive('dispatch')->once()->withArgs(['friendships.blocked', Mockery::any()]); + $this->recipient->blockFriend($this->sender); } - + /** @test */ public function friend_is_unblocked() { $this->sender->befriend($this->recipient); $this->recipient->acceptFriendRequest($this->sender); $this->recipient->blockFriend($this->sender); - Event::shouldReceive('fire')->once()->withArgs(['friendships.unblocked', Mockery::any()]); - + Event::shouldReceive('dispatch')->once()->withArgs(['friendships.unblocked', Mockery::any()]); + $this->recipient->unblockFriend($this->sender); } - + /** @test */ public function friendship_is_cancelled() { $this->sender->befriend($this->recipient); $this->recipient->acceptFriendRequest($this->sender); - Event::shouldReceive('fire')->once()->withArgs(['friendships.cancelled', Mockery::any()]); - + Event::shouldReceive('dispatch')->once()->withArgs(['friendships.cancelled', Mockery::any()]); + $this->recipient->unfriend($this->sender); } -} \ No newline at end of file +}