/**
  *
  */
 public function testWriteManyMany_SetChildrenForParent_RelationWritten()
 {
     $parent = new Human();
     $parent->Name = 'Bob';
     $children = array();
     for ($i = 0; $i < 5; $i++) {
         $child = new Child();
         $child->Name = 'Soldier #' . $i;
         $children[] = $child;
     }
     $writer = new \BatchedWriter();
     $afterExists = new \OnAfterExists(function () use($writer, $parent, $children) {
         $writer->writeManyMany($parent, 'Children', $children);
     });
     $afterExists->addCondition($parent);
     $afterExists->addCondition($children);
     $writer->write(array($parent));
     $writer->write($children);
     $writer->finish();
     $parent = Human::get()->first();
     $this->assertEquals(5, $parent->Children()->Count());
 }
 /**
  * @param $object
  * @param $relation
  * @param $manyManyObjects
  */
 public function writeManyMany($object, $relation, $manyManyObjects)
 {
     $this->batchWriter->writeManyMany($object, $relation, $manyManyObjects);
 }