Last active
March 13, 2017 09:41
-
-
Save guiled/2a23a91b57f3438371afb2f1a2c2f116 to your computer and use it in GitHub Desktop.
Test write to a file
This file contains hidden or 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
<?php | |
namespace Project\Log\tests\units; | |
use \mageekguy\atoum; | |
class Logger extends atoum\test | |
{ | |
public function testStdout() | |
{ | |
$this | |
->assert('Log to default : output') | |
->given($this->newTestedInstance) | |
->and($str = 'test output to default') | |
->output(function () use ($str){ | |
$this->testedInstance->log($str); | |
})->contains($str) | |
->assert('Log to specified output : php://output (like default?)') | |
->given($this->newTestedInstance('php://output')) | |
->and($str = 'test output to stdout') | |
->output(function () use ($str){ | |
$this->testedInstance->log($str); | |
})->contains($str) | |
->assert('Log to a specified file') | |
->given( | |
$str = 'test XXX output to a file', | |
$file = \atoum\mock\streams\fs\file::get('testlog'), | |
$this->newTestedInstance($file->getPath()) | |
) | |
->if($this->testedInstance->log($str)) | |
->stream($file)->isWritten() | |
->string(file_get_contents($file->getPath())) | |
->contains($str) | |
; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment