-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fixed trait/class collision, added mutator support
- Loading branch information
1 parent
10c3ab4
commit 3d18c2d
Showing
3 changed files
with
120 additions
and
12 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,56 @@ | ||
<?php | ||
/** | ||
* Contains the EnumMutatorTest class. | ||
* | ||
* @copyright Copyright (c) 2017 Attila Fulop | ||
* @author Attila Fulop | ||
* @license MIT | ||
* @since 2017-10-05 | ||
* | ||
*/ | ||
|
||
|
||
namespace Konekt\Enum\Eloquent\Tests; | ||
|
||
|
||
use Konekt\Enum\Eloquent\Tests\Models\Order; | ||
use Konekt\Enum\Eloquent\Tests\Models\OrderStatus; | ||
|
||
class EnumMutatorTest extends TestCase | ||
{ | ||
/** | ||
* @test | ||
*/ | ||
public function it_accepts_enum_object_when_setting_value() | ||
{ | ||
$order = Order::create([ | ||
'number' => 'NMLM1HQ', | ||
'status' => OrderStatus::SUBMITTED | ||
]); | ||
|
||
$this->assertTrue($order->status->equals(OrderStatus::SUBMITTED())); | ||
|
||
$order->status = OrderStatus::PROCESSING(); | ||
$order->save(); | ||
|
||
$this->assertTrue($order->status->equals(OrderStatus::PROCESSING())); | ||
} | ||
|
||
/** | ||
* @test | ||
*/ | ||
public function it_accepts_enums_primitive_value_as_well_when_setting_value() | ||
{ | ||
$order = Order::create([ | ||
'number' => 'TFOD578', | ||
'status' => OrderStatus::SUBMITTED | ||
]); | ||
|
||
$order->status = OrderStatus::PROCESSING; | ||
$order->save(); | ||
|
||
$this->assertTrue($order->status->equals(OrderStatus::PROCESSING())); | ||
|
||
} | ||
|
||
} |