-
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Co-authored-by: david_smith <[email protected]>
- Loading branch information
1 parent
3713df8
commit a3b2898
Showing
14 changed files
with
287 additions
and
41 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
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
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 Tests\Unit\MapOf\Required; | ||
|
||
use Zerotoprod\DataModel\DataModel; | ||
|
||
class Alias | ||
{ | ||
use DataModel; | ||
|
||
public string $id; | ||
public string $name; | ||
} |
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,21 @@ | ||
<?php | ||
|
||
namespace Tests\Unit\MapOf\Required; | ||
|
||
use PHPUnit\Framework\Attributes\Test; | ||
use Tests\TestCase; | ||
use Zerotoprod\DataModel\PropertyRequiredException; | ||
|
||
class RequireFalseTest extends TestCase | ||
{ | ||
#[Test] public function from(): void | ||
{ | ||
$UserFalse = UserFalse::from([ | ||
'Aliases' => [[ | ||
'id' => 'id' | ||
]] | ||
]); | ||
|
||
self::assertEquals('id', $UserFalse->Aliases[0]->id); | ||
} | ||
} |
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,16 @@ | ||
<?php | ||
|
||
namespace Tests\Unit\MapOf\Required; | ||
|
||
use PHPUnit\Framework\Attributes\Test; | ||
use Tests\TestCase; | ||
use Zerotoprod\DataModel\PropertyRequiredException; | ||
|
||
class RequireTest extends TestCase | ||
{ | ||
#[Test] public function from(): void | ||
{ | ||
$this->expectException(PropertyRequiredException::class); | ||
User::from(); | ||
} | ||
} |
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,16 @@ | ||
<?php | ||
|
||
namespace Tests\Unit\MapOf\Required; | ||
|
||
use PHPUnit\Framework\Attributes\Test; | ||
use Tests\TestCase; | ||
use Zerotoprod\DataModel\PropertyRequiredException; | ||
|
||
class RequireTrueTest extends TestCase | ||
{ | ||
#[Test] public function from(): void | ||
{ | ||
$this->expectException(PropertyRequiredException::class); | ||
UserTrue::from(); | ||
} | ||
} |
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,21 @@ | ||
<?php | ||
|
||
namespace Tests\Unit\MapOf\Required; | ||
|
||
use Zerotoprod\DataModel\DataModel; | ||
use Zerotoprod\DataModel\Describe; | ||
use Zerotoprod\DataModelHelper\DataModelHelper; | ||
|
||
class User | ||
{ | ||
use DataModel; | ||
use DataModelHelper; | ||
|
||
/** @var Alias[] $Aliases */ | ||
#[Describe([ | ||
'cast' => [self::class, 'mapOf'], | ||
'type' => Alias::class, | ||
'required' | ||
])] | ||
public ?array $Aliases; | ||
} |
Oops, something went wrong.