/**
  * @param Folder $folder
  */
 private function deleteChildren(Folder $folder)
 {
     $em = $this->getEntityManager();
     /** @var Folder $child */
     foreach ($folder->getChildren() as $child) {
         $this->deleteMedia($child);
         $this->deleteChildren($child);
         $child->setDeleted(true);
         $em->persist($child);
     }
 }
 /**
  * @covers Kunstmaan\MediaBundle\Entity\Folder::getChildren
  * @covers Kunstmaan\MediaBundle\Entity\Folder::setChildren
  */
 public function testGetSetChildren()
 {
     $child = new Folder();
     $deletedChild = new Folder();
     $deletedChild->setDeleted(true);
     $children = new ArrayCollection();
     $children->add($child);
     $children->add($deletedChild);
     $this->object->setChildren($children);
     $this->assertCount(1, $this->object->getChildren());
     $this->assertCount(1, $this->object->getChildren(false));
     $this->assertCount(2, $this->object->getChildren(true));
     $children = $this->object->getChildren(false);
     $this->assertContains($child, $children);
     $this->assertNotContains($deletedChild, $children);
     $children = $this->object->getChildren(true);
     $this->assertContains($child, $children);
     $this->assertContains($deletedChild, $children);
 }