Failed Conditions
Push — master ( 0345f7...a16dc6 )
by Guilherme
110:10 queued 103:07
created

Tests/ORM/Functional/Ticket/DDC719Test.php (4 issues)

1
<?php
2
3
namespace Doctrine\Tests\ORM\Functional\Ticket;
4
5
class DDC719Test extends \Doctrine\Tests\OrmFunctionalTestCase
6
{
7
    protected function setUp()
8
    {
9
        parent::setUp();
10
        //$this->_em->getConnection()->getConfiguration()->setSQLLogger(new \Doctrine\DBAL\Logging\EchoSQLLogger);
11
        $this->_schemaTool->createSchema(
12
            [
13
            $this->_em->getClassMetadata(DDC719Group::class),
14
            ]
15
        );
16
    }
17
18
    public function testIsEmptySqlGeneration()
19
    {
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');
21
22
        $referenceSQL = 'SELECT g0_.name AS name_0, g0_.description AS description_1, g0_.id AS id_2, g1_.name AS name_3, g1_.description AS description_4, g1_.id AS id_5 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';
23
24
        $this->assertEquals(
25
            strtolower($referenceSQL),
26
            strtolower($q->getSQL())
27
        );
28
    }
29
}
30
31
/**
32
 * @MappedSuperclass
33
 */
34
class Entity
35
{
36
    /**
37
     * @Id @GeneratedValue
38
     * @Column(type="integer")
39
     */
40
    protected $id;
41
42
    public function getId() { return $this->id; }
43
}
44
45
/**
46
 * @Entity
47
 * @Table(name="groups")
48
 */
49
class DDC719Group extends Entity {
50
    /** @Column(type="string", nullable=false) */
51
    protected $name;
52
53
	/** @Column(type="string", nullable=true) */
54
	protected $description;
55
56
	/**
57
	 * @ManyToMany(targetEntity="DDC719Group", inversedBy="parents")
58
	 * @JoinTable(name="groups_groups",
59
	 * 		joinColumns={@JoinColumn(name="parent_id", referencedColumnName="id")},
60
	 * 		inverseJoinColumns={@JoinColumn(name="child_id", referencedColumnName="id")}
61
	 * )
62
	 */
63
	protected $children = NULL;
64
65
	/**
66
	 * @ManyToMany(targetEntity="DDC719Group", mappedBy="children")
67
	 */
68
	protected $parents = NULL;
69
70
	/**
71
	 * construct
72
	 */
73
	public function __construct() {
74
		parent::__construct();
75
76
		$this->channels = new ArrayCollection();
0 ignored issues
show
Bug Best Practice introduced by
The property channels does not exist. Although not strictly required by PHP, it is generally a best practice to declare properties explicitly.
Loading history...
The type Doctrine\Tests\ORM\Funct...\Ticket\ArrayCollection was not found. Maybe you did not declare it correctly or list all dependencies?

The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g. excluded_paths: ["lib/*"], you can move it to the dependency path list as follows:

filter:
    dependency_paths: ["lib/*"]

For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths

Loading history...
77
		$this->children = new ArrayCollection();
78
		$this->parents = new ArrayCollection();
79
	}
80
81
	/**
82
	 * adds group as new child
83
	 *
84
	 * @param Group $child
85
	 */
86
	public function addGroup(Group $child) {
0 ignored issues
show
The type Doctrine\Tests\ORM\Functional\Ticket\Group was not found. Maybe you did not declare it correctly or list all dependencies?

The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g. excluded_paths: ["lib/*"], you can move it to the dependency path list as follows:

filter:
    dependency_paths: ["lib/*"]

For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths

Loading history...
87
        if ( ! $this->children->contains($child)) {
88
            $this->children->add($child);
89
            $child->addGroup($this);
90
        }
91
	}
92
93
	/**
94
	 * adds channel as new child
95
	 *
96
	 * @param Channel $child
97
	 */
98
	public function addChannel(Channel $child) {
0 ignored issues
show
The type Doctrine\Tests\ORM\Functional\Ticket\Channel was not found. Maybe you did not declare it correctly or list all dependencies?

The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g. excluded_paths: ["lib/*"], you can move it to the dependency path list as follows:

filter:
    dependency_paths: ["lib/*"]

For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths

Loading history...
99
        if ( ! $this->channels->contains($child)) {
100
            $this->channels->add($child);
101
        }
102
	}
103
104
	/**
105
	 * getter & setter
106
	 */
107
	public function getName() { return $this->name; }
108
	public function setName($name) { $this->name = $name; }
109
	public function getDescription() { return $this->description; }
110
	public function setDescription($description) { $this->description = $description; }
111
	public function getChildren() { return $this->children; }
112
	public function getParents() { return $this->parents; }
113
	public function getChannels() { return $this->channels; }
114
}
115