-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix object mapper to not modify key while hydrating
- Loading branch information
Showing
2 changed files
with
79 additions
and
8 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
namespace Zrnik\Zweist\Tests; | ||
|
||
use Nyholm\Psr7\Factory\Psr17Factory; | ||
use PHPUnit\Framework\TestCase; | ||
use Zrnik\Zweist\Content\JsonContentFacade; | ||
use Zrnik\Zweist\Tests\ExampleSchema\UnrelatedSchemaClass; | ||
|
||
class ObjectHydrateTest extends TestCase | ||
{ | ||
private JsonContentFacade $jsonContentFacade; | ||
|
||
protected function setUp(): void | ||
{ | ||
$this->jsonContentFacade = new JsonContentFacade( | ||
new Psr17Factory(), | ||
new Psr17Factory(), | ||
); | ||
} | ||
|
||
/** | ||
* This is tested, because object mapper by default | ||
* converts from camel case to snake case. | ||
* | ||
* We don't want that. | ||
* | ||
* @return void | ||
*/ | ||
public function testHydrate(): void | ||
{ | ||
$json = [ | ||
'unrelatedValue' => 'Example Text', | ||
]; | ||
|
||
/** @var UnrelatedSchemaClass $unrelatedSchemaClass */ | ||
$unrelatedSchemaClass = $this->jsonContentFacade->hydrateObject( | ||
UnrelatedSchemaClass::class, | ||
$json | ||
); | ||
|
||
$this->assertSame('Example Text', $unrelatedSchemaClass->unrelatedValue); | ||
} | ||
} |