/** * @param \Magento\Framework\Event\Observer $observer * @return void */ public function execute(\Magento\Framework\Event\Observer $observer) { /** @var Product $product */ $product = $observer->getEvent()->getProduct(); $product->setUrlKey($this->productUrlPathGenerator->getUrlKey($product)); }
/** * @param string|bool $productUrlKey * @param string|bool $expectedUrlKey * @dataProvider getUrlKeyDataProvider */ public function testGetUrlKey($productUrlKey, $expectedUrlKey) { $this->product->expects($this->any())->method('getUrlKey')->will($this->returnValue($productUrlKey)); $this->product->expects($this->any())->method('formatUrlKey')->will($this->returnValue($productUrlKey)); $this->assertEquals($expectedUrlKey, $this->productUrlPathGenerator->getUrlKey($this->product)); }