forked from doctrine/mongodb-odm
-
Notifications
You must be signed in to change notification settings - Fork 0
/
GH1294Test.php
54 lines (42 loc) · 1.37 KB
/
GH1294Test.php
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
<?php
namespace Doctrine\ODM\MongoDB\Tests\Functional\Ticket;
use Doctrine\Common\Collections\ArrayCollection;
use Doctrine\ODM\MongoDB\DocumentNotFoundException;
use Doctrine\ODM\MongoDB\Mapping\Annotations as ODM;
class GH1294Test extends \Doctrine\ODM\MongoDB\Tests\BaseTest
{
public function testMongoRegexSearchOnIdentifierWithUuidStrategy()
{
$userClass = __NAMESPACE__ . '\GH1294User';
$user1 = new GH1294User();
$user1->id = 'aaa111aaa';
$user1->name = 'Steven';
$user2 = new GH1294User();
$user2->id = 'bbb111bbb';
$user2->name = 'Jeff';
$this->dm->persist($user1);
$this->dm->persist($user2);
$this->dm->flush();
$this->dm->clear();
$qb = $this->dm->createQueryBuilder($userClass);
$res = $qb->field('id')
->equals(new \MongoRegex("/^bbb.*$/i"))
->getQueryArray();
$this->assertTrue(($res['_id'] instanceof \MongoRegex));
$this->assertEquals('^bbb.*$', $res['_id']->regex);
$this->assertEquals('i', $res['_id']->flags);
}
}
/** @ODM\Document */
class GH1294User
{
/** @ODM\Id(strategy="UUID", type="string") */
public $id;
/** @ODM\String */
public $name = false;
// Return the identifier without triggering Proxy initialization
public function getId()
{
return $this->id;
}
}