File tree Expand file tree Collapse file tree 3 files changed +9
-23
lines changed Expand file tree Collapse file tree 3 files changed +9
-23
lines changed Original file line number Diff line number Diff line change 6
6
7
7
use Generator ;
8
8
use MongoDB \BSON \Binary ;
9
- use MongoDB \Laravel \Tests \Models \CastBinaryUuid ;
9
+ use MongoDB \Laravel \Tests \Models \Casting ;
10
10
use MongoDB \Laravel \Tests \TestCase ;
11
11
12
12
use function hex2bin ;
@@ -17,15 +17,15 @@ protected function setUp(): void
17
17
{
18
18
parent ::setUp ();
19
19
20
- CastBinaryUuid ::truncate ();
20
+ Casting ::truncate ();
21
21
}
22
22
23
23
/** @dataProvider provideBinaryUuidCast */
24
24
public function testBinaryUuidCastModel (string $ expectedUuid , string |Binary $ saveUuid , Binary $ queryUuid ): void
25
25
{
26
- CastBinaryUuid ::create (['uuid ' => $ saveUuid ]);
26
+ Casting ::create (['uuid ' => $ saveUuid ]);
27
27
28
- $ model = CastBinaryUuid ::firstWhere ('uuid ' , $ queryUuid );
28
+ $ model = Casting ::firstWhere ('uuid ' , $ queryUuid );
29
29
$ this ->assertNotNull ($ model );
30
30
$ this ->assertSame ($ expectedUuid , $ model ->uuid );
31
31
}
@@ -43,9 +43,9 @@ public function testQueryByStringDoesNotCast(): void
43
43
{
44
44
$ uuid = '0c103357-3806-48c9-a84b-867dcb625cfb ' ;
45
45
46
- CastBinaryUuid ::create (['uuid ' => $ uuid ]);
46
+ Casting ::create (['uuid ' => $ uuid ]);
47
47
48
- $ model = CastBinaryUuid ::firstWhere ('uuid ' , $ uuid );
48
+ $ model = Casting ::firstWhere ('uuid ' , $ uuid );
49
49
$ this ->assertNull ($ model );
50
50
}
51
51
}
Load Diff This file was deleted.
Original file line number Diff line number Diff line change 4
4
5
5
namespace MongoDB \Laravel \Tests \Models ;
6
6
7
+ use MongoDB \Laravel \Eloquent \Casts \BinaryUuid ;
7
8
use MongoDB \Laravel \Eloquent \Model as Eloquent ;
8
9
9
10
class Casting extends Eloquent
@@ -12,6 +13,7 @@ class Casting extends Eloquent
12
13
protected $ collection = 'casting ' ;
13
14
14
15
protected $ fillable = [
16
+ 'uuid ' ,
15
17
'intNumber ' ,
16
18
'floatNumber ' ,
17
19
'decimalNumber ' ,
@@ -26,6 +28,7 @@ class Casting extends Eloquent
26
28
];
27
29
28
30
protected $ casts = [
31
+ 'uuid ' => BinaryUuid::class,
29
32
'intNumber ' => 'int ' ,
30
33
'floatNumber ' => 'float ' ,
31
34
'decimalNumber ' => 'decimal:2 ' ,
You can’t perform that action at this time.
0 commit comments