Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Fetching contributors…

Cannot retrieve contributors at this time

51 lines (43 sloc) 1.097 kB
<?php
require_once ('lib/Analog.php');
class AnalogTest extends PHPUnit_Framework_TestCase {
public static $log = '';
function test_default () {
@unlink (Analog::handler ());
// Check it wrote correctly to temp file
Analog::log ('Foo');
$this->assertStringMatchesFormat (
"localhost - %d-%d-%d %d:%d:%d - 3 - Foo\n",
file_get_contents (Analog::handler ())
);
unlink (Analog::handler ());
}
/**
* @depends test_default
*/
function test_format () {
// Test changing the format string and write again
Analog::$format = "%s, %s, %d, %s\n";
Analog::log ('Foo');
$this->assertStringMatchesFormat (
"localhost, %d-%d-%d %d:%d:%d, 3, Foo\n",
file_get_contents (Analog::handler ())
);
unlink (Analog::handler ());
}
/**
* @depends test_format
*/
function test_handler () {
// Test logging using a closure
Analog::handler (function ($msg) {
AnalogTest::$log .= vsprintf (Analog::$format, $msg);
});
Analog::log ('Testing');
$this->assertStringMatchesFormat (
"localhost, %d-%d-%d %d:%d:%d, 3, Testing\n",
self::$log
);
}
}
?>
Jump to Line
Something went wrong with that request. Please try again.