|
@@ 478-497 (lines=20) @@
|
| 475 |
|
$this->assertFalse($user->groups->isInitialized(), "Post-condition: matching does not initialize collection"); |
| 476 |
|
} |
| 477 |
|
|
| 478 |
|
public function testMatchingWithOffset() |
| 479 |
|
{ |
| 480 |
|
$user = $this->addCmsUserGblancoWithGroups(2); |
| 481 |
|
$this->_em->clear(); |
| 482 |
|
|
| 483 |
|
$user = $this->_em->find(get_class($user), $user->id); |
| 484 |
|
|
| 485 |
|
$groups = $user->groups; |
| 486 |
|
$this->assertFalse($user->groups->isInitialized(), "Pre-condition: lazy collection"); |
| 487 |
|
|
| 488 |
|
$criteria = Criteria::create()->setFirstResult(1); |
| 489 |
|
$result = $groups->matching($criteria); |
| 490 |
|
|
| 491 |
|
$this->assertCount(1, $result); |
| 492 |
|
|
| 493 |
|
$firstGroup = $result->first(); |
| 494 |
|
$this->assertEquals('Developers_1', $firstGroup->name); |
| 495 |
|
|
| 496 |
|
$this->assertFalse($user->groups->isInitialized(), "Post-condition: matching does not initialize collection"); |
| 497 |
|
} |
| 498 |
|
|
| 499 |
|
public function testMatchingWithLimitAndOffset() |
| 500 |
|
{ |
|
@@ 523-542 (lines=20) @@
|
| 520 |
|
$this->assertFalse($user->groups->isInitialized(), "Post-condition: matching does not initialize collection"); |
| 521 |
|
} |
| 522 |
|
|
| 523 |
|
public function testMatching() |
| 524 |
|
{ |
| 525 |
|
$user = $this->addCmsUserGblancoWithGroups(2); |
| 526 |
|
$this->_em->clear(); |
| 527 |
|
|
| 528 |
|
$user = $this->_em->find(get_class($user), $user->id); |
| 529 |
|
|
| 530 |
|
$groups = $user->groups; |
| 531 |
|
$this->assertFalse($user->groups->isInitialized(), "Pre-condition: lazy collection"); |
| 532 |
|
|
| 533 |
|
$criteria = Criteria::create()->where(Criteria::expr()->eq('name', (string) 'Developers_0')); |
| 534 |
|
$result = $groups->matching($criteria); |
| 535 |
|
|
| 536 |
|
$this->assertCount(1, $result); |
| 537 |
|
|
| 538 |
|
$firstGroup = $result->first(); |
| 539 |
|
$this->assertEquals('Developers_0', $firstGroup->name); |
| 540 |
|
|
| 541 |
|
$this->assertFalse($user->groups->isInitialized(), "Post-condition: matching does not initialize collection"); |
| 542 |
|
} |
| 543 |
|
} |
| 544 |
|
|