generated from spatie/package-skeleton-laravel
-
-
Notifications
You must be signed in to change notification settings - Fork 0
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
4 changed files
with
96 additions
and
8 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
<?php | ||
|
||
|
||
namespace Kilobyteno\LaravelUserGuestLike\Tests; | ||
|
||
use Kilobyteno\LaravelUserGuestLike\Tests\Models\TestAuthorModel; | ||
use Kilobyteno\LaravelUserGuestLike\Tests\Models\TestModel; | ||
|
||
class HasUserGuestLikeTest extends TestCase | ||
{ | ||
/** @var TestModel */ | ||
protected TestModel $testModel; | ||
protected TestAuthorModel $author; | ||
|
||
public function setUp(): void | ||
{ | ||
parent::setUp(); | ||
|
||
$this->testModel = TestModel::create([ | ||
'name' => 'Test Model', | ||
]); | ||
|
||
$this->author = TestAuthorModel::create([ | ||
'name' => 'Test Author', | ||
]); | ||
} | ||
|
||
/** @test */ | ||
public function it_can_be_liked_by_a_user() | ||
{ | ||
$this->testModel->like($this->author); | ||
|
||
$this->assertEquals(1, $this->testModel->likes()->count()); | ||
} | ||
|
||
/** @test */ | ||
public function it_can_be_unliked_by_a_user() | ||
{ | ||
$this->testModel->like($this->author); | ||
$this->testModel->dislike($this->author); | ||
|
||
$this->assertEquals(0, $this->testModel->likes()->count()); | ||
} | ||
|
||
} |
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,11 @@ | ||
<?php | ||
|
||
namespace Kilobyteno\LaravelUserGuestLike\Tests\Models; | ||
|
||
use Illuminate\Database\Eloquent\Model; | ||
|
||
class TestAuthorModel extends Model | ||
{ | ||
protected $table = 'users'; | ||
protected $guarded = []; | ||
} |
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,13 @@ | ||
<?php | ||
|
||
namespace Kilobyteno\LaravelUserGuestLike\Tests\Models; | ||
|
||
use Illuminate\Database\Eloquent\Model; | ||
use Kilobyteno\LaravelUserGuestLike\Traits\HasUserGuestLike; | ||
|
||
class TestModel extends Model | ||
{ | ||
use HasUserGuestLike; | ||
protected $table = 'posts'; | ||
protected $guarded = []; | ||
} |
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