@@ -353,6 +353,45 @@ public function comlexQueryWithJoinsCanBeExecutedAfterDeserialization()
353
353
self ::assertEquals ([$ testEntity2 ], $ unserializedQuery ->execute ()->toArray ());
354
354
}
355
355
356
+ /**
357
+ * @test
358
+ */
359
+ public function countReturnsCorrectNumberOfEntities ()
360
+ {
361
+ $ testEntityRepository = new \Neos \Flow \Tests \Functional \Persistence \Fixtures \TestEntityRepository ();
362
+ $ testEntityRepository ->removeAll ();
363
+
364
+ $ testEntity = new \Neos \Flow \Tests \Functional \Persistence \Fixtures \TestEntity ;
365
+ $ testEntity ->setName ('Flow ' );
366
+
367
+ $ subEntity1 = new \Neos \Flow \Tests \Functional \Persistence \Fixtures \SubEntity ;
368
+ $ subEntity1 ->setContent ('foo ' );
369
+ $ subEntity1 ->setParentEntity ($ testEntity );
370
+ $ testEntity ->addSubEntity ($ subEntity1 );
371
+ $ this ->persistenceManager ->add ($ subEntity1 );
372
+
373
+ $ subEntity2 = new \Neos \Flow \Tests \Functional \Persistence \Fixtures \SubEntity ;
374
+ $ subEntity2 ->setContent ('foo ' );
375
+ $ subEntity2 ->setParentEntity ($ testEntity );
376
+ $ testEntity ->addSubEntity ($ subEntity2 );
377
+ $ this ->persistenceManager ->add ($ subEntity2 );
378
+
379
+ $ testEntityRepository ->add ($ testEntity );
380
+
381
+ $ this ->persistenceManager ->persistAll ();
382
+
383
+ $ query = new Query (\Neos \Flow \Tests \Functional \Persistence \Fixtures \TestEntity::class);
384
+
385
+ $ constraint = $ query ->logicalAnd ($ query ->equals ('subEntities.content ' , 'foo ' ));
386
+ $ result = $ query ->matching ($ constraint )->execute ();
387
+
388
+ $ count = $ result ->count ();
389
+ $ arrayCount = $ result ->toArray ();
390
+
391
+ self ::assertEquals (1 , count ($ arrayCount ), 'This correctly returns 1 ' );
392
+ self ::assertEquals (1 , $ count , 'this returns 2 ' );
393
+ }
394
+
356
395
protected function assertQueryEquals (Query $ expected , Query $ actual )
357
396
{
358
397
self ::assertEquals ($ expected ->getConstraint (), $ actual ->getConstraint ());
0 commit comments