Skip to content

Commit

Permalink
Adding interpolate test
Browse files Browse the repository at this point in the history
  • Loading branch information
levidurfee committed Nov 26, 2016
1 parent 66f824a commit b2791fe
Show file tree
Hide file tree
Showing 2 changed files with 32 additions and 1 deletion.
2 changes: 1 addition & 1 deletion src/LogFormat.php
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ public function create($level, $message, array $context = [])
$message .= "\n".print_r($context, true);
}

return $this->interpolate($message);
return $this->interpolate($message, $context);
}

/**
Expand Down
31 changes: 31 additions & 0 deletions tests/InterpolateTest.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
<?php

use League\Flysystem\Adapter\Local;
use League\Flysystem\Filesystem;
use wappr\Logger;

class InterpolateTest extends PHPUnit_Framework_TestCase
{
public function testInterpolate()
{
$adapter = new Local(dirname(__DIR__).'/storage/logs/');
$filesystem = new Filesystem($adapter);
$logger = new Logger($filesystem, Psr\Log\LogLevel::INFO);

$values = [
'animal' => 'cat',
];

$logger->info('A horse is a {animal}.', $values);

$logs = $filesystem->read(date('Y-m-d').'.log'); // read the logs into a string

$containsCat = false;

if (strpos($logs, 'cat') !== false) {
$containsCat = true;
}

$this->assertTrue($containsCat);
}
}

0 comments on commit b2791fe

Please sign in to comment.