當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。