phpunit-assert-log-entry

This library extends PHPUnit with asserting from Monolog logging entries.

MIT License

Downloads
211
Stars
2
Committers
1

PHPUnit assert log entry

This library extends PHPUnit with asserting from Monolog logging entries.

Installation

Install the latest version with

composer require phoenixrvd/phpunit-assert-log-entry

Example

<?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');
    }
    
}

Testing

composer phpunit_log_assertions:test

Copyright and license

Code released under the MIT License.