findByName() публичный Метод

Find by name.
public findByName ( $name ) : mixed
$name
Результат mixed
Пример #1
0
 /**
  * Find a category by name.
  *
  * @param $name
  * @throws CategoryNotFoundException
  * @return mixed
  */
 public function findByName($name)
 {
     $category = $this->categoryRepo->findByName($name);
     if (is_null($category)) {
         $error = 'Category Not Found';
         throw new CategoryNotFoundException($error);
     }
     return $category;
 }
Пример #2
0
 /** @test */
 function it_try_to_find_a_non_existing_category(CategoryDB $categoryRepository)
 {
     $nameCategory = 'test.category';
     $categoryRepository->findByName($nameCategory)->shouldBeCalled()->willReturn(null);
     $this->shouldThrow(CategoryNotFoundException::class)->during('findByName', [$nameCategory]);
 }