2 namespace Consolidation\Log;
4 use Symfony\Component\Console\Output\BufferedOutput;
5 use Symfony\Component\Console\Output\OutputInterface;
7 class LogMethodTests extends \PHPUnit_Framework_TestCase
13 $this->output = new BufferedOutput();
14 $this->output->setVerbosity(OutputInterface::VERBOSITY_DEBUG);
15 $this->logger = new Logger($this->output);
16 $this->logger->setLogOutputStyler(new UnstyledLogOutputStyler());
19 function testError() {
20 $this->logger->error('Do not enter - wrong way.');
21 $outputText = rtrim($this->output->fetch());
22 $this->assertEquals(' [error] Do not enter - wrong way.', $outputText);
25 function testWarning() {
26 $this->logger->warning('Steep grade.');
27 $outputText = rtrim($this->output->fetch());
28 $this->assertEquals(' [warning] Steep grade.', $outputText);
31 function testNotice() {
32 $this->logger->notice('No loitering.');
33 $outputText = rtrim($this->output->fetch());
34 $this->assertEquals(' [notice] No loitering.', $outputText);
38 $this->logger->info('Scenic route.');
39 $outputText = rtrim($this->output->fetch());
40 $this->assertEquals(' [info] Scenic route.', $outputText);
43 function testDebug() {
44 $this->logger->debug('Counter incremented.');
45 $outputText = rtrim($this->output->fetch());
46 $this->assertEquals(' [debug] Counter incremented.', $outputText);
49 function testSuccess() {
50 $this->logger->success('It worked!');
51 $outputText = rtrim($this->output->fetch());
52 $this->assertEquals(' [success] It worked!', $outputText);