Skip to content
This repository was archived by the owner on Mar 12, 2024. It is now read-only.

Commit 769e703

Browse files
committed
add more tests
1 parent 4d4a11d commit 769e703

File tree

1 file changed

+16
-15
lines changed

1 file changed

+16
-15
lines changed

tests/AttributeMappingTest.php

Lines changed: 16 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -10,25 +10,12 @@ class AttributeMappingTest extends TestCase
1010
{
1111
use WithModelMapping;
1212

13-
/**
14-
* @var bool
15-
*/
13+
public int $id;
1614
public bool $test;
17-
18-
/**
19-
* @var string
20-
*/
2115
public string $name;
22-
23-
/**
24-
* @var mixed
25-
*/
2616
public object $files;
27-
28-
/**
29-
* @var \Closure|null
30-
*/
3117
public ?\Closure $default = null;
18+
public ?Collection $collection = null;
3219

3320
/** @test */
3421
public function testMapsAttributesToClassPropertiesCorrectly()
@@ -42,6 +29,7 @@ public function testMapsAttributesToClassPropertiesCorrectly()
4229

4330
$this->mapModelAttributes($model);
4431

32+
$this->assertIsInt($this->id);
4533
$this->assertTrue($this->test);
4634
$this->assertIsString($this->name);
4735
$this->assertStringContainsString('mapped', $this->name);
@@ -67,4 +55,17 @@ public function testMappingIgnoresDifferentTypes()
6755
$this->assertInstanceOf(\Closure::class, $this->default);
6856
$this->assertTrue(($this->default)());
6957
}
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+
}
7071
}

0 commit comments

Comments
 (0)