public function testStoreManyToManyAssociationWhitCascade()
 {
     $this->evictRegions();
     $this->loadFixturesCountries();
     $this->loadFixturesStates();
     $this->loadFixturesCities();
     $this->cache->evictEntityRegion(City::CLASSNAME);
     $this->cache->evictEntityRegion(Traveler::CLASSNAME);
     $this->cache->evictEntityRegion(Travel::CLASSNAME);
     $this->cache->evictCollectionRegion(State::CLASSNAME, 'cities');
     $this->cache->evictCollectionRegion(Traveler::CLASSNAME, 'travels');
     $traveler = new Traveler('Doctrine Bot');
     $travel = new Travel($traveler);
     $travel->addVisitedCity($this->cities[0]);
     $travel->addVisitedCity($this->cities[1]);
     $travel->addVisitedCity($this->cities[3]);
     $this->_em->persist($traveler);
     $this->_em->persist($travel);
     $this->_em->flush();
     $this->_em->clear();
     $this->assertTrue($this->cache->containsEntity(Travel::CLASSNAME, $travel->getId()));
     $this->assertTrue($this->cache->containsEntity(Traveler::CLASSNAME, $traveler->getId()));
     $this->assertTrue($this->cache->containsEntity(City::CLASSNAME, $this->cities[0]->getId()));
     $this->assertTrue($this->cache->containsEntity(City::CLASSNAME, $this->cities[1]->getId()));
     $this->assertTrue($this->cache->containsEntity(City::CLASSNAME, $this->cities[3]->getId()));
     $this->assertTrue($this->cache->containsCollection(Travel::CLASSNAME, 'visitedCities', $travel->getId()));
     $queryCount1 = $this->getCurrentQueryCount();
     $t1 = $this->_em->find(Travel::CLASSNAME, $travel->getId());
     $this->assertInstanceOf(Travel::CLASSNAME, $t1);
     $this->assertCount(3, $t1->getVisitedCities());
     $this->assertEquals($queryCount1, $this->getCurrentQueryCount());
 }
 protected function loadFixturesTravels()
 {
     $t1 = new Travel($this->travelers[0]);
     $t2 = new Travel($this->travelers[1]);
     $t3 = new Travel($this->travelers[1]);
     $t1->addVisitedCity($this->cities[0]);
     $t1->addVisitedCity($this->cities[1]);
     $t1->addVisitedCity($this->cities[2]);
     $t2->addVisitedCity($this->cities[1]);
     $t2->addVisitedCity($this->cities[3]);
     $this->_em->persist($t1);
     $this->_em->persist($t2);
     $this->_em->persist($t3);
     $this->travels[] = $t1;
     $this->travels[] = $t2;
     $this->travels[] = $t3;
     $this->_em->flush();
 }