Skip to content
This repository has been archived by the owner on May 29, 2018. It is now read-only.

Commit

Permalink
Added new Logger class for testing.
Browse files Browse the repository at this point in the history
  • Loading branch information
bramp committed Feb 15, 2016
1 parent 143696b commit d864972
Showing 1 changed file with 19 additions and 2 deletions.
21 changes: 19 additions & 2 deletions tests/phpunit_base.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,23 @@ function stringToStream($str) {
}


/**
* Magic logger
* If you want to trace function calls just prefix them with L::. For example:
* $fp = L::fopen("somefile");
* L::fread($fp, 10);
* Will print out
* fopen("somefile") = Resource id #97
* fread(Resource id #97, 10) = "....."
*/
abstract class L {
public static function __callStatic($name, $arguments) {
echo "$name(" . implode(', ', $arguments). ") = ";
$ret = forward_static_call_array($name, $arguments);
echo print_r($ret, true) . "\n";
return $ret;
}
}

function print_bytes($bytes) {
$len = strlen($bytes);
Expand Down Expand Up @@ -82,8 +99,8 @@ public function evaluate($other, $description = '', $returnResult = false) {

throw new PHPUnit_Framework_ExpectationFailedException(
$description . "\n" .
"Expected: " . self::toHexString($this->value) . "\n" .
" Actual: " . self::toHexString($other)
"Expected: len:" . strlen($this->value) . " " . self::toHexString($this->value) . "\n" .
" Actual: len:" . strlen($this->value) . " " . self::toHexString($other)
);
}

Expand Down

0 comments on commit d864972

Please sign in to comment.