Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support for laravel 5.8 #124

Open
wants to merge 11 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 3 additions & 2 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ services:
php:
- 5.6
- 7.0
- 7.2

addons:
code_climate:
Expand All @@ -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;'
Expand All @@ -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 -
Expand Down
2 changes: 2 additions & 0 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -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.*",
Expand Down
12 changes: 6 additions & 6 deletions src/Traits/Friendable.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand All @@ -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;
}
Expand Down Expand Up @@ -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;
}
Expand All @@ -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;
}
Expand Down Expand Up @@ -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;
}
Expand All @@ -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;
}
Expand Down
44 changes: 22 additions & 22 deletions tests/FriendshipsEventsTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,43 +11,43 @@
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);
}

/** @test */
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);
}

Expand All @@ -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);
}
}
}