コード例 #1
0
 /**
  * Run test prepare method
  *
  * @return void
  * @SuppressWarnings(PHPMD.UnusedLocalVariable)
  */
 public function testPrepare()
 {
     /**
      * @var \Magento\Framework\View\Element\UiComponent\ConfigInterface
      * |\PHPUnit_Framework_MockObject_MockObject $configurationMock
      */
     $configurationMock = $this->getMockForAbstractClass('Magento\\Framework\\View\\Element\\UiComponent\\ConfigInterface', ['getParentName'], '', 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);
     /**
      * @var \Magento\Framework\Data\Collection|\PHPUnit_Framework_MockObject_MockObject $dataCollectionMock
      */
     $dataCollectionMock = $this->getMock('Magento\\Framework\\Data\\Collection', ['setOrder'], [], '', 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->at(0))->method('getDataCollection')->will($this->returnValue($dataCollectionMock));
     $configStorageMock->expects($this->at(1))->method('getDataCollection')->will($this->returnValue($dataCollectionMock));
     $metaData = ['field-1' => 'value-1', 'field-2' => 'value-2', 'field-3' => 'value-3', 'field-4' => 'value-4'];
     $meta = ['fields' => $metaData];
     $filters = $metaData;
     $configStorageMock->expects($this->any())->method('getMeta')->will($this->returnValue($meta));
     $this->renderContextMock->expects($this->once())->method('getRequestParam')->with(static::FILTER_VAR);
     $filterMock = $this->getMockForAbstractClass('Magento\\Ui\\Component\\Filter\\FilterInterface', ['getCondition'], '', false);
     $this->filterPoolProviderMock->expects($this->any())->method('getFilter')->will($this->returnValue($filterMock));
     $filterMock->expects($this->any())->method('getCondition')->will($this->returnValue(true));
     $dataCollectionMock->expects($this->any())->method('addFieldToFilter');
     $this->assertNull($this->filterPool->prepare());
 }
コード例 #2
0
 /**
  * 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());
 }