This library extends PHPUnit with asserting from Monolog logging entries.
Install the latest version with
composer require phoenixrvd/phpunit-assert-log-entry
<?php
use PHPUnit\Framework\TestCase;
class LogAssertionsTest extends TestCase
{
use \PhoenixRVD\PHPUnitLogAssertions\LogAssertions;
public function testFoo(){
// Get a Monolog instance
$logger = new \Monolog\Logger(__CLASS__);
// Register a logger in test case handler
self::attachLogger($logger);
$logger->debug('foo');
self::assertLogHasDebugRecords();
self::assertLogHasDebug('foo');
}
}
composer phpunit_log_assertions:test
Code released under the MIT License.