Esempio n. 1
0
 /**
  * Test getExecutionTime()
  */
 public function testGetExecutionTime()
 {
     $time = '01:02:03';
     $this->timezone->expects($this->any())->method('date')->willReturnSelf();
     $this->timezone->expects($this->any())->method('getConfigTimezone')->willReturn('America/Los_Angeles');
     $this->timezone->expects($this->any())->method('diff')->willReturnSelf();
     $this->timezone->expects($this->any())->method('format')->willReturn($time);
     $this->assertEquals($time, $this->report->getExecutionTime($time));
 }
 public function testExecute()
 {
     $data = new \DateTime();
     $this->localeResolver->expects($this->once())->method('emulate')->with(0);
     $this->localeDate->expects($this->once())->method('date')->will($this->returnValue($data));
     $this->reportRule->expects($this->once())->method('aggregate')->with($data);
     $this->localeResolver->expects($this->once())->method('revert');
     $scheduleMock = $this->getMock('Magento\\Cron\\Model\\Schedule', [], [], '', false);
     $this->assertEquals($this->model, $this->model->execute($scheduleMock));
 }
Esempio n. 3
0
 public function testTimestamp()
 {
     $time = time();
     $this->localeDate->expects($this->at(0))->method('date')->with(1404377188)->will($this->returnValue($this->date));
     $this->localeDate->expects($this->at(1))->method('date')->with($time)->will($this->returnValue($this->date));
     $this->localeDate->expects($this->at(2))->method('date')->with(strtotime("10 September 2000"))->will($this->returnValue($this->date));
     $this->assertSame(1403806949, $this->dateTime->timestamp());
     $this->assertSame(1403806949, $this->dateTime->timestamp($time));
     $this->assertSame(1403806949, $this->dateTime->timestamp("10 September 2000"));
 }
Esempio n. 4
0
 public function testAggregateSalesReportCouponsData()
 {
     $data = new \DateTime();
     $this->localeResolver->expects($this->once())->method('emulate')->with(0);
     $this->localeDate->expects($this->once())->method('date')->will($this->returnValue($data));
     $this->reportRule->expects($this->once())->method('aggregate')->with($data);
     $this->localeResolver->expects($this->once())->method('revert');
     $this->assertEquals($this->model, $this->model->aggregateSalesReportCouponsData());
 }
Esempio n. 5
0
 protected function prepareMeta()
 {
     $meta = ['fields' => [['data_type' => 'date', 'options_provider' => 'provider', 'options' => ['option1']]]];
     $this->listingView->setData('meta', $meta);
     $this->localeDate->expects($this->any())->method('getDateTimeFormat')->with('medium')->willReturn('format_type');
     $options = $this->getMock('Magento\\Cms\\Ui\\DataProvider\\Page\\Options\\PageLayout', [], [], '', false);
     $this->optionsFactory->expects($this->any())->method('create')->with('provider')->willReturn($options);
     $options->expects($this->any())->method('getOptions')->with(['option1'])->willReturn(['option1']);
 }
Esempio n. 6
0
 public function testAggregateSalesReportCouponsData()
 {
     $dateMock = $this->getMock('Magento\\Framework\\Stdlib\\DateTime\\DateInterface', [], [], '', false);
     $this->localeResolver->expects($this->once())->method('emulate')->with(0);
     $this->localeDate->expects($this->once())->method('date')->will($this->returnValue($dateMock));
     $dateMock->expects($this->once())->method('subHour')->with(25)->will($this->returnSelf());
     $this->reportRule->expects($this->once())->method('aggregate')->with($dateMock);
     $this->localeResolver->expects($this->once())->method('revert');
     $this->assertEquals($this->model, $this->model->aggregateSalesReportCouponsData());
 }
Esempio n. 7
0
 public function setUp()
 {
     $this->modelContext = $this->getMock('Magento\\Framework\\Model\\Context', [], [], '', false);
     $this->registry = $this->getMock('Magento\\Framework\\Registry', [], [], '', false);
     $this->extensionFactory = $this->getMock('Magento\\Framework\\Api\\ExtensionAttributesFactory', [], [], '', false);
     $this->customAttributeFactory = $this->getMock('Magento\\Framework\\Api\\AttributeValueFactory', [], [], '', false);
     $this->eavConfig = $this->getMock('Magento\\Eav\\Model\\Config', [], [], '', false);
     $this->eavTypeFactory = $this->getMock('Magento\\Eav\\Model\\Entity\\TypeFactory', [], [], '', false);
     $this->storeManager = $this->getMock('Magento\\Store\\Model\\StoreManager', [], [], '', false);
     $this->resourceHelper = $this->getMock('Magento\\Eav\\Model\\ResourceModel\\Helper', [], [], '', false);
     $this->universalFactory = $this->getMock('Magento\\Framework\\Validator\\UniversalFactory', [], [], '', false);
     $this->optionDataFactory = $this->getMock('Magento\\Eav\\Api\\Data\\AttributeOptionInterfaceFactory', [], [], '', false);
     $this->dataObjectProcessor = $this->getMock('Magento\\Framework\\Reflection\\DataObjectProcessor', [], [], '', false);
     $this->dataObjectHelper = $this->getMock('Magento\\Framework\\Api\\DataObjectHelper', [], [], '', false);
     $this->localeDate = $this->getMock('Magento\\Framework\\Stdlib\\DateTime\\Timezone', [], [], '', false);
     $this->localeDate->expects($this->any())->method('getDateFormat')->will($this->returnValue('12-12-2012'));
     $this->reservedAttributeList = $this->getMock('Magento\\Catalog\\Model\\Product\\ReservedAttributeList', [], [], '', false);
     $this->localeResolver = $this->getMock('Magento\\Framework\\Locale\\Resolver', [], [], '', false);
     $this->resource = $this->getMock('Magento\\Catalog\\Model\\ResourceModel\\Product', [], [], '', false);
     $this->resourceCollection = $this->getMockForAbstractClass('Magento\\Framework\\Data\\Collection\\AbstractDb', [], '', false);
     $this->context = $this->getMock('Magento\\Backend\\Block\\Template\\Context', ['getFileSystem', 'getEscaper', 'getLocaleDate', 'getLayout'], [], '', false);
     $filesystem = $this->getMock('Magento\\Framework\\Filesystem', [], [], '', false);
     $this->context->expects($this->any())->method('getFileSystem')->will($this->returnValue($filesystem));
     $escaper = $this->getMock('Magento\\Framework\\Escaper', ['escapeHtml'], [], '', false);
     $escaper->expects($this->any())->method('escapeHtml')->will($this->returnValue(''));
     $this->context->expects($this->any())->method('getEscaper')->will($this->returnValue($escaper));
     $timeZone = $this->getMock('Magento\\Framework\\Stdlib\\DateTime\\TimeZone', [], [], '', false);
     $timeZone->expects($this->any())->method('getDateFormat')->will($this->returnValue('M/d/yy'));
     $this->context->expects($this->any())->method('getLocaleDate')->will($this->returnValue($timeZone));
     $dateBlock = $this->getMock('Magento\\Framework\\View\\Element\\Html\\Date', ['setValue', 'getHtml', 'setId', 'getId'], [], '', false);
     $dateBlock->expects($this->any())->method('setValue')->will($this->returnSelf());
     $dateBlock->expects($this->any())->method('getHtml')->will($this->returnValue(''));
     $dateBlock->expects($this->any())->method('setId')->will($this->returnSelf());
     $dateBlock->expects($this->any())->method('getId')->will($this->returnValue(1));
     $layout = $this->getMock('Magento\\Framework\\View\\Layout', [], [], '', false);
     $layout->expects($this->any())->method('createBlock')->will($this->returnValue($dateBlock));
     $this->context->expects($this->any())->method('getLayout')->will($this->returnValue($layout));
     $this->backendHelper = $this->getMock('Magento\\Backend\\Helper\\Data', [], [], '', false);
     $this->importExportData = $this->getMock('Magento\\ImportExport\\Helper\\Data', [], [], '', false);
     $this->dateTimeFormatter = $this->getMock('Magento\\Framework\\Stdlib\\DateTime\\DateTimeFormatterInterface');
     $this->objectManagerHelper = new ObjectManagerHelper($this);
     $this->filter = $this->objectManagerHelper->getObject('Magento\\ImportExport\\Block\\Adminhtml\\Export\\Filter', ['context' => $this->context, 'backendHelper' => $this->backendHelper, 'importExportData' => $this->importExportData]);
 }
Esempio n. 8
0
 protected function generalGetProductCollection()
 {
     $this->eventManager->expects($this->once())->method('dispatch')->will($this->returnValue(true));
     $this->scopeConfig->expects($this->once())->method('getValue')->withAnyParameters()->willReturn(false);
     $this->cacheState->expects($this->atLeastOnce())->method('isEnabled')->withAnyParameters()->willReturn(false);
     $this->catalogConfig->expects($this->once())->method('getProductAttributes')->willReturn([]);
     $this->localDate->expects($this->any())->method('date')->willReturn(new \DateTime('now', new \DateTimeZone('UTC')));
     $this->context->expects($this->once())->method('getEventManager')->willReturn($this->eventManager);
     $this->context->expects($this->once())->method('getScopeConfig')->willReturn($this->scopeConfig);
     $this->context->expects($this->once())->method('getCacheState')->willReturn($this->cacheState);
     $this->context->expects($this->once())->method('getCatalogConfig')->willReturn($this->catalogConfig);
     $this->context->expects($this->once())->method('getLocaleDate')->willReturn($this->localDate);
     $this->productCollection = $this->getMockBuilder('Magento\\Catalog\\Model\\ResourceModel\\Product\\Collection')->setMethods(['setVisibility', 'addMinimalPrice', 'addFinalPrice', 'addTaxPercents', 'addAttributeToSelect', 'addUrlRewrite', 'addStoreFilter', 'addAttributeToSort', 'setPageSize', 'setCurPage', 'addAttributeToFilter'])->disableOriginalConstructor()->getMock();
     $this->productCollection->expects($this->once())->method('setVisibility')->willReturnSelf();
     $this->productCollection->expects($this->once())->method('addMinimalPrice')->willReturnSelf();
     $this->productCollection->expects($this->once())->method('addFinalPrice')->willReturnSelf();
     $this->productCollection->expects($this->once())->method('addTaxPercents')->willReturnSelf();
     $this->productCollection->expects($this->once())->method('addAttributeToSelect')->willReturnSelf();
     $this->productCollection->expects($this->once())->method('addUrlRewrite')->willReturnSelf();
     $this->productCollection->expects($this->once())->method('addStoreFilter')->willReturnSelf();
     $this->productCollection->expects($this->once())->method('addAttributeToSort')->willReturnSelf();
     $this->productCollection->expects($this->atLeastOnce())->method('setCurPage')->willReturnSelf();
     $this->productCollection->expects($this->any())->method('addAttributeToFilter')->willReturnSelf();
 }