public function testProductServiceGetProductByPath() { $productPath = 'foo'; $repository = $this->getMockBuilder(ObjectRepository::class)->getMock(); $product = new Product(); $repository->expects(self::once())->method('findOneBy')->with(['path' => $productPath])->will(self::returnValue($product->setPath($productPath))); $service = new ProductService($repository); self::assertEquals($product->setPath($productPath), $service->getProductByPath($productPath)); }