File tree 2 files changed +19
-1
lines changed 2 files changed +19
-1
lines changed Original file line number Diff line number Diff line change @@ -43,7 +43,9 @@ public function __construct(
43
43
44
44
public function fill (array $ attributes )
45
45
{
46
- if ($ minor = $ attributes ['minor ' ] ?? null ) {
46
+ $ minor = $ attributes ['minor ' ] ?? null ;
47
+
48
+ if (! is_null ($ minor )) {
47
49
$ attributes ['amount ' ] = $ minor ;
48
50
} else if (($ amount = $ attributes ['amount ' ] ?? null ) && ($ currency = $ attributes ['currency ' ] ?? null )) {
49
51
$ attributes ['amount ' ] = Money::of ($ amount , $ currency )->getMinorAmount ()->toInt ();
Original file line number Diff line number Diff line change 32
32
$ this ->assertSame ('EUR ' , $ price ->currency );
33
33
});
34
34
35
+ test ('a price instance can be created with a minor value of 0 ' , function () {
36
+ $ price = new Price (
37
+ type: 'selling ' ,
38
+ minor: 0 ,
39
+ currency: 'EUR ' ,
40
+ activated_at: now ()->addWeek ()
41
+ );
42
+
43
+ $ this ->assertNotNull ($ price );
44
+ $ this ->assertInstanceOf (Price::class, $ price );
45
+ $ this ->assertSame ('selling ' , $ price ->type );
46
+ $ this ->assertNotNull ($ price ->amount );
47
+ $ this ->assertSame (0 , $ price ->amount );
48
+ $ this ->assertSame ('EUR ' , $ price ->currency );
49
+ });
50
+
35
51
test ('a price instance can be created from a minor value using a constructor arguments array ' , function () {
36
52
$ price = new Price ([
37
53
'type ' => 'selling ' ,
You can’t perform that action at this time.
0 commit comments