Jyxo\Rpc\ServerTestCase::testLog PHP Method

testLog() public method

Tests logging.
public testLog ( )
    public function testLog()
    {
        // Skips this test if no temporary directory is defined
        if (empty($GLOBALS['tmp'])) {
            $this->markTestSkipped('Temp dir not set');
        }
        $logFile = $GLOBALS['tmp'] . '/rpc.log';
        require_once $this->getFilePath('TestMath.php');
        $this->rpc->registerMethod('TestMath', 'sum');
        $this->rpc->enableLogging($logFile, [__CLASS__, 'logCallback']);
        // Server output check
        $this->checkServerOutput('sum');
        // Log check - it is necessary to replace the dynamically generated date
        $log = preg_replace('~^\\[\\d{4}-\\d{2}-\\d{2} \\d{2}:\\d{2}:\\d{2}\\]~', '[2009-11-15 19:09:24]', file_get_contents($logFile));
        $this->assertStringEqualsFile($this->getFilePath('expected.log'), $log);
        // Log cleanup
        unlink($logFile);
    }