/**
  * @test
  */
 public function distinctQueryOnlyReturnsDistinctEntities()
 {
     $testEntityRepository = new \TYPO3\Flow\Tests\Functional\Persistence\Fixtures\TestEntityRepository();
     $testEntityRepository->removeAll();
     $testEntity = new \TYPO3\Flow\Tests\Functional\Persistence\Fixtures\TestEntity();
     $testEntity->setName('Flow');
     $subEntity1 = new \TYPO3\Flow\Tests\Functional\Persistence\Fixtures\SubEntity();
     $subEntity1->setContent('value');
     $subEntity1->setParentEntity($testEntity);
     $testEntity->addSubEntity($subEntity1);
     $this->persistenceManager->add($subEntity1);
     $subEntity2 = new \TYPO3\Flow\Tests\Functional\Persistence\Fixtures\SubEntity();
     $subEntity2->setContent('value');
     $subEntity2->setParentEntity($testEntity);
     $testEntity->addSubEntity($subEntity2);
     $this->persistenceManager->add($subEntity2);
     $testEntityRepository->add($testEntity);
     $testEntity2 = new \TYPO3\Flow\Tests\Functional\Persistence\Fixtures\TestEntity();
     $testEntity2->setName('Flow');
     $subEntity3 = new \TYPO3\Flow\Tests\Functional\Persistence\Fixtures\SubEntity();
     $subEntity3->setContent('value');
     $subEntity3->setParentEntity($testEntity2);
     $testEntity2->addSubEntity($subEntity3);
     $this->persistenceManager->add($subEntity3);
     $testEntityRepository->add($testEntity2);
     $this->persistenceManager->persistAll();
     $query = new Query(\TYPO3\Flow\Tests\Functional\Persistence\Fixtures\TestEntity::class);
     $entities = $query->matching($query->equals('subEntities.content', 'value'))->setDistinct()->setLimit(2)->execute()->toArray();
     $this->assertEquals(2, count($entities));
 }
 /**
  * @test
  */
 public function countRespectsOffsetConstraint()
 {
     $testEntityRepository = new \TYPO3\Flow\Tests\Functional\Persistence\Fixtures\TestEntityRepository();
     $testEntityRepository->removeAll();
     $testEntity1 = new \TYPO3\Flow\Tests\Functional\Persistence\Fixtures\TestEntity();
     $testEntity1->setName('Flow');
     $testEntityRepository->add($testEntity1);
     $testEntity2 = new \TYPO3\Flow\Tests\Functional\Persistence\Fixtures\TestEntity();
     $testEntity2->setName('some');
     $testEntityRepository->add($testEntity2);
     $testEntity3 = new \TYPO3\Flow\Tests\Functional\Persistence\Fixtures\TestEntity();
     $testEntity3->setName('more');
     $testEntityRepository->add($testEntity3);
     $this->persistenceManager->persistAll();
     $query = new Query('TYPO3\\Flow\\Tests\\Functional\\Persistence\\Fixtures\\TestEntity');
     $this->assertEquals(1, $query->setOffset(2)->execute()->count());
 }