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

Add support for Laravel 6 #132

Open
wants to merge 20 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
7 changes: 4 additions & 3 deletions .travis.yml
100644 → 100755
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,9 @@ services:
- mysql

php:
- 5.6
- 7.0
- 7.2
- 7.3
- 7.4

addons:
code_climate:
Expand Down Expand Up @@ -35,7 +36,7 @@ before_script:
- cd vendor/laravel/laravel
- composer update --dev --prefer-source --no-interaction
- perl -pi -w -e "s/'engine' => null,/'engine' => 'InnoDB ROW_FORMAT=DYNAMIC',/g;" config/database.php
- php artisan migrate
- php artisan migrate --force
- cd -

script:
Expand Down
13 changes: 8 additions & 5 deletions composer.json
100644 → 100755
Original file line number Diff line number Diff line change
Expand Up @@ -21,15 +21,18 @@
}
},
"require": {
"php": ">=5.4.0"
"php": ">=7.2"
},
"require-dev": {
"phpunit/phpunit" : "5.*",
"beyondcode/laravel-dump-server": "^1.2",
"nunomaduro/collision": "3.*",
"phpunit/phpunit" : "^8.0",
"fzaninotto/faker": "~1.4",
"laravel/laravel": "5.*",
"laravel/laravel": "^6.0",
"codeclimate/php-test-reporter": "^0.3.2",
"mockery/mockery": "^0.9.5",
"doctrine/dbal": "^2.5"
"mockery/mockery": "^1.3",
"doctrine/dbal": "^2.5",
"facade/ignition": "^1.4"
},
"autoload": {
"psr-4": {
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: 23 additions & 21 deletions tests/FriendshipsEventsTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,74 +11,76 @@
class FriendshipsEventsTest extends TestCase
{
// use DatabaseTransactions;
public function setUp()

public function setUp(): void
{
parent::setUp();

Event::fake();

$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()]);

$this->sender->befriend($this->recipient);

Event::assertDispatched('friendships.sent');
}

/** @test */
public function friend_request_is_accepted()
{
$this->sender->befriend($this->recipient);
Event::shouldReceive('fire')->once()->withArgs(['friendships.accepted', Mockery::any()]);

$this->recipient->acceptFriendRequest($this->sender);

Event::assertDispatched('friendships.accepted');
}

/** @test */
public function friend_request_is_denied()
{
$this->sender->befriend($this->recipient);
Event::shouldReceive('fire')->once()->withArgs(['friendships.denied', Mockery::any()]);

$this->recipient->denyFriendRequest($this->sender);

Event::assertDispatched('friendships.denied');
}

/** @test */
public function friend_is_blocked()
{
$this->sender->befriend($this->recipient);
$this->recipient->acceptFriendRequest($this->sender);
Event::shouldReceive('fire')->once()->withArgs(['friendships.blocked', Mockery::any()]);

$this->recipient->blockFriend($this->sender);

Event::assertDispatched('friendships.blocked');
}

/** @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()]);

$this->recipient->unblockFriend($this->sender);

Event::assertDispatched('friendships.unblocked');
}

/** @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()]);

$this->recipient->unfriend($this->sender);

Event::assertDispatched('friendships.cancelled');
}
}
}