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


PHP Logger::expects方法代码示例

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


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

示例1: testIndexActionException

 public function testIndexActionException()
 {
     $this->request->expects($this->once())->method('isPost')->will($this->returnValue(true));
     $exception = new \Exception();
     $this->request->expects($this->once())->method('getPost')->will($this->throwException($exception));
     $this->logger->expects($this->once())->method('logException')->with($this->identicalTo($exception));
     $this->response->expects($this->once())->method('setHttpResponseCode')->with(500);
     $this->model->execute();
 }
开发者ID:,项目名称:,代码行数:9,代码来源:

示例2: testRenderMsrpNotRegisteredException

 public function testRenderMsrpNotRegisteredException()
 {
     $this->logger->expects($this->once())->method('logException');
     $this->priceInfo->expects($this->once())->method('getPrice')->with($this->equalTo('msrp_price'))->will($this->throwException(new \InvalidArgumentException()));
     $result = $this->object->toHtml();
     //assert price wrapper
     $this->assertStringStartsWith('<div', $result);
     //assert css_selector
     $this->assertRegExp('/[final_price]/', $result);
 }
开发者ID:,项目名称:,代码行数:10,代码来源:

示例3: testMinificationFailed

 public function testMinificationFailed()
 {
     $this->prepareAttemptToMinifyMock(false);
     $this->_asset->expects($this->once())->method('getContent')->will($this->returnValue('content'));
     $e = new \Exception('test');
     $this->_adapter->expects($this->once())->method('minify')->with('content')->will($this->throwException($e));
     $this->_logger->expects($this->once())->method('logException');
     $this->_staticViewDir->expects($this->never())->method('writeFile');
     $this->_asset->expects($this->once())->method('getFilePath')->will($this->returnValue('file_path'));
     $this->_asset->expects($this->once())->method('getContext')->will($this->returnValue('context'));
     $this->_asset->expects($this->once())->method('getUrl')->will($this->returnValue('url'));
     $this->assertEquals('test/library.js', $this->_model->getPath());
 }
开发者ID:,项目名称:,代码行数:13,代码来源:

示例4: testErrorHandlerLogging

 /**
  * Test for setting error handler and logging
  *
  * @covers \Magento\Framework\Error\Handler::handler
  * @throws \Exception
  */
 public function testErrorHandlerLogging()
 {
     $this->appState->expects($this->any())->method('getMode')->will($this->returnValue(\Magento\Framework\App\State::MODE_DEFAULT));
     $this->logger->expects($this->once())->method('log')->with($this->stringContains('testErrorHandlerLogging'), \Zend_Log::ERR);
     set_error_handler(array($this->handler, 'handler'));
     try {
         trigger_error('testErrorHandlerLogging', E_USER_NOTICE);
         restore_error_handler();
     } catch (\Exception $e) {
         restore_error_handler();
         throw $e;
     }
 }
开发者ID:,项目名称:,代码行数:19,代码来源:

示例5: testAddException

 public function testAddException()
 {
     $exceptionMessage = 'exception message';
     $alternativeText = 'alternative text';
     $logText = "Exception message: {$exceptionMessage}\nTrace:";
     $messageError = $this->getMockBuilder('Magento\\Framework\\Message\\Error')->setConstructorArgs(array('text' => $alternativeText))->getMock();
     $this->messageFactory->expects($this->atLeastOnce())->method('create')->with(MessageInterface::TYPE_ERROR, $alternativeText)->will($this->returnValue($messageError));
     $this->logger->expects($this->atLeastOnce())->method('logFile')->with($this->stringStartsWith($logText), \Zend_Log::DEBUG, \Magento\Framework\Logger::LOGGER_EXCEPTION);
     $messageCollection = $this->getMockBuilder('Magento\\Framework\\Message\\Collection')->disableOriginalConstructor()->setMethods(array('addMessage'))->getMock();
     $messageCollection->expects($this->atLeastOnce())->method('addMessage')->with($messageError);
     $this->session->expects($this->atLeastOnce())->method('getData')->with(ManagerInterface::DEFAULT_GROUP)->will($this->returnValue($messageCollection));
     $exception = new \Exception($exceptionMessage);
     $this->assertEquals($this->model, $this->model->addException($exception, $alternativeText));
 }
开发者ID:,项目名称:,代码行数:14,代码来源:

示例6: testPrintLogQueryLogging

 /**
  * @param bool $logQuery
  * @param bool $logFlag
  * @param int $expectedCalls
  *
  * @dataProvider printLogQueryLoggingDataProvider
  */
 public function testPrintLogQueryLogging($logQuery, $logFlag, $expectedCalls)
 {
     $this->collection->setFlag('log_query', $logFlag);
     $this->loggerMock->expects($this->exactly($expectedCalls))->method('log');
     $this->collection->printLogQuery(false, $logQuery, 'some_query');
 }
开发者ID:,项目名称:,代码行数:13,代码来源:

示例7: testSerialize

 public function testSerialize()
 {
     $this->assertNotEmpty($this->_model->serialize());
     $this->_logger->expects($this->once())->method('log');
     $this->_model->add($this->_items['item1']);
 }
开发者ID:,项目名称:,代码行数:6,代码来源:

示例8: testImportDirectoriesFailureWithoutParent

 /**
  * test import directories without parent
  */
 public function testImportDirectoriesFailureWithoutParent()
 {
     $this->directoryMock->expects($this->any())->method('getParentId')->will($this->returnValue(null));
     $this->loggerMock->expects($this->any())->method('logException');
     $this->directoryDatabase->importDirectories(array());
 }
开发者ID:,项目名称:,代码行数:9,代码来源:


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