Skip to content

Commit

Permalink
Add failing test case for incorrect hydration (nelmio#860)
Browse files Browse the repository at this point in the history
Failing test case for nelmio#858
  • Loading branch information
Dennis L authored and theofidry committed Feb 14, 2018
1 parent 5cb9f49 commit b43afff
Show file tree
Hide file tree
Showing 2 changed files with 60 additions and 0 deletions.
31 changes: 31 additions & 0 deletions fixtures/Entity/DummyWithThrowableSetter.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
<?php

/*
* This file is part of the Alice package.
*
* (c) Nelmio <[email protected]>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/

declare(strict_types=1);

namespace Nelmio\Alice\Entity;

class DummyWithThrowableSetter
{
private $val = null;

/**
* @param $val
*/
public function setVal($val)
{
if (!empty($this->val)) {
throw new \LogicException('val is already initialised, cant be set again');
}

$this->val = $val;
}
}
29 changes: 29 additions & 0 deletions tests/Loader/LoaderIntegrationTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -1842,6 +1842,35 @@ public function provideFixturesToHydrate()

public function provideFixturesToGenerate()
{

yield '[construct] with reference to object with throwable setter' => [
[
FixtureEntity\DummyWithThrowableSetter::class => [
'another_dummy' => [
'val' => 1
]
],
FixtureEntity\DummyWithConstructorParam::class => [
'dummy' => [
'__construct' => [
'@another_dummy'
]
]
]
],
[
'parameters' => [],
'objects' => [
'another_dummy' => $anotherDummy1 = StdClassFactory::create([
'val' => 1,
]),
'dummy' => $dummy1 = StdClassFactory::create([
'val' => $anotherDummy1,
]),
]
]
];

yield 'empty instance' => [
[
stdClass::class => [
Expand Down

0 comments on commit b43afff

Please sign in to comment.