public function testProductServiceGetProductById() { $productId = 5; $repository = $this->getMockBuilder(ObjectRepository::class)->getMock(); $product = new Product(); $repository->expects(self::once())->method('findOneBy')->with(['id' => $productId])->will(self::returnValue($product->setId($productId))); $service = new ProductService($repository); self::assertEquals($product->setId($productId), $service->getProductById($productId)); }
/** * {@inheritDoc} */ public function setId($id) { $this->__initializer__ && $this->__initializer__->__invoke($this, 'setId', [$id]); return parent::setId($id); }