3 namespace Doctrine\Tests\ORM\Functional\Ticket;
5 require_once __DIR__ . '/../../../TestInit.php';
7 class DDC719Test extends \Doctrine\Tests\OrmFunctionalTestCase
9 protected function setUp()
12 //$this->_em->getConnection()->getConfiguration()->setSQLLogger(new \Doctrine\DBAL\Logging\EchoSQLLogger);
13 $this->_schemaTool->createSchema(array(
14 $this->_em->getClassMetadata(__NAMESPACE__ . '\DDC719Group'),
18 public function testIsEmptySqlGeneration()
20 $q = $this->_em->createQuery('SELECT g, c FROM Doctrine\Tests\ORM\Functional\Ticket\DDC719Group g LEFT JOIN g.children c WHERE g.parents IS EMPTY');
23 strtolower('SELECT g0_.name AS name0, g0_.description AS description1, g0_.id AS id2, g1_.name AS name3, g1_.description AS description4, g1_.id AS id5 FROM groups g0_ LEFT JOIN groups_groups g2_ ON g0_.id = g2_.parent_id LEFT JOIN groups g1_ ON g1_.id = g2_.child_id WHERE (SELECT COUNT(*) FROM groups_groups g3_ WHERE g3_.child_id = g0_.id) = 0'),
24 strtolower($q->getSQL())
36 * @Column(type="integer")
40 public function getId() { return $this->id; }
45 * @Table(name="groups")
47 class DDC719Group extends Entity {
48 /** @Column(type="string", nullable=false) */
51 /** @Column(type="string", nullable=true) */
52 protected $description;
55 * @ManyToMany(targetEntity="DDC719Group", inversedBy="parents")
56 * @JoinTable(name="groups_groups",
57 * joinColumns={@JoinColumn(name="parent_id", referencedColumnName="id")},
58 * inverseJoinColumns={@JoinColumn(name="child_id", referencedColumnName="id")}
61 protected $children = NULL;
64 * @ManyToMany(targetEntity="DDC719Group", mappedBy="children")
66 protected $parents = NULL;
71 public function __construct() {
72 parent::__construct();
74 $this->channels = new ArrayCollection();
75 $this->children = new ArrayCollection();
76 $this->parents = new ArrayCollection();
80 * adds group as new child
84 public function addGroup(Group $child) {
85 if ( ! $this->children->contains($child)) {
86 $this->children->add($child);
87 $child->addGroup($this);
92 * adds channel as new child
94 * @param Channel $child
96 public function addChannel(Channel $child) {
97 if ( ! $this->channels->contains($child)) {
98 $this->channels->add($child);
105 public function getName() { return $this->name; }
106 public function setName($name) { $this->name = $name; }
107 public function getDescription() { return $this->description; }
108 public function setDescription($description) { $this->description = $description; }
109 public function getChildren() { return $this->children; }
110 public function getParents() { return $this->parents; }
111 public function getChannels() { return $this->channels; }