public function testGetHrefWithForProductWithCategoryIdParameter() { $storeId = 15; $this->block->setData('id_path', ProductUrlRewriteGenerator::ENTITY_TYPE . '/entity_id/category_id'); $store = $this->getMock('Magento\\Store\\Model\\Store', ['getId', '__wakeUp'], [], '', false); $store->expects($this->any())->method('getId')->will($this->returnValue($storeId)); $this->storeManager->expects($this->any())->method('getStore')->will($this->returnValue($store)); $this->urlFinder->expects($this->once())->method('findOneByData')->with([UrlRewrite::ENTITY_ID => 'entity_id', UrlRewrite::ENTITY_TYPE => ProductUrlRewriteGenerator::ENTITY_TYPE, UrlRewrite::STORE_ID => $storeId, UrlRewrite::METADATA => ['category_id' => 'category_id']])->will($this->returnValue(false)); $this->block->getHref(); }
/** * @param \Magento\Framework\View\Element\Template\Context $context * @param \Magento\UrlRewrite\Model\Resource\UrlRewrite $urlRewrite * @param \Magento\Catalog\Model\Resource\Category $resourceCategory * @param array $data */ public function __construct(\Magento\Framework\View\Element\Template\Context $context, \Magento\UrlRewrite\Model\Resource\UrlRewrite $urlRewrite, \Magento\Catalog\Model\Resource\Category $resourceCategory, array $data = array()) { parent::__construct($context, $urlRewrite, $data); $this->_entityResource = $resourceCategory; }