/** * @magentoDataFixture Magento/Catalog/_files/categories.php */ public function testGetRemoveUrl() { /** @var $objectManager \Magento\TestFramework\ObjectManager */ $objectManager = \Magento\TestFramework\Helper\Bootstrap::getObjectManager(); /** @var $request \Magento\TestFramework\Request */ $request = $objectManager->create('Magento\\Framework\\App\\RequestInterface'); \Magento\TestFramework\Helper\Bootstrap::getObjectManager()->get('Magento\\Framework\\App\\RequestInterface')->setRoutingInfo(array('requested_route' => 'x', 'requested_controller' => 'y', 'requested_action' => 'z')); $request->setParam('cat', 4); $this->_model->getFilter()->apply($request, \Magento\TestFramework\Helper\Bootstrap::getObjectManager()->get('Magento\\Framework\\View\\LayoutInterface')->createBlock('Magento\\Framework\\View\\Element\\Text')); $this->assertStringEndsWith('/x/y/z/?cat=3', $this->_model->getRemoveUrl()); }
public function getRemoveUrl() { if ($this->helper->isActiveEngine()) { if (!$this->hasSelectedValues() || empty($this->getSelectedValues())) { return parent::getRemoveUrl(); } /** @var array $values */ $values = $this->getSelectedValues(); $values = array_diff($values, [$this->getValue()]); if (empty($values)) { return parent::getRemoveUrl(); } $query = [$this->getFilter()->getRequestVar() => implode(',', $values), $this->_htmlPagerBlock->getPageVarName() => null]; return $this->_url->getUrl('*/*/*', ['_current' => true, '_use_rewrite' => true, '_query' => $query]); } return parent::getRemoveUrl(); }