/**
  * @test
  */
 public function it_should_log_the_query_if_logger_has_been_set()
 {
     $logger = new Psr3SqlLogger($this->logger, LogLevel::INFO);
     $this->logger->shouldReceive('log')->with(LogLevel::INFO, 'Execute SQL', ['query' => '', 'params' => [], 'types' => null])->once();
     $logger->startQuery('', [], null);
     $logger->stopQuery();
 }
 /**
  *
  */
 protected function setUp()
 {
     $this->logger = \Mockery::mock('\\Psr\\Log\\LoggerInterface');
     $this->logger->shouldReceive('log')->withAnyArgs();
     // helper function
     $this->futureFunc = function (array $response) {
         return function (array $request) use($response) {
             return new CompletedFutureArray($response);
         };
     };
     // basic response
     $this->response = ['status' => 200, 'effective_url' => 'http://localhost', 'transfer_stats' => ['total_time' => 0]];
 }
Example #3
0
 /**
  * @test
  */
 public function testHandleWithParsingErrorWithoutMessage()
 {
     $userId = $this->getApplicationUserId(42);
     $userName = '******';
     $user = \Mockery::mock(ParsingUser::class, function ($user) use($userId, $userName) {
         $user->shouldReceive('getId')->andReturn($userId);
         $user->shouldReceive('getName')->andReturn($userName);
         $user->shouldReceive('getAccount')->andReturn(\Mockery::mock(Account::class));
     });
     $message = new \stdClass();
     $exception = \Mockery::mock('\\MessageApp\\Parser\\Exception\\MessageParserException');
     $exception->shouldReceive('getUser')->andReturn($user);
     $parser = \Mockery::mock('\\MessageApp\\Parser\\MessageParser');
     $parser->shouldReceive('parse')->andThrow($exception);
     $this->logger->shouldReceive('info')->twice();
     $this->logger->shouldReceive('error')->once();
     $this->logger->shouldReceive('warning')->once();
     $this->messageSender->shouldReceive('send')->never();
     $this->factory->shouldReceive('buildMessage')->with(\Mockery::on(function ($users) {
         $this->assertCount(1, $users);
         $this->assertInstanceOf(UndefinedApplicationUser::class, $users[0]);
         return true;
     }), $exception)->andReturn(null);
     $hangmanApp = new MessageApplication($this->messageSender, $parser, $this->factory, $this->getCommandBus());
     $hangmanApp->setLogger($this->logger);
     $hangmanApp->handle($message);
 }
 /**
  * @expectedException \League\Tactician\Logger\Tests\Fixtures\UserAlreadyExistsException
  */
 public function testErrorLogLevelCanBeCustomized()
 {
     $middleware = new LoggerMiddleware($this->formatter, $this->logger, LogLevel::DEBUG, LogLevel::DEBUG, LogLevel::CRITICAL);
     $this->formatter->shouldReceive('commandReceived')->andReturn('received');
     $this->formatter->shouldReceive('commandFailed')->andReturn('failed');
     $this->logger->shouldReceive('log')->with(LogLevel::DEBUG, 'received');
     $this->logger->shouldReceive('log')->with(LogLevel::CRITICAL, 'failed');
     $middleware->execute(new RegisterUserCommand(), function () {
         throw new UserAlreadyExistsException();
     });
 }
 private function mockFinishApiCall()
 {
     $this->apiTimeCalculator->shouldReceive('calculateEarliestNextCall')->with($this->apiCall)->andReturn(self::EARLIEST_NEXT_CALL);
     $this->apiCall->shouldReceive('setEarliestNextCall')->with(self::EARLIEST_NEXT_CALL);
     $this->logger->shouldReceive('info');
 }