Example #1
0
 public function testFindByfilterComponentsDontLookIntheDatabaseItWontHelpYou()
 {
     $this->populateA1();
     $a1r = $this->entityManager->getRepository('A1');
     $a2r = $this->entityManager->getRepository('A2');
     $db = $this->entityManager->db;
     $numQuerys = $db->numQuerys;
     # Verify the unit tests are using the same db connection as the repos.
     $a2r->findAll();
     $this->assertSame(++$numQuerys, $db->numQuerys);
     $factory = new FindFilterComponentFactory([PropertyMapperEntityData::class]);
     # The following shouldn't hit the database -  empty container
     $a1s = $a1r->findByFilterComponents(FindFilterComponentFactory::FIND_ALL, ['foreign_key' => $factory->get('foreign_key', null, new Container())], Repository::ALL);
     $this->assertSame($numQuerys, $db->numQuerys);
     return;
     # container with two non persisted entities
     $a1s = $a1r->findByFilterComponents(FindFilterComponentFactory::FIND_ALL, array('foreign_key' => FindFilterComponent::factory('foreign_key', null, new Container($a2r->make(), $a2r->make()))), Repository::ALL);
     $this->assertSame($numQuerys, $db->numQuerys);
     # entity
     $a1s = $a1r->findByFilterComponents(FindFilterComponentFactory::FIND_ALL, array('foreign_key' => FindFilterComponent::factory('foreign_key', null, $a2r->make())), Repository::ALL);
     $this->assertSame($numQuerys, $db->numQuerys);
 }