Exemplo n.º 1
0
 /**
  * @param \AppBundle\Entity\Troop\Troop $troop
  * @param integer $roleId
  * @param string $label
  * @throws \InvalidArgumentException
  * @return \AppBundle\Entity\Troop\Role
  */
 public function updateRole(Troop $troop, $roleId, $label)
 {
     if (($role = $this->em->getRepository(Role::class)->findOneBy(['id' => $roleId, 'troop' => $troop])) === null) {
         throw new \InvalidArgumentException($this->translator->trans('troops.roles.not_found'));
     }
     $role->setLabel($label)->setSlug($this->slugger->slugify($label));
     $this->em->flush();
     return $role;
 }
Exemplo n.º 2
0
 /**
  * @dataProvider getSlugs
  */
 public function testSlugify($string, $slug)
 {
     $slugger = new Slugger();
     $result = $slugger->slugify($string);
     $this->assertEquals($slug, $result);
 }