Skip to content

Commit

Permalink
fix: infinite loop in MapperFactory
Browse files Browse the repository at this point in the history
  • Loading branch information
priyadi committed Nov 12, 2024
1 parent d117d4d commit 98606b1
Show file tree
Hide file tree
Showing 3 changed files with 39 additions and 0 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
# CHANGELOG

## 1.13.5

* fix: infinite loop in `MapperFactory`

## 1.13.4

* fix: fix list handling
Expand Down
1 change: 1 addition & 0 deletions tests/config/rekalogika-mapper/generated-mappings.php
Original file line number Diff line number Diff line change
Expand Up @@ -281,6 +281,7 @@
$mappingCollection->addObjectMapping(
// tests/src/IntegrationTest/BasicMappingTest.php on line 33
// tests/src/IntegrationTest/IterableMapperTest.php on line 24
// tests/src/UnitTest/MapperFactoryTest.php on line 29
source: \Rekalogika\Mapper\Tests\Fixtures\Basic\Person::class,
target: \Rekalogika\Mapper\Tests\Fixtures\Basic\PersonDto::class
);
Expand Down
34 changes: 34 additions & 0 deletions tests/src/UnitTest/MapperFactoryTest.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
<?php

declare(strict_types=1);

/*
* This file is part of rekalogika/mapper package.
*
* (c) Priyadi Iman Nurcahyo <https://rekalogika.dev>
*
* For the full copyright and license information, please view the LICENSE file
* that was distributed with this source code.
*/

namespace Rekalogika\Mapper\Tests\UnitTest;

use PHPUnit\Framework\TestCase;
use Rekalogika\Mapper\MapperFactory;
use Rekalogika\Mapper\Tests\Fixtures\Basic\Person;
use Rekalogika\Mapper\Tests\Fixtures\Basic\PersonDto;

class MapperFactoryTest extends TestCase
{
public function testMapperFactory(): void
{
$mapperFactory = new MapperFactory();
$mapper = $mapperFactory->getMapper();

$source = new Person('John Doe', 30);
$target = $mapper->map($source, PersonDto::class);

$this->assertSame('John Doe', $target->name);
$this->assertSame(30, $target->age);
}
}

0 comments on commit 98606b1

Please sign in to comment.