44
55namespace Doctrine \Tests \ORM \Functional \Ticket ;
66
7- use Doctrine \DBAL \ Platforms \ SqlitePlatform ;
7+ use Doctrine \Common \ Collections \ ArrayCollection ;
88use Doctrine \ORM \Mapping as ORM ;
99use Doctrine \Tests \OrmFunctionalTestCase ;
1010
11- /**
12- * @group GH6499
13- *
14- * Specifically, GH6499B has a dependency on GH6499A, and GH6499A
15- * has a dependency on GH6499B. Since GH6499A#b is not nullable,
16- * the GH6499B should be inserted first.
17- */
18- class GH6499Test extends OrmFunctionalTestCase
11+ class GH7006Test extends OrmFunctionalTestCase
1912{
2013 protected function setUp (): void
2114 {
2215 parent ::setUp ();
2316
2417 $ this ->_schemaTool ->createSchema ([
25- $ this ->_em ->getClassMetadata (GH6499A ::class),
26- $ this ->_em ->getClassMetadata (GH6499B ::class),
18+ $ this ->_em ->getClassMetadata (GH7006Book::class),
19+ $ this ->_em ->getClassMetadata (GH7006PCT ::class),
20+ $ this ->_em ->getClassMetadata (GH7006PCTFee::class),
2721 ]);
2822 }
2923
@@ -32,41 +26,125 @@ protected function tearDown(): void
3226 parent ::tearDown ();
3327
3428 $ this ->_schemaTool ->dropSchema ([
35- $ this ->_em ->getClassMetadata (GH6499A ::class),
36- $ this ->_em ->getClassMetadata (GH6499B ::class),
29+ $ this ->_em ->getClassMetadata (GH7006Book::class),
30+ $ this ->_em ->getClassMetadata (GH7006PCT ::class),
31+ $ this ->_em ->getClassMetadata (GH7006PCTFee::class),
3732 ]);
3833 }
3934
4035 public function testIssue (): void
4136 {
42- $ b = new GH6499B ();
43- $ a = new GH6499A ();
37+ $ book = new GH7006Book ();
38+ $ book ->exchangeCode = 'first ' ;
39+ $ this ->_em ->persist ($ book );
4440
45- $ this -> _em -> persist ( $ a );
41+ $ book -> exchangeCode = ' second ' ; // change sth.
4642
47- $ a ->b = $ b ;
43+ $ paymentCardTransaction = new GH7006PCT ();
44+ $ paymentCardTransaction ->book = $ book ;
45+ $ paymentCardTransactionFee = new GH7006PCTFee ($ paymentCardTransaction );
4846
49- $ this ->_em ->persist ($ b );
47+ $ this ->_em ->persist ($ paymentCardTransaction );
5048
5149 $ this ->_em ->flush ();
5250
53- self ::assertIsInt ($ a ->id );
54- self ::assertIsInt ($ b ->id );
51+ self ::assertIsInt ($ book ->id );
52+ self ::assertIsInt ($ paymentCardTransaction ->id );
53+ self ::assertIsInt ($ paymentCardTransactionFee ->id );
5554 }
55+ }
5656
57- public function testIssueReversed (): void
58- {
59- $ b = new GH6499B ();
60- $ a = new GH6499A ();
61-
62- $ a ->b = $ b ;
63-
64- $ this ->_em ->persist ($ b );
65- $ this ->_em ->persist ($ a );
57+ /**
58+ * @ORM\Entity
59+ */
60+ class GH7006Book
61+ {
62+ /**
63+ * @ORM\Id
64+ * @ORM\Column(type="integer")
65+ * @ORM\GeneratedValue(strategy="AUTO")
66+ *
67+ * @var int
68+ */
69+ public $ id ;
70+
71+ /**
72+ * @ORM\Column(type="string", length=255, nullable=true)
73+ *
74+ * @var string
75+ */
76+ public $ exchangeCode ;
77+
78+ /**
79+ * @ORM\OneToOne(targetEntity="GH7006PCT", cascade={"persist", "remove"})
80+ * @ORM\JoinColumn(name="paymentCardTransactionId", referencedColumnName="id")
81+ *
82+ * @var GH7006PCT
83+ */
84+ public $ paymentCardTransaction ;
85+ }
6686
67- $ this ->_em ->flush ();
87+ /**
88+ * @ORM\Entity
89+ */
90+ class GH7006PCT
91+ {
92+ /**
93+ * @ORM\Id
94+ * @ORM\Column(type="integer")
95+ * @ORM\GeneratedValue(strategy="AUTO")
96+ *
97+ * @var int
98+ */
99+ public $ id ;
100+
101+ /**
102+ * @ORM\ManyToOne(targetEntity="GH7006Book")
103+ * @ORM\JoinColumn(name="bookingId", referencedColumnName="id", nullable=false)
104+ *
105+ * @var GH7006Book
106+ */
107+ public $ book ;
108+
109+ /**
110+ * @ORM\OneToMany(targetEntity="GH7006PCTFee", mappedBy="pct", cascade={"persist", "remove"})
111+ * @ORM\OrderBy({"id" = "ASC"})
112+ *
113+ * @var GH7006PCTFee[]
114+ */
115+ public $ fees ;
116+
117+ public function __construct ()
118+ {
119+ $ this ->fees = new ArrayCollection ();
120+ }
121+ }
68122
69- self ::assertIsInt ($ a ->id );
70- self ::assertIsInt ($ b ->id );
123+ /**
124+ * @ORM\Entity
125+ */
126+ class GH7006PCTFee
127+ {
128+ /**
129+ * @ORM\Id
130+ * @ORM\Column(type="integer")
131+ * @ORM\GeneratedValue(strategy="AUTO")
132+ *
133+ * @var int
134+ */
135+ public $ id ;
136+
137+ /**
138+ * @ORM\ManyToOne(targetEntity="GH7006PCT", inversedBy="fees")
139+ * @ORM\JoinColumn(name="paymentCardTransactionId", referencedColumnName="id", nullable=false)
140+ *
141+ * @var GH7006PCT
142+ */
143+ public $ pct ;
144+
145+ public function __construct (GH7006PCT $ pct )
146+ {
147+ $ this ->pct = $ pct ;
148+ $ pct ->fees ->add ($ this );
71149 }
72150}
0 commit comments