-
Notifications
You must be signed in to change notification settings - Fork 2.5k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
d7a537c
commit 37d1d57
Showing
6 changed files
with
117 additions
and
3 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
15 changes: 15 additions & 0 deletions
15
tests/Doctrine/Tests/Models/ClassTableInheritanceCustomType/CustomIdObjectTypeChild.php
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,15 @@ | ||
<?php | ||
|
||
namespace Doctrine\Tests\Models\ClassTableInheritanceCustomType; | ||
|
||
/** | ||
* @Entity | ||
* @Table(name="class_table_inheritance_custom_id_type_child") | ||
*/ | ||
class CustomIdObjectTypeChild extends CustomIdObjectTypeParent | ||
{ | ||
/** | ||
* @var string | ||
*/ | ||
public $name; | ||
} |
39 changes: 39 additions & 0 deletions
39
tests/Doctrine/Tests/Models/ClassTableInheritanceCustomType/CustomIdObjectTypeParent.php
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,39 @@ | ||
<?php | ||
|
||
namespace Doctrine\Tests\Models\ClassTableInheritanceCustomType; | ||
|
||
use Doctrine\Tests\DbalTypes\CustomIdObject; | ||
|
||
/** | ||
* @Entity | ||
* @Table(name="class_table_inheritance_custom_id_type_parent") | ||
* @InheritanceType("JOINED") | ||
* @DiscriminatorColumn(name="type", type="string") | ||
* @DiscriminatorMap({"child" = "CustomIdObjectTypeChild"}) | ||
*/ | ||
abstract class CustomIdObjectTypeParent | ||
{ | ||
/** | ||
* @Id | ||
* @Column(type="CustomIdObject") | ||
* | ||
* @var CustomIdObject | ||
*/ | ||
public $id; | ||
|
||
/** | ||
* @var string | ||
*/ | ||
public $type; | ||
|
||
/** | ||
* CustomIdObjectTypeParent constructor. | ||
* @param CustomIdObject $id | ||
* @param string $type | ||
*/ | ||
public function __construct(CustomIdObject $id, $type = 'child') | ||
{ | ||
$this->id = $id; | ||
$this->type = $type; | ||
} | ||
} |
51 changes: 51 additions & 0 deletions
51
tests/Doctrine/Tests/ORM/Functional/ClassTableInheritanceCustomIdObjectTypeTest.php
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,51 @@ | ||
<?php | ||
|
||
namespace Doctrine\Tests\ORM\Functional; | ||
|
||
use Doctrine\DBAL\Types\Type as DBALType; | ||
use Doctrine\Tests\DbalTypes\CustomIdObject; | ||
use Doctrine\Tests\DbalTypes\CustomIdObjectType; | ||
use Doctrine\Tests\Models\ClassTableInheritanceCustomType\CustomIdObjectTypeChild; | ||
use Doctrine\Tests\Models\ClassTableInheritanceCustomType\CustomIdObjectTypeParent; | ||
use Doctrine\Tests\OrmFunctionalTestCase; | ||
|
||
/** | ||
* Functional tests for the Class Table Inheritance mapping strategy with custom id object types. | ||
*/ | ||
class ClassTableInheritanceCustomIdObjectTypeTest extends OrmFunctionalTestCase | ||
{ | ||
protected function setUp() | ||
{ | ||
if (DBALType::hasType(CustomIdObjectType::NAME)) { | ||
DBALType::overrideType(CustomIdObjectType::NAME, CustomIdObjectType::class); | ||
} else { | ||
DBALType::addType(CustomIdObjectType::NAME, CustomIdObjectType::class); | ||
} | ||
|
||
$this->useModelSet('class_table_inheritance_custom_id_object_type'); | ||
|
||
parent::setUp(); | ||
} | ||
|
||
public function testDelete() | ||
{ | ||
$object = new CustomIdObjectTypeChild(new CustomIdObject('foo')); | ||
$object->name = 'Test'; | ||
|
||
// persist parent | ||
$this->_em->persist($object); | ||
$this->_em->flush(); | ||
|
||
// save id for later use | ||
$id = $object->id; | ||
|
||
// get child | ||
$object2 = $this->_em->find(CustomIdObjectTypeChild::class, $id); | ||
|
||
// remove child | ||
$this->_em->remove($object2); | ||
$this->_em->flush(); | ||
|
||
$this->assertNull($this->_em->find(CustomIdObjectTypeChild::class, $id)); | ||
} | ||
} |
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