#1336 DDC-3622 - removing implicit cast from string
to CustomIdObject
in entity API (confusing)
This commit is contained in:
parent
712b6a7a64
commit
5c89bb8c6b
3 changed files with 10 additions and 17 deletions
|
@ -42,15 +42,11 @@ class CustomIdObjectTypeChild
|
||||||
public $parent;
|
public $parent;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param CustomIdObject|string $id
|
* @param CustomIdObject $id
|
||||||
* @param CustomIdObjectTypeParent $parent
|
* @param CustomIdObjectTypeParent $parent
|
||||||
*/
|
*/
|
||||||
public function __construct($id, CustomIdObjectTypeParent $parent)
|
public function __construct(CustomIdObject $id, CustomIdObjectTypeParent $parent)
|
||||||
{
|
{
|
||||||
if (! $id instanceof CustomIdObject) {
|
|
||||||
$id = new CustomIdObject($id);
|
|
||||||
}
|
|
||||||
|
|
||||||
$this->id = $id;
|
$this->id = $id;
|
||||||
$this->parent = $parent;
|
$this->parent = $parent;
|
||||||
}
|
}
|
||||||
|
|
|
@ -43,14 +43,10 @@ class CustomIdObjectTypeParent
|
||||||
public $children;
|
public $children;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param CustomIdObject|string $id
|
* @param CustomIdObject $id
|
||||||
*/
|
*/
|
||||||
public function __construct($id)
|
public function __construct(CustomIdObject $id)
|
||||||
{
|
{
|
||||||
if (! $id instanceof CustomIdObject) {
|
|
||||||
$id = new CustomIdObject($id);
|
|
||||||
}
|
|
||||||
|
|
||||||
$this->id = $id;
|
$this->id = $id;
|
||||||
$this->children = new ArrayCollection();
|
$this->children = new ArrayCollection();
|
||||||
}
|
}
|
||||||
|
|
|
@ -19,6 +19,7 @@
|
||||||
|
|
||||||
namespace Doctrine\Tests\ORM\Functional;
|
namespace Doctrine\Tests\ORM\Functional;
|
||||||
|
|
||||||
|
use Doctrine\Tests\DbalTypes\CustomIdObject;
|
||||||
use Doctrine\Tests\DbalTypes\CustomIdObjectType;
|
use Doctrine\Tests\DbalTypes\CustomIdObjectType;
|
||||||
use Doctrine\Tests\Models\CustomType\CustomIdObjectTypeChild;
|
use Doctrine\Tests\Models\CustomType\CustomIdObjectTypeChild;
|
||||||
use Doctrine\Tests\Models\CustomType\CustomIdObjectTypeParent;
|
use Doctrine\Tests\Models\CustomType\CustomIdObjectTypeParent;
|
||||||
|
@ -42,7 +43,7 @@ class CustomIdObjectTypeTest extends OrmFunctionalTestCase
|
||||||
|
|
||||||
public function testFindByCustomIdObject()
|
public function testFindByCustomIdObject()
|
||||||
{
|
{
|
||||||
$parent = new CustomIdObjectTypeParent('foo');
|
$parent = new CustomIdObjectTypeParent(new CustomIdObject('foo'));
|
||||||
|
|
||||||
$this->_em->persist($parent);
|
$this->_em->persist($parent);
|
||||||
$this->_em->flush();
|
$this->_em->flush();
|
||||||
|
@ -58,9 +59,9 @@ class CustomIdObjectTypeTest extends OrmFunctionalTestCase
|
||||||
*/
|
*/
|
||||||
public function testFetchJoinCustomIdObject()
|
public function testFetchJoinCustomIdObject()
|
||||||
{
|
{
|
||||||
$parent = new CustomIdObjectTypeParent('foo');
|
$parent = new CustomIdObjectTypeParent(new CustomIdObject('foo'));
|
||||||
|
|
||||||
$parent->children->add(new CustomIdObjectTypeChild('bar', $parent));
|
$parent->children->add(new CustomIdObjectTypeChild(new CustomIdObject('bar'), $parent));
|
||||||
|
|
||||||
$this->_em->persist($parent);
|
$this->_em->persist($parent);
|
||||||
$this->_em->flush();
|
$this->_em->flush();
|
||||||
|
@ -84,9 +85,9 @@ class CustomIdObjectTypeTest extends OrmFunctionalTestCase
|
||||||
*/
|
*/
|
||||||
public function testFetchJoinWhereCustomIdObject()
|
public function testFetchJoinWhereCustomIdObject()
|
||||||
{
|
{
|
||||||
$parent = new CustomIdObjectTypeParent('foo');
|
$parent = new CustomIdObjectTypeParent(new CustomIdObject('foo'));
|
||||||
|
|
||||||
$parent->children->add(new CustomIdObjectTypeChild('bar', $parent));
|
$parent->children->add(new CustomIdObjectTypeChild(new CustomIdObject('bar'), $parent));
|
||||||
|
|
||||||
$this->_em->persist($parent);
|
$this->_em->persist($parent);
|
||||||
$this->_em->flush();
|
$this->_em->flush();
|
||||||
|
|
Loading…
Add table
Reference in a new issue