-
Notifications
You must be signed in to change notification settings - Fork 2.5k
Expand file tree
/
Copy pathGH8702Test.php
More file actions
64 lines (52 loc) · 1.62 KB
/
Copy pathGH8702Test.php
File metadata and controls
64 lines (52 loc) · 1.62 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
<?php
declare(strict_types=1);
namespace Doctrine\Tests\ORM\Functional\Ticket;
use Doctrine\Common\Collections\Criteria;
use Doctrine\ORM\Mapping\Column;
use Doctrine\ORM\Mapping\Entity;
use Doctrine\ORM\Mapping\Id;
use Doctrine\Tests\OrmFunctionalTestCase;
use PHPUnit\Framework\Attributes\Group;
use function defined;
#[Group('GH8702')]
class GH8702Test extends OrmFunctionalTestCase
{
protected function setUp(): void
{
parent::setUp();
$this->createSchemaForModels(GH8702Item::class);
$this->_em->persist(new GH8702Item(1, 1));
$this->_em->persist(new GH8702Item(2, 2));
$this->_em->persist(new GH8702Item(3, 3));
$this->_em->flush();
$this->_em->clear();
}
public function testAddingMultipleCriteriaOnTheSameField(): void
{
$from = defined(Criteria::class . '::ASC') ? Criteria::create(true) : Criteria::create();
$from->where($from->expr()->gte('value', 2));
$to = defined(Criteria::class . '::ASC') ? Criteria::create(true) : Criteria::create();
$to->where($to->expr()->lte('value', 2));
$items = $this->_em->createQueryBuilder()
->select('item')
->from(GH8702Item::class, 'item')
->addCriteria($from)
->addCriteria($to)
->getQuery()
->getResult();
self::assertCount(1, $items);
self::assertSame(2, $items[0]->id);
}
}
#[Entity]
class GH8702Item
{
public function __construct(
#[Id]
#[Column(type: 'integer')]
public int $id,
#[Column(type: 'integer')]
public int $value,
) {
}
}