Ejemplo n.º 1
0
 /**
  * @param string $objectDataIndex
  * @param string $periodType
  */
 private function mockGridDateColumnConfig($objectDataIndex, $periodType)
 {
     $columnMock = $this->getMockBuilder('Magento\\Backend\\Block\\Widget\\Grid\\Column')->disableOriginalConstructor()->setMethods(['getIndex', 'getPeriodType'])->getMock();
     $columnMock->expects($this->once())->method('getIndex')->willReturn($objectDataIndex);
     $columnMock->expects($this->atLeastOnce())->method('getPeriodType')->willReturn($periodType);
     $this->date->setColumn($columnMock);
 }
Ejemplo n.º 2
0
 /**
  * @param string $data
  * @param string $index
  * @param string $locale
  * @param string $period
  * @param string $result
  * @dataProvider datesDataProvider
  * @return void
  */
 public function testRender($data, $index, $locale, $period, $result)
 {
     $this->resolverMock->expects($this->any())->method('getLocale')->will($this->returnValue($locale));
     $this->localeDate->expects($this->any())->method('getDateFormat')->willReturnCallback(function ($value) use($locale) {
         return (new \IntlDateFormatter($locale, $value, \IntlDateFormatter::NONE))->getPattern();
     });
     $objectMock = $this->getMockBuilder('Magento\\Framework\\Object')->setMethods(['getData'])->getMock();
     $objectMock->expects($this->once())->method('getData')->will($this->returnValue($data));
     $columnMock = $this->getMockBuilder('Magento\\Backend\\Block\\Widget\\Grid\\Column')->disableOriginalConstructor()->setMethods(['getIndex', 'getPeriodType'])->getMock();
     $columnMock->expects($this->once())->method('getIndex')->will($this->returnValue($index));
     $columnMock->expects($this->atLeastOnce())->method('getPeriodType')->will($this->returnValue($period));
     $this->date->setColumn($columnMock);
     $this->assertEquals($result, $this->date->render($objectMock));
 }