/** * Find a group By name * * @param $group_name * @return mixed * @throws \Fenos\Notifynder\Exceptions\NotifynderGroupNotFoundException */ public function findByName($group_name) { $group = $this->groupRepo->findByName($group_name); if (is_null($group)) { $error = "Group Not Found"; throw new NotifynderGroupNotFoundException($error); } return $group; }
/** @test */ function it_try_to_find_an_not_existing_group_by_name(NotifynderGroupDB $groupDB) { $group_name = 'mygroup'; $groupDB->findByName($group_name)->shouldBeCalled()->willReturn(null); $this->shouldThrow(NotifynderGroupNotFoundException::class)->during('findByName', [$group_name]); }