Skip to content

Commit

Permalink
Fix
Browse files Browse the repository at this point in the history
  • Loading branch information
arogachev committed Aug 5, 2024
1 parent 6fccfd3 commit a018aa4
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 25 deletions.
2 changes: 1 addition & 1 deletion src/Attribute/Parameter/CollectionResolver.php
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ public function getParameterValue(
try {
$collection[] = $context->getHydrator()->create($attribute->className, $item);
} catch (NonInstantiableException) {
break;
continue;
}
}

Expand Down
12 changes: 9 additions & 3 deletions tests/Attribute/Parameter/CollectionTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,6 @@
use Yiisoft\Hydrator\Tests\Support\Classes\CounterClass;
use Yiisoft\Hydrator\Tests\Support\Classes\Post\Post;
use Yiisoft\Hydrator\Tests\Support\Classes\Post\PostCategory;
use Yiisoft\Hydrator\Tests\Support\Classes\Post\PostCategoryWithNonExistingPostClass;
use Yiisoft\Hydrator\Tests\Support\TestHelper;
use Yiisoft\Test\Support\Container\SimpleContainer;

Expand Down Expand Up @@ -94,18 +93,25 @@ public function testInvalidValueItem(): void
public function testNonInstantiableValueItem(): void
{
$hydrator = new Hydrator();
$object = new PostCategoryWithNonExistingPostClass();
$object = new PostCategory();

$hydrator->hydrate(
$object,
[
'posts' => [
['name' => 'Post 1'],
['name' => []],
['name' => 'Post 2', 'description' => 'Description for post 2'],
],
],
);
$this->assertEmpty($object->getPosts());
$this->assertEquals(
[
new Post(name: 'Post 1'),
new Post(name: 'Post 2', description: 'Description for post 2'),
],
$object->getPosts(),
);
}

public static function dataBase(): array
Expand Down

This file was deleted.

0 comments on commit a018aa4

Please sign in to comment.