-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Test setting the logFormat and logFilename properties
- Loading branch information
1 parent
72e83cf
commit 3cc8318
Showing
1 changed file
with
44 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
<?php | ||
|
||
use League\Flysystem\Adapter\Local; | ||
use League\Flysystem\Filesystem; | ||
use wappr\LogFilename; | ||
use wappr\LogFormat; | ||
use wappr\Logger; | ||
|
||
class otherLogClassesTest extends PHPUnit_Framework_TestCase | ||
{ | ||
public function testSpeicifyingLogClasses() | ||
{ | ||
$adapter = new Local(dirname(__DIR__).'/storage/logs/'); | ||
$filesystem = new Filesystem($adapter); | ||
$logger = new Logger($filesystem, Psr\Log\LogLevel::INFO); | ||
|
||
$logFilename = new LogFilename; | ||
$logFormat = new LogFormat; | ||
|
||
$this->assertInstanceOf('wappr\Contracts\LogFilenameInterface', $logFilename); | ||
$this->assertInstanceOf('wappr\Contracts\LogFormatInterface', $logFormat); | ||
|
||
$logger->setLogFilename($logFilename); | ||
$logger->setLogFormat($logFormat); | ||
|
||
$result = $logger->debug('A horse is a dog.'); | ||
$this->assertNull($result); | ||
|
||
$logs = $filesystem->read(date('Y-m-d').'.log'); // read the logs into a string | ||
|
||
$log = explode("\n", $logs); // explode the string by newline into an array | ||
|
||
$numberOfLines = count($log); // get the number of indexes in the array | ||
unset($log[$numberOfLines - 1]); // take off the last line / last index of the array | ||
|
||
$containHorse = false; | ||
|
||
if (strpos(end($log), 'cat') !== false) { | ||
$containHorse = true; | ||
} | ||
|
||
$this->assertFalse($containHorse); | ||
} | ||
} |