当前位置: 首页>>代码示例>>PHP>>正文


PHP DateTime::expects方法代码示例

本文整理汇总了PHP中Magento\Framework\Stdlib\DateTime::expects方法的典型用法代码示例。如果您正苦于以下问题:PHP DateTime::expects方法的具体用法?PHP DateTime::expects怎么用?PHP DateTime::expects使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Magento\Framework\Stdlib\DateTime的用法示例。


在下文中一共展示了DateTime::expects方法的11个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: testBeforeSave

 public function testBeforeSave()
 {
     $this->pageMock->expects($this->any())->method('getData')->willReturnMap([['identifier', null, 'test'], ['custom_theme_from', null, null], ['custom_theme_to', null, '10/02/2016']]);
     $this->dateTimeMock->expects($this->once())->method('formatDate')->with('10/02/2016')->willReturn('10 Feb 2016');
     $this->pageMock->expects($this->any())->method('setData')->withConsecutive(['custom_theme_from', null], ['custom_theme_to', '10 Feb 2016']);
     $this->model->beforeSave($this->pageMock);
 }
开发者ID:Doability,项目名称:magento2dev,代码行数:7,代码来源:PageTest.php

示例2: testReportOrderPlaced

 /**
  * Test case when module is enabled in config
  *
  * @return void
  */
 public function testReportOrderPlaced()
 {
     $testCustomerId = 1;
     $testTotal = '1.00';
     $testBaseTotal = '1.00';
     $testItemCount = null;
     $testTotalQtyOrderedCount = 1;
     $testUpdated = '1970-01-01 00:00:00';
     /** @var \Magento\Framework\Event\Observer|\PHPUnit_Framework_MockObject_MockObject $eventObserver */
     $eventObserver = $this->getMockBuilder('Magento\\Framework\\Event\\Observer')->disableOriginalConstructor()->getMock();
     $this->config->expects($this->once())->method('isNewRelicEnabled')->willReturn(true);
     $this->dateTime->expects($this->once())->method('formatDate')->willReturn($testUpdated);
     $event = $this->getMockBuilder('Magento\\Framework\\Event')->setMethods(['getOrder'])->disableOriginalConstructor()->getMock();
     $eventObserver->expects($this->once())->method('getEvent')->willReturn($event);
     $order = $this->getMockBuilder('Magento\\Sales\\Model\\Order')->disableOriginalConstructor()->getMock();
     $event->expects($this->once())->method('getOrder')->willReturn($order);
     $order->expects($this->once())->method('getCustomerId')->willReturn($testCustomerId);
     $order->expects($this->once())->method('getGrandTotal')->willReturn($testTotal);
     $order->expects($this->once())->method('getBaseGrandTotal')->willReturn($testBaseTotal);
     $order->expects($this->once())->method('getTotalItemCount')->willReturn($testItemCount);
     $order->expects($this->once())->method('getTotalQtyOrdered')->willReturn($testTotalQtyOrderedCount);
     $this->ordersModel->expects($this->once())->method('setData')->with(['customer_id' => $testCustomerId, 'total' => $testTotal, 'total_base' => $testBaseTotal, 'item_count' => $testTotalQtyOrderedCount, 'updated_at' => $testUpdated])->willReturnSelf();
     $this->ordersModel->expects($this->once())->method('save');
     $this->model->execute($eventObserver);
 }
开发者ID:whoople,项目名称:magento2-testing,代码行数:30,代码来源:ReportOrderPlacedTest.php

示例3: testBeforeSave

 public function testBeforeSave()
 {
     $timeStamp = '0000';
     $this->dateTimeMock->expects($this->exactly(2))->method('formatDate')->will($this->returnValue($timeStamp));
     $this->integrationModel->beforeSave();
     $this->assertEquals($timeStamp, $this->integrationModel->getCreatedAt());
     $this->assertEquals($timeStamp, $this->integrationModel->getUpdatedAt());
 }
开发者ID:nja78,项目名称:magento2,代码行数:8,代码来源:IntegrationTest.php

示例4: setUp

 /**
  * Setup
  *
  * @return void
  */
 public function setUp()
 {
     $this->config = $this->getMockBuilder('Magento\\NewRelicReporting\\Model\\Config')->disableOriginalConstructor()->setMethods(['isNewRelicEnabled'])->getMock();
     $this->collect = $this->getMockBuilder('Magento\\NewRelicReporting\\Model\\Module\\Collect')->disableOriginalConstructor()->setMethods(['getModuleData'])->getMock();
     $this->systemFactory = $this->getMockBuilder('Magento\\NewRelicReporting\\Model\\SystemFactory')->disableOriginalConstructor()->setMethods(['create'])->getMock();
     $this->systemModel = $this->getMockBuilder('Magento\\NewRelicReporting\\Model\\System')->disableOriginalConstructor()->getMock();
     $this->jsonEncoder = $this->getMockBuilder('Magento\\Framework\\Json\\EncoderInterface')->getMock();
     $this->dateTime = $this->getMockBuilder('Magento\\Framework\\Stdlib\\DateTime')->disableOriginalConstructor()->setMethods(['formatDate'])->getMock();
     $this->systemFactory->expects($this->any())->method('create')->willReturn($this->systemModel);
     $this->jsonEncoder->expects($this->any())->method('encode')->willReturn('json_string');
     $this->dateTime->expects($this->any())->method('formatDate')->willReturn('1970-01-01 00:00:00');
     $this->model = new ReportModulesInfo($this->config, $this->collect, $this->systemFactory, $this->jsonEncoder, $this->dateTime);
 }
开发者ID:whoople,项目名称:magento2-testing,代码行数:18,代码来源:ReportModulesInfoTest.php

示例5: setUp

 protected function setUp()
 {
     $this->objectManager = new ObjectManagerHelper($this);
     $this->backendConfigMock = $this->getMockBuilder(ConfigInterface::class)->disableOriginalConstructor()->setMethods(['getValue'])->getMockForAbstractClass();
     $this->customerRegistryMock = $this->getMock(CustomerRegistry::class, ['retrieveSecureData', 'retrieve'], [], '', false);
     $this->customerRepositoryMock = $this->getMockBuilder(CustomerRepositoryInterface::class)->disableOriginalConstructor()->getMock();
     $this->encryptorMock = $this->getMockBuilder(\Magento\Framework\Encryption\EncryptorInterface::class)->disableOriginalConstructor()->getMock();
     $this->dateTimeMock = $this->getMockBuilder(DateTime::class)->disableOriginalConstructor()->getMock();
     $this->dateTimeMock->expects($this->any())->method('formatDate')->willReturn('formattedDate');
     $this->customerSecureMock = $this->getMock(CustomerSecure::class, ['getId', 'getPasswordHash', 'isCustomerLocked', 'getFailuresNum', 'getFirstFailure', 'getLockExpires', 'setFirstFailure', 'setFailuresNum', 'setLockExpires'], [], '', false);
     $this->customerAuthUpdate = $this->getMockBuilder(\Magento\Customer\Model\CustomerAuthUpdate::class)->disableOriginalConstructor()->getMock();
     $this->authentication = $this->objectManager->getObject(Authentication::class, ['customerRegistry' => $this->customerRegistryMock, 'backendConfig' => $this->backendConfigMock, 'customerRepository' => $this->customerRepositoryMock, 'encryptor' => $this->encryptorMock, 'dateTime' => $this->dateTimeMock]);
     $this->objectManager->setBackwardCompatibleProperty($this->authentication, 'customerAuthUpdate', $this->customerAuthUpdate);
 }
开发者ID:Doability,项目名称:magento2dev,代码行数:14,代码来源:AuthenticationTest.php

示例6: testReportSystemCacheFlush

 /**
  * Test case when module is enabled in config
  *
  * @return void
  */
 public function testReportSystemCacheFlush()
 {
     $testType = 'systemCacheFlush';
     $testAction = 'JSON string';
     $testUpdated = '1970-01-01 00:00:00';
     /** @var \Magento\Framework\Event\Observer|\PHPUnit_Framework_MockObject_MockObject $eventObserver */
     $eventObserver = $this->getMockBuilder('Magento\\Framework\\Event\\Observer')->disableOriginalConstructor()->getMock();
     $this->config->expects($this->once())->method('isNewRelicEnabled')->willReturn(true);
     $this->dateTime->expects($this->once())->method('formatDate')->willReturn($testUpdated);
     $this->jsonEncoder->expects($this->once())->method('encode')->willReturn($testAction);
     $this->systemModel->expects($this->once())->method('setData')->with(['type' => $testType, 'action' => $testAction, 'updated_at' => $testUpdated])->willReturnSelf();
     $this->systemModel->expects($this->once())->method('save');
     $this->model->execute($eventObserver);
 }
开发者ID:whoople,项目名称:magento2-testing,代码行数:19,代码来源:ReportSystemCacheFlushTest.php

示例7: testLoadChangeFromCache

 /**
  * @test
  * @return void
  * @covers \Magento\Theme\Model\Design::loadChange
  * @covers \Magento\Theme\Model\Design::__construct
  * @covers \Magento\Theme\Model\Design::_construct
  */
 public function testLoadChangeFromCache()
 {
     $storeId = 1;
     $localDate = '2\\28\\2000';
     $date = '28-02-2000';
     $cacheId = 'design_change_' . md5($storeId . $date);
     $this->localeDate->expects($this->once())->method('scopeTimeStamp')->with($storeId)->willReturn($localDate);
     $this->dateTime->expects($this->once())->method('formatDate')->with($localDate, false)->willReturn($date);
     $this->cacheManager->expects($this->once())->method('load')->with($cacheId)->willReturn(serialize(['test' => 'data']));
     $this->assertInstanceOf(get_class($this->model), $this->model->loadChange($storeId));
 }
开发者ID:pradeep-wagento,项目名称:magento2,代码行数:18,代码来源:DesignTest.php

示例8: testGetData

 public function testGetData()
 {
     $this->dateTime->expects($this->once())->method('formatDate')->will($this->returnValue(date('Y-m-d H:i:s')));
     $this->rssUrlBuilderInterface->expects($this->once())->method('getUrl')->with(['_secure' => true, '_nosecret' => true, 'type' => 'new_order'])->will($this->returnValue('http://magento.com/backend/rss/feed/index/type/new_order'));
     $this->timezoneInterface->expects($this->once())->method('formatDate')->will($this->returnValue('2014-09-10 17:39:50'));
     $order = $this->getMockBuilder('Magento\\Sales\\Model\\Order')->setMethods(['__sleep', '__wakeup', 'getResourceCollection', 'getIncrementId', 'getId', 'getCreatedAt'])->disableOriginalConstructor()->getMock();
     $order->expects($this->once())->method('getId')->will($this->returnValue(1));
     $order->expects($this->once())->method('getIncrementId')->will($this->returnValue('100000001'));
     $order->expects($this->once())->method('getCreatedAt')->will($this->returnValue(time()));
     $collection = $this->getMockBuilder('\\Magento\\Sales\\Model\\ResourceModel\\Order\\Collection')->setMethods(['addAttributeToFilter', 'addAttributeToSort', 'getIterator'])->disableOriginalConstructor()->getMock();
     $collection->expects($this->once())->method('addAttributeToFilter')->will($this->returnSelf());
     $collection->expects($this->once())->method('addAttributeToSort')->will($this->returnSelf());
     $collection->expects($this->once())->method('getIterator')->will($this->returnValue(new \ArrayIterator([$order])));
     $order->expects($this->once())->method('getResourceCollection')->will($this->returnValue($collection));
     $this->orderFactory->expects($this->once())->method('create')->will($this->returnValue($order));
     $this->eventManager->expects($this->once())->method('dispatch')->will($this->returnSelf());
     $block = $this->getMock('Magento\\Sales\\Block\\Adminhtml\\Order\\Details', ['setOrder', 'toHtml'], [], '', false);
     $block->expects($this->once())->method('setOrder')->with($order)->will($this->returnSelf());
     $block->expects($this->once())->method('toHtml')->will($this->returnValue('Order Description'));
     $this->layout->expects($this->once())->method('getBlockSingleton')->will($this->returnValue($block));
     $this->urlBuiler->expects($this->once())->method('getUrl')->will($this->returnValue('http://magento.com/sales/order/view/order_id/1'));
     $this->assertEquals($this->feedData, $this->model->getRssData());
 }
开发者ID:kidaa30,项目名称:magento2-platformsh,代码行数:23,代码来源:NewOrderTest.php

示例9: testReportConcurrentAdmins

 /**
  * Test case when module is enabled and user is logged in 
  *
  * @return void
  */
 public function testReportConcurrentAdmins()
 {
     $testAction = 'JSON string';
     $testUpdated = '1970-01-01 00:00:00';
     /** @var \Magento\Framework\Event\Observer|\PHPUnit_Framework_MockObject_MockObject $eventObserver */
     $eventObserver = $this->getMockBuilder('Magento\\Framework\\Event\\Observer')->disableOriginalConstructor()->getMock();
     $this->config->expects($this->once())->method('isNewRelicEnabled')->willReturn(true);
     $this->backendAuthSession->expects($this->once())->method('isLoggedIn')->willReturn(true);
     $userMock = $this->getMockBuilder('Magento\\User\\Model\\User')->disableOriginalConstructor()->getMock();
     $this->backendAuthSession->expects($this->once())->method('getUser')->willReturn($userMock);
     $this->jsonEncoder->expects($this->once())->method('encode')->willReturn($testAction);
     $this->dateTime->expects($this->once())->method('formatDate')->willReturn($testUpdated);
     $this->usersModel->expects($this->once())->method('setData')->with(['type' => 'admin_activity', 'action' => $testAction, 'updated_at' => $testUpdated])->willReturnSelf();
     $this->usersModel->expects($this->once())->method('save');
     $this->model->execute($eventObserver);
 }
开发者ID:whoople,项目名称:magento2-testing,代码行数:21,代码来源:ReportConcurrentAdminsTest.php

示例10: testReportProductUpdated

 /**
  * Test case when module is enabled in config and product updated
  *
  * @return void
  */
 public function testReportProductUpdated()
 {
     $testType = 'adminProductChange';
     $testAction = 'JSON string';
     $testUpdated = '1970-01-01 00:00:00';
     /** @var \Magento\Framework\Event\Observer|\PHPUnit_Framework_MockObject_MockObject $eventObserver */
     $eventObserver = $this->getMockBuilder('Magento\\Framework\\Event\\Observer')->disableOriginalConstructor()->getMock();
     $this->config->expects($this->once())->method('isNewRelicEnabled')->willReturn(true);
     $event = $this->getMockBuilder('Magento\\Framework\\Event')->setMethods(['getProduct'])->disableOriginalConstructor()->getMock();
     $eventObserver->expects($this->once())->method('getEvent')->willReturn($event);
     /** @var \Magento\Catalog\Model\Product|\PHPUnit_Framework_MockObject_MockObject $product */
     $product = $this->getMockBuilder('Magento\\Catalog\\Model\\Product')->setMethods(['getId'])->disableOriginalConstructor()->getMock();
     $product->isObjectNew(false);
     $event->expects($this->once())->method('getProduct')->willReturn($product);
     $this->dateTime->expects($this->once())->method('formatDate')->willReturn($testUpdated);
     $this->jsonEncoder->expects($this->once())->method('encode')->willReturn($testAction);
     $this->systemModel->expects($this->once())->method('setData')->with(['type' => $testType, 'action' => $testAction, 'updated_at' => $testUpdated])->willReturnSelf();
     $this->systemModel->expects($this->once())->method('save');
     $this->model->execute($eventObserver);
 }
开发者ID:whoople,项目名称:magento2-testing,代码行数:25,代码来源:ReportProductSavedTest.php

示例11: testReportConcurrentUsers

 /**
  * Test case when module is enabled and user is logged in
  *
  * @return void
  */
 public function testReportConcurrentUsers()
 {
     $testCustomerId = 1;
     $testAction = 'JSON string';
     $testUpdated = '1970-01-01 00:00:00';
     /** @var \Magento\Framework\Event\Observer|\PHPUnit_Framework_MockObject_MockObject $eventObserver */
     $eventObserver = $this->getMockBuilder('Magento\\Framework\\Event\\Observer')->disableOriginalConstructor()->getMock();
     $this->config->expects($this->once())->method('isNewRelicEnabled')->willReturn(true);
     $this->customerSession->expects($this->once())->method('isLoggedIn')->willReturn(true);
     $this->customerSession->expects($this->once())->method('getCustomerId')->willReturn($testCustomerId);
     $customerMock = $this->getMockBuilder('Magento\\Customer\\Api\\Data\\CustomerInterface')->getMock();
     $this->customerRepository->expects($this->once())->method('getById')->willReturn($customerMock);
     $storeMock = $this->getMockBuilder('Magento\\Store\\Model\\Store')->disableOriginalConstructor()->getMock();
     $this->storeManager->expects($this->once())->method('getStore')->willReturn($storeMock);
     $websiteMock = $this->getMockBuilder('Magento\\Store\\Model\\Website')->disableOriginalConstructor()->getMock();
     $this->storeManager->expects($this->once())->method('getWebsite')->willReturn($websiteMock);
     $this->jsonEncoder->expects($this->once())->method('encode')->willReturn($testAction);
     $this->dateTime->expects($this->once())->method('formatDate')->willReturn($testUpdated);
     $this->usersModel->expects($this->once())->method('setData')->with(['type' => 'user_action', 'action' => $testAction, 'updated_at' => $testUpdated])->willReturnSelf();
     $this->usersModel->expects($this->once())->method('save');
     $this->model->execute($eventObserver);
 }
开发者ID:whoople,项目名称:magento2-testing,代码行数:27,代码来源:ReportConcurrentUsersTest.php


注:本文中的Magento\Framework\Stdlib\DateTime::expects方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。