Rajout de doctrine/orm
[zf2.biz/galerie.git] / vendor / doctrine / orm / tests / Doctrine / Tests / ORM / Functional / EntityRepositoryTest.php
1 <?php
2
3 namespace Doctrine\Tests\ORM\Functional;
4
5 use Doctrine\Tests\Models\CMS\CmsUser;
6 use Doctrine\Tests\Models\CMS\CmsAddress;
7 use Doctrine\Tests\Models\CMS\CmsPhonenumber;
8 use Doctrine\Common\Collections\Criteria;
9
10 require_once __DIR__ . '/../../TestInit.php';
11
12 /**
13  * @author robo
14  */
15 class EntityRepositoryTest extends \Doctrine\Tests\OrmFunctionalTestCase
16 {
17     protected function setUp() {
18         $this->useModelSet('cms');
19         parent::setUp();
20     }
21
22     public function tearDown()
23     {
24         if ($this->_em) {
25             $this->_em->getConfiguration()->setEntityNamespaces(array());
26         }
27         parent::tearDown();
28     }
29
30     public function loadFixture()
31     {
32         $user = new CmsUser;
33         $user->name = 'Roman';
34         $user->username = 'romanb';
35         $user->status = 'freak';
36         $this->_em->persist($user);
37
38         $user2 = new CmsUser;
39         $user2->name = 'Guilherme';
40         $user2->username = 'gblanco';
41         $user2->status = 'dev';
42         $this->_em->persist($user2);
43
44         $user3 = new CmsUser;
45         $user3->name = 'Benjamin';
46         $user3->username = 'beberlei';
47         $user3->status = null;
48         $this->_em->persist($user3);
49
50         $user4 = new CmsUser;
51         $user4->name = 'Alexander';
52         $user4->username = 'asm89';
53         $user4->status = 'dev';
54         $this->_em->persist($user4);
55
56         $this->_em->flush();
57
58         $user1Id = $user->getId();
59
60         unset($user);
61         unset($user2);
62         unset($user3);
63         unset($user4);
64
65         $this->_em->clear();
66
67         return $user1Id;
68     }
69
70     public function loadAssociatedFixture()
71     {
72         $address = new CmsAddress();
73         $address->city = "Berlin";
74         $address->country = "Germany";
75         $address->street = "Foostreet";
76         $address->zip = "12345";
77
78         $user = new CmsUser();
79         $user->name = 'Roman';
80         $user->username = 'romanb';
81         $user->status = 'freak';
82         $user->setAddress($address);
83
84         $this->_em->persist($user);
85         $this->_em->persist($address);
86         $this->_em->flush();
87         $this->_em->clear();
88
89         return array($user->id, $address->id);
90     }
91
92     public function buildUser($name, $username, $status, $address)
93     {
94         $user = new CmsUser();
95         $user->name     = $name;
96         $user->username = $username;
97         $user->status   = $status;
98         $user->setAddress($address);
99
100         $this->_em->persist($user);
101         $this->_em->flush();
102
103         return $user;
104     }
105
106     public function buildAddress($country, $city, $street, $zip)
107     {
108         $address = new CmsAddress();
109         $address->country = $country;
110         $address->city    = $city;
111         $address->street  = $street;
112         $address->zip     = $zip;
113
114         $this->_em->persist($address);
115         $this->_em->flush();
116
117         return $address;
118     }
119
120     public function testBasicFind()
121     {
122         $user1Id = $this->loadFixture();
123         $repos = $this->_em->getRepository('Doctrine\Tests\Models\CMS\CmsUser');
124
125         $user = $repos->find($user1Id);
126         $this->assertInstanceOf('Doctrine\Tests\Models\CMS\CmsUser',$user);
127         $this->assertEquals('Roman', $user->name);
128         $this->assertEquals('freak', $user->status);
129     }
130
131     public function testFindByField()
132     {
133         $user1Id = $this->loadFixture();
134         $repos = $this->_em->getRepository('Doctrine\Tests\Models\CMS\CmsUser');
135
136         $users = $repos->findBy(array('status' => 'dev'));
137         $this->assertEquals(2, count($users));
138         $this->assertInstanceOf('Doctrine\Tests\Models\CMS\CmsUser',$users[0]);
139         $this->assertEquals('Guilherme', $users[0]->name);
140         $this->assertEquals('dev', $users[0]->status);
141     }
142
143     public function testFindByAssociationWithIntegerAsParameter()
144     {
145         $address1 = $this->buildAddress('Germany', 'Berlim', 'Foo st.', '123456');
146         $user1    = $this->buildUser('Benjamin', 'beberlei', 'dev', $address1);
147
148         $address2 = $this->buildAddress('Brazil', 'São Paulo', 'Bar st.', '654321');
149         $user2    = $this->buildUser('Guilherme', 'guilhermeblanco', 'freak', $address2);
150
151         $address3 = $this->buildAddress('USA', 'Nashville', 'Woo st.', '321654');
152         $user3    = $this->buildUser('Jonathan', 'jwage', 'dev', $address3);
153
154         unset($address1);
155         unset($address2);
156         unset($address3);
157
158         $this->_em->clear();
159
160         $repository = $this->_em->getRepository('Doctrine\Tests\Models\CMS\CmsAddress');
161         $addresses  = $repository->findBy(array('user' => array($user1->getId(), $user2->getId())));
162
163         $this->assertEquals(2, count($addresses));
164         $this->assertInstanceOf('Doctrine\Tests\Models\CMS\CmsAddress',$addresses[0]);
165     }
166
167     public function testFindByAssociationWithObjectAsParameter()
168     {
169         $address1 = $this->buildAddress('Germany', 'Berlim', 'Foo st.', '123456');
170         $user1    = $this->buildUser('Benjamin', 'beberlei', 'dev', $address1);
171
172         $address2 = $this->buildAddress('Brazil', 'São Paulo', 'Bar st.', '654321');
173         $user2    = $this->buildUser('Guilherme', 'guilhermeblanco', 'freak', $address2);
174
175         $address3 = $this->buildAddress('USA', 'Nashville', 'Woo st.', '321654');
176         $user3    = $this->buildUser('Jonathan', 'jwage', 'dev', $address3);
177
178         unset($address1);
179         unset($address2);
180         unset($address3);
181
182         $this->_em->clear();
183
184         $repository = $this->_em->getRepository('Doctrine\Tests\Models\CMS\CmsAddress');
185         $addresses  = $repository->findBy(array('user' => array($user1, $user2)));
186
187         $this->assertEquals(2, count($addresses));
188         $this->assertInstanceOf('Doctrine\Tests\Models\CMS\CmsAddress',$addresses[0]);
189     }
190
191     public function testFindFieldByMagicCall()
192     {
193         $user1Id = $this->loadFixture();
194         $repos = $this->_em->getRepository('Doctrine\Tests\Models\CMS\CmsUser');
195
196         $users = $repos->findByStatus('dev');
197         $this->assertEquals(2, count($users));
198         $this->assertInstanceOf('Doctrine\Tests\Models\CMS\CmsUser',$users[0]);
199         $this->assertEquals('Guilherme', $users[0]->name);
200         $this->assertEquals('dev', $users[0]->status);
201     }
202
203     public function testFindAll()
204     {
205         $user1Id = $this->loadFixture();
206         $repos = $this->_em->getRepository('Doctrine\Tests\Models\CMS\CmsUser');
207
208         $users = $repos->findAll();
209         $this->assertEquals(4, count($users));
210     }
211
212     public function testFindByAlias()
213     {
214         $user1Id = $this->loadFixture();
215         $repos = $this->_em->getRepository('Doctrine\Tests\Models\CMS\CmsUser');
216
217         $this->_em->getConfiguration()->addEntityNamespace('CMS', 'Doctrine\Tests\Models\CMS');
218
219         $repos = $this->_em->getRepository('CMS:CmsUser');
220
221         $users = $repos->findAll();
222         $this->assertEquals(4, count($users));
223     }
224
225     /**
226      * @expectedException \Doctrine\ORM\ORMException
227      */
228     public function testExceptionIsThrownWhenCallingFindByWithoutParameter() {
229         $this->_em->getRepository('Doctrine\Tests\Models\CMS\CmsUser')
230                   ->findByStatus();
231     }
232
233     /**
234      * @expectedException \Doctrine\ORM\ORMException
235      */
236     public function testExceptionIsThrownWhenUsingInvalidFieldName() {
237         $this->_em->getRepository('Doctrine\Tests\Models\CMS\CmsUser')
238                   ->findByThisFieldDoesNotExist('testvalue');
239     }
240
241     /**
242      * @group locking
243      * @group DDC-178
244      */
245     public function testPessimisticReadLockWithoutTransaction_ThrowsException()
246     {
247         $this->setExpectedException('Doctrine\ORM\TransactionRequiredException');
248
249         $this->_em->getRepository('Doctrine\Tests\Models\CMS\CmsUser')
250                   ->find(1, \Doctrine\DBAL\LockMode::PESSIMISTIC_READ);
251     }
252
253     /**
254      * @group locking
255      * @group DDC-178
256      */
257     public function testPessimisticWriteLockWithoutTransaction_ThrowsException()
258     {
259         $this->setExpectedException('Doctrine\ORM\TransactionRequiredException');
260
261         $this->_em->getRepository('Doctrine\Tests\Models\CMS\CmsUser')
262                   ->find(1, \Doctrine\DBAL\LockMode::PESSIMISTIC_WRITE);
263     }
264
265     /**
266      * @group locking
267      * @group DDC-178
268      */
269     public function testOptimisticLockUnversionedEntity_ThrowsException()
270     {
271         $this->setExpectedException('Doctrine\ORM\OptimisticLockException');
272
273         $this->_em->getRepository('Doctrine\Tests\Models\CMS\CmsUser')
274                   ->find(1, \Doctrine\DBAL\LockMode::OPTIMISTIC);
275     }
276
277     /**
278      * @group locking
279      * @group DDC-178
280      */
281     public function testIdentityMappedOptimisticLockUnversionedEntity_ThrowsException()
282     {
283         $user = new CmsUser;
284         $user->name = 'Roman';
285         $user->username = 'romanb';
286         $user->status = 'freak';
287         $this->_em->persist($user);
288         $this->_em->flush();
289
290         $userId = $user->id;
291
292         $this->_em->find('Doctrine\Tests\Models\CMS\CmsUser', $userId);
293
294         $this->setExpectedException('Doctrine\ORM\OptimisticLockException');
295         $this->_em->find('Doctrine\Tests\Models\CMS\CmsUser', $userId, \Doctrine\DBAL\LockMode::OPTIMISTIC);
296     }
297
298     /**
299      * @group DDC-819
300      */
301     public function testFindMagicCallByNullValue()
302     {
303         $this->loadFixture();
304
305         $repos = $this->_em->getRepository('Doctrine\Tests\Models\CMS\CmsUser');
306
307         $users = $repos->findByStatus(null);
308         $this->assertEquals(1, count($users));
309     }
310
311     /**
312      * @group DDC-819
313      */
314     public function testInvalidMagicCall()
315     {
316         $this->setExpectedException('BadMethodCallException');
317
318         $repos = $this->_em->getRepository('Doctrine\Tests\Models\CMS\CmsUser');
319         $repos->foo();
320     }
321
322     /**
323      * @group DDC-817
324      */
325     public function testFindByAssociationKey_ExceptionOnInverseSide()
326     {
327         list($userId, $addressId) = $this->loadAssociatedFixture();
328         $repos = $this->_em->getRepository('Doctrine\Tests\Models\CMS\CmsUser');
329
330         $this->setExpectedException('Doctrine\ORM\ORMException', "You cannot search for the association field 'Doctrine\Tests\Models\CMS\CmsUser#address', because it is the inverse side of an association. Find methods only work on owning side associations.");
331         $user = $repos->findBy(array('address' => $addressId));
332     }
333
334     /**
335      * @group DDC-817
336      */
337     public function testFindOneByAssociationKey()
338     {
339         list($userId, $addressId) = $this->loadAssociatedFixture();
340         $repos = $this->_em->getRepository('Doctrine\Tests\Models\CMS\CmsAddress');
341         $address = $repos->findOneBy(array('user' => $userId));
342
343         $this->assertInstanceOf('Doctrine\Tests\Models\CMS\CmsAddress', $address);
344         $this->assertEquals($addressId, $address->id);
345     }
346
347     /**
348      * @group DDC-817
349      */
350     public function testFindByAssociationKey()
351     {
352         list($userId, $addressId) = $this->loadAssociatedFixture();
353         $repos = $this->_em->getRepository('Doctrine\Tests\Models\CMS\CmsAddress');
354         $addresses = $repos->findBy(array('user' => $userId));
355
356         $this->assertContainsOnly('Doctrine\Tests\Models\CMS\CmsAddress', $addresses);
357         $this->assertEquals(1, count($addresses));
358         $this->assertEquals($addressId, $addresses[0]->id);
359     }
360
361     /**
362      * @group DDC-817
363      */
364     public function testFindAssociationByMagicCall()
365     {
366         list($userId, $addressId) = $this->loadAssociatedFixture();
367         $repos = $this->_em->getRepository('Doctrine\Tests\Models\CMS\CmsAddress');
368         $addresses = $repos->findByUser($userId);
369
370         $this->assertContainsOnly('Doctrine\Tests\Models\CMS\CmsAddress', $addresses);
371         $this->assertEquals(1, count($addresses));
372         $this->assertEquals($addressId, $addresses[0]->id);
373     }
374
375     /**
376      * @group DDC-817
377      */
378     public function testFindOneAssociationByMagicCall()
379     {
380         list($userId, $addressId) = $this->loadAssociatedFixture();
381         $repos = $this->_em->getRepository('Doctrine\Tests\Models\CMS\CmsAddress');
382         $address = $repos->findOneByUser($userId);
383
384         $this->assertInstanceOf('Doctrine\Tests\Models\CMS\CmsAddress', $address);
385         $this->assertEquals($addressId, $address->id);
386     }
387
388     public function testValidNamedQueryRetrieval()
389     {
390         $repos = $this->_em->getRepository('Doctrine\Tests\Models\CMS\CmsUser');
391
392         $query = $repos->createNamedQuery('all');
393
394         $this->assertInstanceOf('Doctrine\ORM\Query', $query);
395         $this->assertEquals('SELECT u FROM Doctrine\Tests\Models\CMS\CmsUser u', $query->getDQL());
396     }
397
398     public function testInvalidNamedQueryRetrieval()
399     {
400         $repos = $this->_em->getRepository('Doctrine\Tests\Models\CMS\CmsUser');
401
402         $this->setExpectedException('Doctrine\ORM\Mapping\MappingException');
403
404         $repos->createNamedQuery('invalidNamedQuery');
405     }
406
407     /**
408      * @group DDC-1087
409      */
410     public function testIsNullCriteriaDoesNotGenerateAParameter()
411     {
412         $repos = $this->_em->getRepository('Doctrine\Tests\Models\CMS\CmsUser');
413         $users = $repos->findBy(array('status' => null, 'username' => 'romanb'));
414
415         $params = $this->_sqlLoggerStack->queries[$this->_sqlLoggerStack->currentQuery]['params'];
416         $this->assertEquals(1, count($params), "Should only execute with one parameter.");
417         $this->assertEquals(array('romanb'), $params);
418     }
419
420     public function testIsNullCriteria()
421     {
422         $this->loadFixture();
423
424         $repos = $this->_em->getRepository('Doctrine\Tests\Models\CMS\CmsUser');
425
426         $users = $repos->findBy(array('status' => null));
427         $this->assertEquals(1, count($users));
428     }
429
430     /**
431      * @group DDC-1094
432      */
433     public function testFindByLimitOffset()
434     {
435         $this->loadFixture();
436
437         $repos = $this->_em->getRepository('Doctrine\Tests\Models\CMS\CmsUser');
438
439         $users1 = $repos->findBy(array(), null, 1, 0);
440         $users2 = $repos->findBy(array(), null, 1, 1);
441
442         $this->assertEquals(4, count($repos->findBy(array())));
443         $this->assertEquals(1, count($users1));
444         $this->assertEquals(1, count($users2));
445         $this->assertNotSame($users1[0], $users2[0]);
446     }
447
448     /**
449      * @group DDC-1094
450      */
451     public function testFindByOrderBy()
452     {
453         $this->loadFixture();
454
455         $repos = $this->_em->getRepository('Doctrine\Tests\Models\CMS\CmsUser');
456         $usersAsc = $repos->findBy(array(), array("username" => "ASC"));
457         $usersDesc = $repos->findBy(array(), array("username" => "DESC"));
458
459         $this->assertEquals(4, count($usersAsc), "Pre-condition: only four users in fixture");
460         $this->assertEquals(4, count($usersDesc), "Pre-condition: only four users in fixture");
461         $this->assertSame($usersAsc[0], $usersDesc[3]);
462         $this->assertSame($usersAsc[3], $usersDesc[0]);
463     }
464
465     /**
466      * @group DDC-1426
467      */
468     public function testFindFieldByMagicCallOrderBy()
469     {
470         $this->loadFixture();
471         $repos = $this->_em->getRepository('Doctrine\Tests\Models\CMS\CmsUser');
472
473         $usersAsc = $repos->findByStatus('dev', array('username' => "ASC"));
474         $usersDesc = $repos->findByStatus('dev', array('username' => "DESC"));
475
476         $this->assertEquals(2, count($usersAsc));
477         $this->assertEquals(2, count($usersDesc));
478
479         $this->assertInstanceOf('Doctrine\Tests\Models\CMS\CmsUser',$usersAsc[0]);
480         $this->assertEquals('Alexander', $usersAsc[0]->name);
481         $this->assertEquals('dev', $usersAsc[0]->status);
482
483         $this->assertSame($usersAsc[0], $usersDesc[1]);
484         $this->assertSame($usersAsc[1], $usersDesc[0]);
485     }
486
487     /**
488      * @group DDC-1426
489      */
490     public function testFindFieldByMagicCallLimitOffset()
491     {
492         $this->loadFixture();
493         $repos = $this->_em->getRepository('Doctrine\Tests\Models\CMS\CmsUser');
494
495         $users1 = $repos->findByStatus('dev', array(), 1, 0);
496         $users2 = $repos->findByStatus('dev', array(), 1, 1);
497
498         $this->assertEquals(1, count($users1));
499         $this->assertEquals(1, count($users2));
500         $this->assertNotSame($users1[0], $users2[0]);
501     }
502
503     /**
504      * @group DDC-753
505      */
506     public function testDefaultRepositoryClassName()
507     {
508         $this->assertEquals($this->_em->getConfiguration()->getDefaultRepositoryClassName(), "Doctrine\ORM\EntityRepository");
509         $this->_em->getConfiguration()->setDefaultRepositoryClassName("Doctrine\Tests\Models\DDC753\DDC753DefaultRepository");
510         $this->assertEquals($this->_em->getConfiguration()->getDefaultRepositoryClassName(), "Doctrine\Tests\Models\DDC753\DDC753DefaultRepository");
511
512         $repos = $this->_em->getRepository('Doctrine\Tests\Models\DDC753\DDC753EntityWithDefaultCustomRepository');
513         $this->assertInstanceOf("Doctrine\Tests\Models\DDC753\DDC753DefaultRepository", $repos);
514         $this->assertTrue($repos->isDefaultRepository());
515
516
517         $repos = $this->_em->getRepository('Doctrine\Tests\Models\DDC753\DDC753EntityWithCustomRepository');
518         $this->assertInstanceOf("Doctrine\Tests\Models\DDC753\DDC753CustomRepository", $repos);
519         $this->assertTrue($repos->isCustomRepository());
520
521         $this->assertEquals($this->_em->getConfiguration()->getDefaultRepositoryClassName(), "Doctrine\Tests\Models\DDC753\DDC753DefaultRepository");
522         $this->_em->getConfiguration()->setDefaultRepositoryClassName("Doctrine\ORM\EntityRepository");
523         $this->assertEquals($this->_em->getConfiguration()->getDefaultRepositoryClassName(), "Doctrine\ORM\EntityRepository");
524
525     }
526
527
528     /**
529      * @group DDC-753
530      * @expectedException Doctrine\ORM\ORMException
531      * @expectedExceptionMessage Invalid repository class 'Doctrine\Tests\Models\DDC753\DDC753InvalidRepository'. It must be a Doctrine\Common\Persistence\ObjectRepository.
532      */
533     public function testSetDefaultRepositoryInvalidClassError()
534     {
535         $this->assertEquals($this->_em->getConfiguration()->getDefaultRepositoryClassName(), "Doctrine\ORM\EntityRepository");
536         $this->_em->getConfiguration()->setDefaultRepositoryClassName("Doctrine\Tests\Models\DDC753\DDC753InvalidRepository");
537     }
538
539     /**
540      * @group DDC-1500
541      */
542     public function testInvalidOrientation()
543     {
544         $this->setExpectedException('Doctrine\ORM\ORMException', 'Invalid order by orientation specified for Doctrine\Tests\Models\CMS\CmsUser#username');
545
546         $repo = $this->_em->getRepository('Doctrine\Tests\Models\CMS\CmsUser');
547         $repo->findBy(array('status' => 'test'), array('username' => 'INVALID'));
548     }
549
550     /**
551      * @group DDC-1713
552      */
553     public function testFindByAssocationArray()
554     {
555         $repo = $this->_em->getRepository('Doctrine\Tests\Models\CMS\CmsArticle');
556         $data = $repo->findBy(array('user' => array(1, 2, 3)));
557
558         $query = array_pop($this->_sqlLoggerStack->queries);
559         $this->assertEquals(array(1,2,3), $query['params'][0]);
560         $this->assertEquals(\Doctrine\DBAL\Connection::PARAM_INT_ARRAY, $query['types'][0]);
561     }
562
563     /**
564      * @group DDC-1637
565      */
566     public function testMatchingEmptyCriteria()
567     {
568         $this->loadFixture();
569
570         $repository = $this->_em->getRepository('Doctrine\Tests\Models\CMS\CmsUser');
571         $users = $repository->matching(new Criteria());
572
573         $this->assertEquals(4, count($users));
574     }
575
576     /**
577      * @group DDC-1637
578      */
579     public function testMatchingCriteriaEqComparison()
580     {
581         $this->loadFixture();
582
583         $repository = $this->_em->getRepository('Doctrine\Tests\Models\CMS\CmsUser');
584         $users = $repository->matching(new Criteria(
585             Criteria::expr()->eq('username', 'beberlei')
586         ));
587
588         $this->assertEquals(1, count($users));
589     }
590
591     /**
592      * @group DDC-1637
593      */
594     public function testMatchingCriteriaNeqComparison()
595     {
596         $this->loadFixture();
597
598         $repository = $this->_em->getRepository('Doctrine\Tests\Models\CMS\CmsUser');
599         $users = $repository->matching(new Criteria(
600             Criteria::expr()->neq('username', 'beberlei')
601         ));
602
603         $this->assertEquals(3, count($users));
604     }
605
606     /**
607      * @group DDC-1637
608      */
609     public function testMatchingCriteriaInComparison()
610     {
611         $this->loadFixture();
612
613         $repository = $this->_em->getRepository('Doctrine\Tests\Models\CMS\CmsUser');
614         $users = $repository->matching(new Criteria(
615             Criteria::expr()->in('username', array('beberlei', 'gblanco'))
616         ));
617
618         $this->assertEquals(2, count($users));
619     }
620
621     /**
622      * @group DDC-1637
623      */
624     public function testMatchingCriteriaNotInComparison()
625     {
626         $this->loadFixture();
627
628         $repository = $this->_em->getRepository('Doctrine\Tests\Models\CMS\CmsUser');
629         $users = $repository->matching(new Criteria(
630             Criteria::expr()->notIn('username', array('beberlei', 'gblanco', 'asm89'))
631         ));
632
633         $this->assertEquals(1, count($users));
634     }
635
636     /**
637      * @group DDC-1637
638      */
639     public function testMatchingCriteriaLtComparison()
640     {
641         $firstUserId = $this->loadFixture();
642
643         $repository = $this->_em->getRepository('Doctrine\Tests\Models\CMS\CmsUser');
644         $users = $repository->matching(new Criteria(
645             Criteria::expr()->lt('id', $firstUserId + 1)
646         ));
647
648         $this->assertEquals(1, count($users));
649     }
650
651     /**
652      * @group DDC-1637
653      */
654     public function testMatchingCriteriaLeComparison()
655     {
656         $firstUserId = $this->loadFixture();
657
658         $repository = $this->_em->getRepository('Doctrine\Tests\Models\CMS\CmsUser');
659         $users = $repository->matching(new Criteria(
660             Criteria::expr()->lte('id', $firstUserId + 1)
661         ));
662
663         $this->assertEquals(2, count($users));
664     }
665
666     /**
667      * @group DDC-1637
668      */
669     public function testMatchingCriteriaGtComparison()
670     {
671         $firstUserId = $this->loadFixture();
672
673         $repository = $this->_em->getRepository('Doctrine\Tests\Models\CMS\CmsUser');
674         $users = $repository->matching(new Criteria(
675             Criteria::expr()->gt('id', $firstUserId)
676         ));
677
678         $this->assertEquals(3, count($users));
679     }
680
681     /**
682      * @group DDC-1637
683      */
684     public function testMatchingCriteriaGteComparison()
685     {
686         $firstUserId = $this->loadFixture();
687
688         $repository = $this->_em->getRepository('Doctrine\Tests\Models\CMS\CmsUser');
689         $users = $repository->matching(new Criteria(
690             Criteria::expr()->gte('id', $firstUserId)
691         ));
692
693         $this->assertEquals(4, count($users));
694     }
695 }
696