2 namespace Doctrine\Tests\ORM\Functional\Ticket;
4 require_once __DIR__ . '/../../../TestInit.php';
6 class DDC422Test extends \Doctrine\Tests\OrmFunctionalTestCase
8 protected function setUp()
11 //$this->_em->getConnection()->getConfiguration()->setSQLLogger(new \Doctrine\DBAL\Logging\EchoSQLLogger);
12 $this->_schemaTool->createSchema(array(
13 $this->_em->getClassMetadata(__NAMESPACE__ . '\DDC422Guest'),
14 $this->_em->getClassMetadata(__NAMESPACE__ . '\DDC422Customer'),
15 $this->_em->getClassMetadata(__NAMESPACE__ . '\DDC422Contact')
22 public function testIssue()
24 $customer = new DDC422Customer;
25 $this->_em->persist($customer);
29 $customer = $this->_em->find(get_class($customer), $customer->id);
31 $this->assertInstanceOf('Doctrine\ORM\PersistentCollection', $customer->contacts);
32 $this->assertFalse($customer->contacts->isInitialized());
33 $contact = new DDC422Contact;
34 $customer->contacts->add($contact);
35 $this->assertTrue($customer->contacts->isDirty());
36 $this->assertFalse($customer->contacts->isInitialized());
39 $this->assertEquals(1, $this->_em->getConnection()->fetchColumn("select count(*) from ddc422_customers_contacts"));
45 * @InheritanceType("JOINED")
46 * @DiscriminatorColumn(name="discr", type="string")
47 * @DiscriminatorMap({"guest" = "DDC422Guest", "customer" = "DDC422Customer"})
50 /** @Id @Column(type="integer") @GeneratedValue */
55 class DDC422Customer extends DDC422Guest {
57 * @ManyToMany(targetEntity="DDC422Contact", cascade={"persist","remove"})
58 * @JoinTable(name="ddc422_customers_contacts",
59 * joinColumns={@JoinColumn(name="customer_id", referencedColumnName="id", onDelete="cascade" )},
60 * inverseJoinColumns={@JoinColumn(name="contact_id", referencedColumnName="id", onDelete="cascade" )}
65 public function __construct() {
66 $this->contacts = new \Doctrine\Common\Collections\ArrayCollection;
72 /** @Id @Column(type="integer") @GeneratedValue */