Skip to content

Commit

Permalink
add meta test
Browse files Browse the repository at this point in the history
  • Loading branch information
iamgergo committed Dec 30, 2023
1 parent eb5de3e commit 83cc87d
Show file tree
Hide file tree
Showing 2 changed files with 67 additions and 0 deletions.
37 changes: 37 additions & 0 deletions tests/Models/MetaTest.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
<?php

namespace Cone\Root\Tests\Models;

use Cone\Root\Models\Meta;
use Cone\Root\Tests\TestCase;
use Cone\Root\Tests\User;

class MetaTest extends TestCase
{
protected User $user;

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

$this->user = User::factory()->create();
}

public function test_a_meta_belongs_to_a_metable(): void
{
$meta = Meta::factory()->make();

$meta->metable()->associate($this->user)->save();

$this->assertTrue($meta->metable->is($this->user));
}

public function test_a_metable_model_has_meta_data(): void
{
$this->user->metaData()->save(
$meta = Meta::factory()->make()
);

$this->assertTrue($this->user->metaData->contains($meta));
}
}
30 changes: 30 additions & 0 deletions tests/Models/NotificationTest.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
<?php

namespace Cone\Root\Tests\Models;

use Cone\Root\Models\Notification;
use Cone\Root\Tests\TestCase;
use Cone\Root\Tests\User;

class NotificationTest extends TestCase
{
protected User $user;

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

$this->user = User::factory()->create();
}

public function test_a_notification_belongs_to_a_notifiable(): void
{
$notification = Notification::factory()->make();

$notification->notifiable()->associate($this->user);

$notification->save();

$this->assertTrue($notification->notifiable->is($this->user));
}
}

0 comments on commit 83cc87d

Please sign in to comment.