Test Failed
Pull Request — master (#6740)
by Mathieu
62:38
created

DDC288Test::setUp()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 22
Code Lines 14

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 22
rs 9.2
c 0
b 0
f 0
cc 1
eloc 14
nc 1
nop 0
1
<?php
2
3
namespace Doctrine\Tests\ORM\Functional\Ticket;
4
5
use Doctrine\Tests\OrmFunctionalTestCase;
6
use Doctrine\Tests\Models\ECommerce\ECommerceProduct;
7
use Doctrine\Tests\Models\ECommerce\ECommerceCategory;
8
use Doctrine\Common\Collections\Criteria;
9
10
class DDC288Test extends OrmFunctionalTestCase
11
{
12
    private $firstProduct;
13
    private $secondProduct;
0 ignored issues
show
Unused Code introduced by
The property $secondProduct is not used and could be removed.

This check marks private properties in classes that are never used. Those properties can be removed.

Loading history...
14
    private $firstCategory;
15
    private $secondCategory;
16
17
    public function setUp()
18
    {
19
        $this->useModelSet('ecommerce');
20
        parent::setUp();
21
22
        $this->firstProduct = new ECommerceProduct();
23
        $this->firstProduct->setName("First Product");
24
25
        $this->firstCategory = new ECommerceCategory();
26
        $this->firstCategory->setName("Business");
27
28
        $this->secondCategory = new ECommerceCategory();
29
        $this->secondCategory->setName("Home");
30
31
        $this->firstProduct->addCategory($this->firstCategory);
32
        $this->firstProduct->addCategory($this->secondCategory);
33
34
        $this->_em->persist($this->firstProduct);
35
36
        $this->_em->flush();
37
        $this->_em->clear();
38
    }
39
40
    public function testCollectionFilteringOperator()
41
    {
42
        $firstProduct = $this->_em->find(ECommerceProduct::class, $this->firstProduct->getId());
43
44
        $criteria = Criteria::create()->where(Criteria::expr()->lte('id', 999));
45
46
        $this->assertCount(2, $firstProduct->getCategories()->matching($criteria));
47
    }
48
}
49