PageRenderTime 40ms CodeModel.GetById 15ms RepoModel.GetById 0ms app.codeStats 0ms

/vendor/doctrine/orm/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC1209Test.php

https://bitbucket.org/iiic/iszp
PHP | 125 lines | 70 code | 16 blank | 39 comment | 0 complexity | 3b79c1060b57766cfac860e688050d47 MD5 | raw file
  1. <?php
  2. namespace Doctrine\Tests\ORM\Functional\Ticket;
  3. use Doctrine\Common\Collections\ArrayCollection;
  4. require_once __DIR__ . '/../../../TestInit.php';
  5. class DDC1209Test extends \Doctrine\Tests\OrmFunctionalTestCase
  6. {
  7. protected function setUp()
  8. {
  9. parent::setUp();
  10. try {
  11. $this->_schemaTool->createSchema(array(
  12. $this->_em->getClassMetadata(__NAMESPACE__ . '\\DDC1209_1'),
  13. $this->_em->getClassMetadata(__NAMESPACE__ . '\\DDC1209_2'),
  14. $this->_em->getClassMetadata(__NAMESPACE__ . '\\DDC1209_3')
  15. ));
  16. } catch(\Exception $e) {
  17. }
  18. }
  19. /**
  20. * @group DDC-1209
  21. */
  22. public function testIdentifierCanHaveCustomType()
  23. {
  24. $this->_em->persist(new DDC1209_3());
  25. $this->_em->flush();
  26. }
  27. /**
  28. * @group DDC-1209
  29. */
  30. public function testCompositeIdentifierCanHaveCustomType()
  31. {
  32. $future1 = new DDC1209_1();
  33. $this->_em->persist($future1);
  34. $this->_em->flush();
  35. $future2 = new DDC1209_2($future1);
  36. $this->_em->persist($future2);
  37. $this->_em->flush();
  38. }
  39. }
  40. /**
  41. * @Entity
  42. */
  43. class DDC1209_1
  44. {
  45. /**
  46. * @Id @GeneratedValue @Column(type="integer")
  47. */
  48. private $id;
  49. public function getId()
  50. {
  51. return $this->id;
  52. }
  53. }
  54. /**
  55. * @Entity
  56. */
  57. class DDC1209_2
  58. {
  59. /**
  60. * @Id
  61. * @ManyToOne(targetEntity="DDC1209_1")
  62. * @JoinColumn(referencedColumnName="id", nullable=false)
  63. */
  64. private $future1;
  65. /**
  66. * @Id
  67. * @Column(type="datetime", nullable=false)
  68. */
  69. private $starting_datetime;
  70. /**
  71. * @Id
  72. * @Column(type="datetime", nullable=false)
  73. */
  74. private $during_datetime;
  75. /**
  76. * @Id
  77. * @Column(type="datetime", nullable=false)
  78. */
  79. private $ending_datetime;
  80. public function __construct(DDC1209_1 $future1)
  81. {
  82. $this->future1 = $future1;
  83. $this->starting_datetime = new DateTime2();
  84. $this->during_datetime = new DateTime2();
  85. $this->ending_datetime = new DateTime2();
  86. }
  87. }
  88. /**
  89. * @Entity
  90. */
  91. class DDC1209_3
  92. {
  93. /**
  94. * @Id
  95. * @Column(type="datetime", name="somedate")
  96. */
  97. private $date;
  98. public function __construct()
  99. {
  100. $this->date = new DateTime2();
  101. }
  102. }
  103. class DateTime2 extends \DateTime
  104. {
  105. public function __toString()
  106. {
  107. return $this->format('Y');
  108. }
  109. }