-
-
Notifications
You must be signed in to change notification settings - Fork 502
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
2 changed files
with
53 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
52 changes: 52 additions & 0 deletions
52
tests/Doctrine/ODM/MongoDB/Tests/Functional/Ticket/GH1294Test.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
<?php | ||
|
||
namespace Doctrine\ODM\MongoDB\Tests\Functional\Ticket; | ||
|
||
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; | ||
} | ||
} |