Skip to content

Commit a018aa4

Browse files
committed
Fix
1 parent 6fccfd3 commit a018aa4

File tree

3 files changed

+10
-25
lines changed

3 files changed

+10
-25
lines changed

src/Attribute/Parameter/CollectionResolver.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ public function getParameterValue(
3838
try {
3939
$collection[] = $context->getHydrator()->create($attribute->className, $item);
4040
} catch (NonInstantiableException) {
41-
break;
41+
continue;
4242
}
4343
}
4444

tests/Attribute/Parameter/CollectionTest.php

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,6 @@
2525
use Yiisoft\Hydrator\Tests\Support\Classes\CounterClass;
2626
use Yiisoft\Hydrator\Tests\Support\Classes\Post\Post;
2727
use Yiisoft\Hydrator\Tests\Support\Classes\Post\PostCategory;
28-
use Yiisoft\Hydrator\Tests\Support\Classes\Post\PostCategoryWithNonExistingPostClass;
2928
use Yiisoft\Hydrator\Tests\Support\TestHelper;
3029
use Yiisoft\Test\Support\Container\SimpleContainer;
3130

@@ -94,18 +93,25 @@ public function testInvalidValueItem(): void
9493
public function testNonInstantiableValueItem(): void
9594
{
9695
$hydrator = new Hydrator();
97-
$object = new PostCategoryWithNonExistingPostClass();
96+
$object = new PostCategory();
9897

9998
$hydrator->hydrate(
10099
$object,
101100
[
102101
'posts' => [
103102
['name' => 'Post 1'],
103+
['name' => []],
104104
['name' => 'Post 2', 'description' => 'Description for post 2'],
105105
],
106106
],
107107
);
108-
$this->assertEmpty($object->getPosts());
108+
$this->assertEquals(
109+
[
110+
new Post(name: 'Post 1'),
111+
new Post(name: 'Post 2', description: 'Description for post 2'),
112+
],
113+
$object->getPosts(),
114+
);
109115
}
110116

111117
public static function dataBase(): array

tests/Support/Classes/Post/PostCategoryWithNonExistingPostClass.php

Lines changed: 0 additions & 21 deletions
This file was deleted.

0 commit comments

Comments
 (0)