-
-
Notifications
You must be signed in to change notification settings - Fork 3
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
3 changed files
with
68 additions
and
0 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,31 @@ | ||
<?php | ||
|
||
namespace Cone\Root\Tests\Fields; | ||
|
||
use Cone\Root\Fields\HasMany; | ||
use Cone\Root\Models\Medium; | ||
use Cone\Root\Tests\TestCase; | ||
use Cone\Root\Tests\User; | ||
|
||
class HasManyTest extends TestCase | ||
{ | ||
protected HasMany $field; | ||
|
||
public function setUp(): void | ||
{ | ||
parent::setUp(); | ||
|
||
$this->field = new HasMany('Uploads'); | ||
} | ||
|
||
public function test_a_has_many_field_hydates_model(): void | ||
{ | ||
$user = User::factory()->create(); | ||
|
||
$medium = Medium::factory()->create(); | ||
|
||
$this->field->resolveHydrate($this->app['request'], $user, [$medium->getKey()]); | ||
|
||
$this->assertTrue($user->uploads->contains($medium)); | ||
} | ||
} |
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,31 @@ | ||
<?php | ||
|
||
namespace Cone\Root\Tests\Fields; | ||
|
||
use Cone\Root\Fields\HasOne; | ||
use Cone\Root\Models\Medium; | ||
use Cone\Root\Tests\TestCase; | ||
use Cone\Root\Tests\User; | ||
|
||
class HasOneTest extends TestCase | ||
{ | ||
protected HasOne $field; | ||
|
||
public function setUp(): void | ||
{ | ||
parent::setUp(); | ||
|
||
$this->field = new HasOne('Latest Upload', 'latestUpload'); | ||
} | ||
|
||
public function test_a_has_one_field_hydates_model(): void | ||
{ | ||
$user = User::factory()->create(); | ||
|
||
$medium = Medium::factory()->create(); | ||
|
||
$this->field->resolveHydrate($this->app['request'], $user, $medium->getKey()); | ||
|
||
$this->assertTrue($user->latestUpload->is($medium)); | ||
} | ||
} |
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