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


PHP DateTime::expects方法代码示例

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


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

示例1: testFilterByLifetime

 /**
  * @return void
  */
 public function testFilterByLifetime()
 {
     $lifetime = 600;
     $timestamp = time();
     $this->dateTimeMock->expects($this->once())->method('gmtTimestamp')->willReturn($timestamp);
     $this->collectionMock->expects($this->once())->method('addFieldToFilter')->with('created_at', ['gt' => $this->collectionMock->getConnection()->formatDate($timestamp - $lifetime)])->willReturnSelf();
     $this->assertEquals($this->collectionMock, $this->collectionMock->filterByLifetime($lifetime));
 }
开发者ID:Doability,项目名称:magento2dev,代码行数:11,代码来源:CollectionTest.php

示例2: testFilterExpiredSessions

 /**
  * @return void
  */
 public function testFilterExpiredSessions()
 {
     $sessionLifeTime = '600';
     $timestamp = time();
     $this->dateTimeMock->expects($this->once())->method('gmtTimestamp')->willReturn($timestamp);
     $this->collectionMock->expects($this->once())->method('addFieldToFilter')->with('updated_at', ['gt' => $this->collectionMock->getConnection()->formatDate($timestamp - $sessionLifeTime)])->willReturnSelf();
     $this->assertEquals($this->collectionMock, $this->collectionMock->filterExpiredSessions($sessionLifeTime));
 }
开发者ID:Doability,项目名称:magento2dev,代码行数:11,代码来源:CollectionTest.php

示例3: testSessionExpired

 /**
  * @param bool $expectedResult
  * @param string $sessionLifetime
  * @dataProvider dataProviderSessionLifetime
  */
 public function testSessionExpired($expectedResult, $sessionLifetime)
 {
     $timestamp = time();
     $this->securityConfigMock->expects($this->once())->method('getAdminSessionLifetime')->will($this->returnValue($sessionLifetime));
     $this->dateTimeMock->expects($this->once())->method('gmtTimestamp')->willReturn($timestamp);
     $this->model->setUpdatedAt(date("Y-m-d H:i:s", $timestamp - 1));
     $this->assertEquals($expectedResult, $this->model->isSessionExpired());
 }
开发者ID:rafaelstz,项目名称:magento2,代码行数:13,代码来源:AdminSessionInfoTest.php

示例4: testSendPerSubscriberZeroSize

 public function testSendPerSubscriberZeroSize()
 {
     $this->queue->setQueueStatus(1);
     $this->queue->setQueueStartAt(1);
     $this->subscribersCollection->expects($this->once())->method('getQueueJoinedFlag')->willReturn(false);
     $this->subscribersCollection->expects($this->once())->method('useQueue')->with($this->queue)->willReturnSelf();
     $this->subscribersCollection->expects($this->once())->method('getSize')->willReturn(0);
     $this->date->expects($this->once())->method('gmtDate')->willReturn('any_date');
     $this->assertEquals($this->queue, $this->queue->sendPerSubscriber());
 }
开发者ID:Doability,项目名称:magento2dev,代码行数:10,代码来源:QueueTest.php

示例5: testGenerate

 public function testGenerate()
 {
     $orderId = '1';
     $orderIncrementId = '0000000001';
     $timestamp = 12345678;
     $try = 2;
     $order = $this->getOrderMock($orderId, $orderIncrementId);
     $this->transactionResource->expects($this->once())->method('getLastTryByOrderId')->with($this->equalTo($orderId))->willReturn($try);
     $this->dateTime->expects($this->once())->method('timestamp')->willReturn($timestamp);
     $this->assertEquals($orderIncrementId . ':' . $timestamp . ':' . ($try + 1), $this->model->generate($order));
 }
开发者ID:tozwierz,项目名称:magento2_payupl,代码行数:11,代码来源:ExtOrderIdTest.php

示例6: testSave

 public function testSave()
 {
     $productId = 1;
     $this->stockItemMock->expects($this->any())->method('getProductId')->willReturn($productId);
     $this->productMock->expects($this->once())->method('load')->with($productId)->willReturnSelf();
     $this->productMock->expects($this->once())->method('getId')->willReturn($productId);
     $this->productMock->expects($this->once())->method('getTypeId')->willReturn('typeId');
     $this->stockConfigurationMock->expects($this->once())->method('isQty')->with('typeId')->willReturn(true);
     $this->stockStateProviderMock->expects($this->once())->method('verifyStock')->with($this->stockItemMock)->willReturn(false);
     $this->stockItemMock->expects($this->once())->method('getManageStock')->willReturn(true);
     $this->stockItemMock->expects($this->once())->method('setIsInStock')->with(false)->willReturnSelf();
     $this->stockItemMock->expects($this->once())->method('setStockStatusChangedAutomaticallyFlag')->with(true)->willReturnSelf();
     $this->stockItemMock->expects($this->any())->method('setLowStockDate')->willReturnSelf();
     $this->stockStateProviderMock->expects($this->once())->method('verifyNotification')->with($this->stockItemMock)->willReturn(true);
     $this->dateTime->expects($this->once())->method('gmtDate');
     $this->stockItemMock->expects($this->atLeastOnce())->method('setStockStatusChangedAuto')->willReturnSelf();
     $this->stockItemMock->expects($this->once())->method('hasStockStatusChangedAutomaticallyFlag')->willReturn(true);
     $this->stockItemMock->expects($this->once())->method('getStockStatusChangedAutomaticallyFlag')->willReturn(true);
     $this->stockItemMock->expects($this->once())->method('getWebsiteId')->willReturn(1);
     $this->stockItemMock->expects($this->once())->method('setWebsiteId')->with(1)->willReturnSelf();
     $this->stockItemMock->expects($this->once())->method('getStockId')->willReturn(1);
     $this->stockItemMock->expects($this->once())->method('setStockId')->with(1)->willReturnSelf();
     $this->stockItemResourceMock->expects($this->once())->method('save')->with($this->stockItemMock)->willReturnSelf();
     $this->indexProcessorMock->expects($this->once())->method('reindexRow')->with($productId);
     $this->assertEquals($this->stockItemMock, $this->model->save($this->stockItemMock));
 }
开发者ID:pradeep-wagento,项目名称:magento2,代码行数:26,代码来源:StockItemRepositoryTest.php

示例7: testCleanExpiredSessions

 /**
  * @return void
  */
 public function testCleanExpiredSessions()
 {
     $timestamp = time();
     $this->adminSessionInfoCollectionFactoryMock->expects($this->once())->method('create')->willReturn($this->adminSessionInfoCollectionMock);
     $this->dateTimeMock->expects($this->once())->method('gmtTimestamp')->willReturn($timestamp);
     $this->adminSessionInfoCollectionMock->expects($this->once())->method('deleteSessionsOlderThen')->with($timestamp - AdminSessionsManager::ADMIN_SESSION_LIFETIME)->willReturnSelf();
     $this->model->cleanExpiredSessions();
 }
开发者ID:Doability,项目名称:magento2dev,代码行数:11,代码来源:AdminSessionsManagerTest.php

示例8: testCleanExpiredRecords

 /**
  * @return void
  */
 public function testCleanExpiredRecords()
 {
     $timestamp = time();
     $this->passwordResetRequestEventCollectionFactoryMock->expects($this->once())->method('create')->willReturn($this->passwordResetRequestEventCollectionMock);
     $this->dateTimeMock->expects($this->once())->method('gmtTimestamp')->willReturn($timestamp);
     $this->passwordResetRequestEventCollectionMock->expects($this->once())->method('deleteRecordsOlderThen')->with($timestamp - \Magento\Security\Model\SecurityManager::SECURITY_CONTROL_RECORDS_LIFE_TIME)->willReturnSelf();
     $this->model->cleanExpiredRecords();
 }
开发者ID:Doability,项目名称:magento2dev,代码行数:11,代码来源:SecurityManagerTest.php

示例9: testCheckException

 /**
  * @param int $securityEventType
  * @param int $requestsMethod
  * @dataProvider dataProviderSecurityEventTypeWithRequestsMethod
  * @expectedException \Magento\Framework\Exception\SecurityViolationException
  * @expectedExceptionMessage Too many password reset requests. Please wait and try again or contact test@host.com.
  */
 public function testCheckException($securityEventType, $requestsMethod)
 {
     $limitTimeBetweenPasswordResetRequests = 600;
     $timestamp = time();
     $this->prepareTestCheck($requestsMethod, $limitTimeBetweenPasswordResetRequests);
     $this->dateTimeMock->expects($this->once())->method('gmtTimestamp')->willReturn($timestamp);
     /** @var \Magento\Security\Model\PasswordResetRequestEvent $record */
     $record = $this->objectManager->getObject('\\Magento\\Security\\Model\\PasswordResetRequestEvent');
     $record->setCreatedAt(date("Y-m-d H:i:s", $timestamp - $limitTimeBetweenPasswordResetRequests + 1));
     $this->collectionMock->expects($this->once())->method('getFirstItem')->willReturn($record);
     $this->model->check($securityEventType);
 }
开发者ID:Doability,项目名称:magento2dev,代码行数:19,代码来源:FrequencyTest.php

示例10: testExecute

    /**
     * @covers \Magento\Sales\Controller\Adminhtml\Order\Creditmemo\PrintAction::executeInternal
     */
    public function testExecute()
    {
        $creditmemoId = 2;
        $date = '2015-01-19_13-03-45';
        $fileName = 'creditmemo2015-01-19_13-03-45.pdf';
        $fileContents = 'pdf0123456789';
        $this->prepareTestExecute($creditmemoId);

        $this->objectManagerMock->expects($this->any())
            ->method('create')
            ->willReturnMap(
                [
                    ['Magento\Sales\Model\Order\Creditmemo', [], $this->creditmemoMock],
                    ['Magento\Sales\Model\Order\Pdf\Creditmemo', [], $this->creditmemoPdfMock]
                ]
            );
        $this->creditmemoRepositoryMock->expects($this->once())
            ->method('get')
            ->with($creditmemoId)
            ->willReturn($this->creditmemoMock);
        $this->creditmemoPdfMock->expects($this->once())
            ->method('getPdf')
            ->with([$this->creditmemoMock])
            ->willReturn($this->pdfMock);
        $this->objectManagerMock->expects($this->once())
            ->method('get')
            ->with('Magento\Framework\Stdlib\DateTime\DateTime')
            ->willReturn($this->dateTimeMock);
        $this->dateTimeMock->expects($this->once())
            ->method('date')
            ->with('Y-m-d_H-i-s')
            ->willReturn($date);
        $this->pdfMock->expects($this->once())
            ->method('render')
            ->willReturn($fileContents);
        $this->fileFactoryMock->expects($this->once())
            ->method('create')
            ->with(
                $fileName,
                $fileContents,
                \Magento\Framework\App\Filesystem\DirectoryList::VAR_DIR,
                'application/pdf'
            )
            ->willReturn($this->responseMock);

        $this->assertInstanceOf(
            'Magento\Framework\App\ResponseInterface',
            $this->printAction->executeInternal()
        );
    }
开发者ID:nblair,项目名称:magescotch,代码行数:53,代码来源:PrintActionTest.php

示例11: testCreateHistoryReportThrowException

 /**
  * Cover createHistoryReport().
  *
  * @expectedException \Magento\Framework\Exception\LocalizedException
  * @expectedExceptionMessage Source file coping failed
  */
 public function testCreateHistoryReportThrowException()
 {
     $sourceFileRelative = null;
     $entity = '';
     $extension = '';
     $result = '';
     $gmtTimestamp = 1234567;
     $this->import->expects($this->once())->method('isReportEntityType')->with($entity)->willReturn(true);
     $this->_varDirectory->expects($this->never())->method('getRelativePath');
     $phrase = $this->getMock('\\Magento\\Framework\\Phrase', [], [], '', false);
     $this->_driver->expects($this->any())->method('fileGetContents')->willReturnCallback(function () use($phrase) {
         throw new \Magento\Framework\Exception\FileSystemException($phrase);
     });
     $this->dateTime->expects($this->once())->method('gmtTimestamp')->willReturn($gmtTimestamp);
     $args = [$sourceFileRelative, $entity, $extension, $result];
     $actualResult = $this->invokeMethod($this->import, 'createHistoryReport', $args);
     $this->assertEquals($this->import, $actualResult);
 }
开发者ID:kidaa30,项目名称:magento2-platformsh,代码行数:24,代码来源:ImportTest.php

示例12: testGetYears

 public function testGetYears()
 {
     $this->date->expects($this->once())->method('date')->with('Y')->will($this->returnValue(self::CURRENT_YEAR));
     $this->assertEquals($this->_getPreparedYearsList(), $this->config->getYears());
 }
开发者ID:,项目名称:,代码行数:5,代码来源:

示例13: _makeValidExpirationPeriod

 protected function _makeValidExpirationPeriod()
 {
     $this->_dateMock->expects($this->any())->method('timestamp')->will($this->returnValue(0));
     $this->_dataHelperMock->expects($this->once())->method('getConsumerExpirationPeriod')->will($this->returnValue(300));
 }
开发者ID:Atlis,项目名称:docker-magento2,代码行数:5,代码来源:OauthTest.php


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