本文整理汇总了PHP中Psr\Log\LoggerInterface::expects方法的典型用法代码示例。如果您正苦于以下问题:PHP LoggerInterface::expects方法的具体用法?PHP LoggerInterface::expects怎么用?PHP LoggerInterface::expects使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Psr\Log\LoggerInterface
的用法示例。
在下文中一共展示了LoggerInterface::expects方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: testAdd
public function testAdd()
{
$this->varReaderWriter->expects($this->once())->method('isExist')->willReturn(false);
$this->varReaderWriter->expects($this->once())->method('writeFile');
$this->logger->expects($this->once())->method('log')->with(\Psr\Log\LogLevel::ERROR, 'test1');
$this->status->add('test1', \Psr\Log\LogLevel::ERROR);
}
示例2: setUp
protected function setUp()
{
$this->logger = $this->getMock('Psr\\Log\\LoggerInterface', array('info', 'error'));
$this->logger->expects($this->any())->method('info');
$this->logger->expects($this->any())->method('error');
$this->adapter = new BraintreeSubscriptionAdapter($this->logger, 'sandbox', MERCHANTID, PUBLICKEY, PRIVATEKEY, 'Kairos\\SubscriptionBundle\\Tests\\TestEntities\\TransactionEntity');
}
示例3: testBeforeDispatchWithException
public function testBeforeDispatchWithException()
{
$exception = new LocalizedException(new Phrase('Phrase'));
$this->themeRegistration->expects($this->once())->method('register')->willThrowException($exception);
$this->logger->expects($this->once())->method('critical');
$this->plugin->beforeDispatch($this->abstractAction, $this->request);
}
示例4: testBeforeExecuteWithException
public function testBeforeExecuteWithException()
{
$exception = new LocalizedException(new Phrase('Phrase'));
$this->themeRegistration->expects($this->once())->method('register')->willThrowException($exception);
$this->logger->expects($this->once())->method('critical');
$object = new Registration($this->themeRegistration, $this->logger, $this->appState);
$object->beforeExecute($this->abstractAction, $this->request);
}
示例5: testUpdateDbWithException
public function testUpdateDbWithException()
{
$this->databaseConfig->expects($this->once())->method('isAutoUpdate')->willReturn(true);
$e = new \Exception();
$this->updaterSelected->expects($this->once())->method('update')->willThrowException($e);
$this->logger->expects($this->once())->method('critical')->with($e);
$this->assertSame($this->cronUpdateDb, $this->cronUpdateDb->execute());
}
示例6: testSendEmailWhenRedirectUrlExists
public function testSendEmailWhenRedirectUrlExists()
{
$this->paymentMock->expects($this->once())->method('getOrderPlaceRedirectUrl')->willReturn(false);
$this->orderMock->expects($this->once())->method('getCanSendNewEmailFlag');
$this->orderSenderMock->expects($this->never())->method('send');
$this->loggerMock->expects($this->never())->method('critical');
$this->model->execute($this->observerMock);
}
示例7: testCall
/**
* Make sure publish is logged.
*/
public function testCall()
{
$this->innerDriver->expects(self::once())->method('call')->willReturn(new Promise(function () {
return new Response('');
}));
$this->logger->expects(self::exactly(2))->method('debug');
$this->driver->call(new Identity(''), new Request(''))->resolve();
}
示例8: testServiceNotListening
public function testServiceNotListening()
{
$this->logger->expects($this->once())->method('info');
$this->logger->expects($this->once())->method('warning');
$this->connection->expects($this->any())->method('isServiceListening')->will($this->returnValue(false));
$listener = new PheanstalkLogListener();
$listener->setLogger($this->logger);
$listener->onCommand(new CommandEvent($this->pheanstalk, []), CommandEvent::PEEK_READY);
}
示例9: testIndexActionException
public function testIndexActionException()
{
$this->request->expects($this->once())->method('isPost')->will($this->returnValue(true));
$exception = new \Exception();
$this->request->expects($this->once())->method('getPostValue')->will($this->throwException($exception));
$this->logger->expects($this->once())->method('critical')->with($this->identicalTo($exception));
$this->response->expects($this->once())->method('setHttpResponseCode')->with(500);
$this->model->executeInternal();
}
示例10: testReorderChildElementLog
/**
* @param \PHPUnit_Framework_MockObject_Matcher_InvokedCount $loggerExpects
* @param string $stateMode
* @return void
* @dataProvider reorderChildElementLogDataProvider
*/
public function testReorderChildElementLog($loggerExpects, $stateMode)
{
$parentName = 'parent';
$childName = 'child';
$offsetOrSibling = '-';
$this->stateMock->expects($this->once())->method('getMode')->willReturn($stateMode);
$this->loggerMock->expects($loggerExpects)->method('critical')->with("Broken reference: the '{$childName}' tries to reorder itself towards '', but " . "their parents are different: '{$parentName}' and '' respectively.");
$this->dataStructure->reorderChildElement($parentName, $childName, $offsetOrSibling);
}
示例11: testApplyThemeCustomizationException
public function testApplyThemeCustomizationException()
{
$file = $this->getMock('Magento\\Theme\\Model\\Theme\\File', [], [], '', false);
$file->expects($this->any())->method('getCustomizationService')->willThrowException(new \InvalidArgumentException());
$this->themeCustomization->expects($this->once())->method('getFiles')->will($this->returnValue([$file]));
$this->logger->expects($this->once())->method('critical');
$observer = new \Magento\Framework\Event\Observer();
$this->themeObserver->execute($observer);
}
示例12: testExecuteQueryThrowsExceptionOnExecuteError
/**
* @expectedException \Assertis\SimpleDatabase\SimpleDatabaseExecuteException
*/
public function testExecuteQueryThrowsExceptionOnExecuteError()
{
$sql = "SQL";
$params = ['foo' => 'bar'];
$this->pdo->expects($this->once())->method('prepare')->with($sql)->willReturn($this->statement);
$this->statement->expects($this->once())->method('execute')->with($params)->willReturn(false);
$this->logger->expects($this->once())->method('error');
$db = new SimpleDatabase($this->pdo, $this->logger);
$db->executeQuery($sql, $params);
}
示例13: testDone
public function testDone()
{
$jobId = 12345;
$this->pheanstalkMock->expects($this->once())->method('delete')->with($this->callback(function (Job $job) use($jobId) {
return $job->getId() === $jobId;
}));
$this->pheanstalkMock->expects($this->any())->method('peek')->with($jobId)->willReturn(new Job($jobId, 'asdf'));
$this->loggerMock->expects($this->once())->method('info')->with('Done job (12345): asdf');
$this->sut->done($jobId);
}
示例14: testGetFilesEmpty
public function testGetFilesEmpty()
{
$this->libraryFilesMock->expects($this->any())->method('getFiles')->will($this->returnValue([]));
$this->baseFilesMock->expects($this->any())->method('getFiles')->will($this->returnValue([]));
$this->overriddenBaseFilesMock->expects($this->any())->method('getFiles')->will($this->returnValue([]));
$aggregated = new Aggregated($this->fileListFactoryMock, $this->libraryFilesMock, $this->baseFilesMock, $this->overriddenBaseFilesMock, $this->loggerMock);
$this->themeMock->expects($this->any())->method('getInheritedThemes')->will($this->returnValue([]));
$this->themeMock->expects($this->any())->method('getCode')->will($this->returnValue('theme_code'));
$this->loggerMock->expects($this->once())->method('notice')->with('magento_import returns empty result by path * for theme theme_code', []);
$aggregated->getFiles($this->themeMock, '*');
}
示例15: testExecuteWithException
public function testExecuteWithException()
{
$this->requestMock->expects($this->once())->method('getParam')->with('item_id', null)->willReturn('1');
$exception = new \Exception('Error message!');
$this->sidebarMock->expects($this->once())->method('checkQuoteItem')->with(1)->willThrowException($exception);
$this->loggerMock->expects($this->once())->method('critical')->with($exception)->willReturn(null);
$this->sidebarMock->expects($this->once())->method('getResponseData')->with('Error message!')->willReturn(['success' => false, 'error_message' => 'Error message!']);
$this->jsonHelperMock->expects($this->once())->method('jsonEncode')->with(['success' => false, 'error_message' => 'Error message!'])->willReturn('json encoded');
$this->responseMock->expects($this->once())->method('representJson')->with('json encoded')->willReturn('json represented');
$this->assertEquals('json represented', $this->removeItem->executeInternal());
}