/** * Run test prepare method * * @return void */ public function testPrepare() { /** * @var \Magento\Framework\View\Element\UiComponent\ConfigInterface * |\PHPUnit_Framework_MockObject_MockObject $configurationMock */ $configurationMock = $this->getMockForAbstractClass('Magento\\Framework\\View\\Element\\UiComponent\\ConfigInterface', [], '', false); /** * @var \Magento\Framework\View\Element\UiComponent\ConfigStorageInterface * |\PHPUnit_Framework_MockObject_MockObject $configStorageMock */ $configStorageMock = $this->getMockForAbstractClass('Magento\\Framework\\View\\Element\\UiComponent\\ConfigStorageInterface', ['addComponentsData', 'getDataCollection', 'getMeta'], '', false); $this->renderContextMock->expects($this->at(0))->method('getNamespace')->will($this->returnValue('namespace')); $this->renderContextMock->expects($this->at(1))->method('getNamespace')->will($this->returnValue('namespace')); $this->configFactoryMock->expects($this->any())->method('create')->will($this->returnValue($configurationMock)); $this->renderContextMock->expects($this->any())->method('getStorage')->will($this->returnValue($configStorageMock)); $configStorageMock->expects($this->once())->method('addComponentsData')->with($configurationMock); $this->assertNull($this->filter->prepare()); }
/** * Run test getActiveFilters method * * @return void */ public function _testGetActiveFilters() { $result = ['field-1' => ['title' => 'title-1', 'current_display_value' => 'value-1'], 'field-2' => ['title' => 'title-2', 'current_display_value' => 'value-2'], 'field-3' => ['title' => 'title-3', 'current_display_value' => 'value-3'], 'field-4' => ['title' => 'title-4', 'current_display_value' => 'value-4']]; $meta = ['fields' => ['field-1' => ['filter_type' => true, 'title' => 'title-1'], 'field-2' => ['filter_type' => true, 'title' => 'title-2'], 'field-3' => ['filter_type' => true, 'title' => 'title-3'], 'field-4' => ['filter_type' => true, 'title' => 'title-4']]]; $filters = ['field-1' => 'value-1', 'field-2' => 'value-2', 'field-3' => 'value-3', 'field-4' => 'value-4']; /** * @var \Magento\Framework\View\Element\UiComponent\ConfigInterface * |\PHPUnit_Framework_MockObject_MockObject $configurationMock */ $configMock = $this->getMockForAbstractClass('Magento\\Framework\\View\\Element\\UiComponent\\ConfigInterface', [], '', false); /** * @var \Magento\Framework\View\Element\UiComponent\ConfigStorageInterface * |\PHPUnit_Framework_MockObject_MockObject $configStorageMock */ $configStorageMock = $this->getMockForAbstractClass('Magento\\Framework\\View\\Element\\UiComponent\\ConfigStorageInterface', ['addComponentsData', 'getDataCollection', 'getMeta'], '', false); $this->filterPool->setConfig($configMock); $this->renderContextMock->expects($this->any())->method('getStorage')->will($this->returnValue($configStorageMock)); $configStorageMock->expects($this->any())->method('getMeta')->will($this->returnValue($meta)); $this->dataHelperMock->expects($this->once())->method('prepareFilterString')->will($this->returnValue($filters)); $this->renderContextMock->expects($this->once())->method('getRequestParam')->with(static::FILTER_VAR); $this->assertEquals($result, $this->filterPool->getActiveFilters()); }