This repository was archived by the owner on Mar 12, 2024. It is now read-only.
File tree Expand file tree Collapse file tree 1 file changed +16
-15
lines changed Expand file tree Collapse file tree 1 file changed +16
-15
lines changed Original file line number Diff line number Diff line change @@ -10,25 +10,12 @@ class AttributeMappingTest extends TestCase
10
10
{
11
11
use WithModelMapping;
12
12
13
- /**
14
- * @var bool
15
- */
13
+ public int $ id ;
16
14
public bool $ test ;
17
-
18
- /**
19
- * @var string
20
- */
21
15
public string $ name ;
22
-
23
- /**
24
- * @var mixed
25
- */
26
16
public object $ files ;
27
-
28
- /**
29
- * @var \Closure|null
30
- */
31
17
public ?\Closure $ default = null ;
18
+ public ?Collection $ collection = null ;
32
19
33
20
/** @test */
34
21
public function testMapsAttributesToClassPropertiesCorrectly ()
@@ -42,6 +29,7 @@ public function testMapsAttributesToClassPropertiesCorrectly()
42
29
43
30
$ this ->mapModelAttributes ($ model );
44
31
32
+ $ this ->assertIsInt ($ this ->id );
45
33
$ this ->assertTrue ($ this ->test );
46
34
$ this ->assertIsString ($ this ->name );
47
35
$ this ->assertStringContainsString ('mapped ' , $ this ->name );
@@ -67,4 +55,17 @@ public function testMappingIgnoresDifferentTypes()
67
55
$ this ->assertInstanceOf (\Closure::class, $ this ->default );
68
56
$ this ->assertTrue (($ this ->default )());
69
57
}
58
+
59
+ /** @test */
60
+ public function testMappingWorksWithCollections ()
61
+ {
62
+ $ model = new TestModel ([
63
+ 'id ' => 1 ,
64
+ 'collection ' => new Collection (),
65
+ ]);
66
+
67
+ $ this ->mapModelAttributes ($ model );
68
+
69
+ $ this ->assertInstanceOf (Collection::class, $ this ->collection );
70
+ }
70
71
}
You can’t perform that action at this time.
0 commit comments