Skip to content
This repository has been archived by the owner on Apr 5, 2021. It is now read-only.

Commit

Permalink
Improve tests
Browse files Browse the repository at this point in the history
  • Loading branch information
tillkruss committed Apr 22, 2016
1 parent d2f2f91 commit dbaf3b6
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 6 deletions.
11 changes: 5 additions & 6 deletions tests/Middleware/LoggerMiddlewareTest.php
Expand Up @@ -134,13 +134,12 @@ public function testErrorLogLevelCanBeCustomized()
$this->logger->shouldReceive('log')->with('info', 'received');
$this->logger->shouldReceive('log')->with('emergency', 'failed');

$next = function () use (&$executed) {
throw new Exception('Command Failed');
};

$this->setExpectedException(Exception::class, 'Command Failed');

$this->middleware->execute(
new TestCommand,
function () {
throw new Exception('Command Failed');
}
);
$this->middleware->execute(new TestCommand, $next);
}
}
16 changes: 16 additions & 0 deletions tests/Middleware/TransactionMiddlewareTest.php
Expand Up @@ -66,4 +66,20 @@ public function testCommandFailsWithErrorAndTransactionIsRolledBack()

$this->middleware->execute(new TestCommand, $next);
}

public function testNextCallableIsInvoked()
{
$this->database->shouldIgnoreMissing();

$sentCommand = new TestCommand;
$receivedSameCommand = false;

$next = function ($receivedCommand) use (&$receivedSameCommand, $sentCommand) {
$receivedSameCommand = ($receivedCommand === $sentCommand);
};

$this->middleware->execute($sentCommand, $next);

$this->assertTrue($receivedSameCommand);
}
}

0 comments on commit dbaf3b6

Please sign in to comment.