Skip to content

Commit

Permalink
Swap out deprecated method
Browse files Browse the repository at this point in the history
  • Loading branch information
aldenw committed Dec 15, 2020
1 parent efe5910 commit 47ab1ba
Showing 1 changed file with 11 additions and 14 deletions.
25 changes: 11 additions & 14 deletions tests/ColoredLineFormatterTest.php
Original file line number Diff line number Diff line change
@@ -1,13 +1,16 @@
<?php

use Bramus\Monolog\Formatter\ColorSchemes\ColorSchemeInterface;
use Bramus\Monolog\Formatter\ColorSchemes\DefaultScheme;
use Bramus\Monolog\Formatter\ColorSchemes\TrafficLight;
use \Monolog\Logger;
use \Bramus\Monolog\Formatter\ColoredLineFormatter;
use Bramus\Ansi\Ansi;
use Bramus\Ansi\Writers\BufferWriter;
use Bramus\Ansi\ControlSequences\EscapeSequences\Enums\SGR;
use PHPUnit\Framework\TestCase;

class ColoredLineFormatterTest extends \PHPUnit\Framework\TestCase
class ColoredLineFormatterTest extends TestCase
{
/**
* @var Ansi
Expand All @@ -25,11 +28,6 @@ protected function setUp(): void
$this->clf = new ColoredLineFormatter();
}

protected function tearDown(): void
{
// ...
}

public function testInstantiation()
{
$this->assertInstanceOf('\Bramus\Monolog\Formatter\ColoredLineFormatter', $this->clf);
Expand All @@ -42,7 +40,7 @@ public function testReset()

public function testDefaultColorScheme()
{
$defaultScheme = new \Bramus\Monolog\Formatter\ColorSchemes\DefaultScheme();
$defaultScheme = new DefaultScheme();

$this->assertEquals(
$this->clf->getColorScheme()->getColorizeArray(),
Expand All @@ -52,7 +50,7 @@ public function testDefaultColorScheme()

public function testSetColorSchemeViaConstructor()
{
$newScheme = new \Bramus\Monolog\Formatter\ColorSchemes\TrafficLight();
$newScheme = new TrafficLight();
$this->clf = new ColoredLineFormatter($newScheme);

$this->assertEquals(
Expand All @@ -63,7 +61,7 @@ public function testSetColorSchemeViaConstructor()

public function testSetColorSchemeViaSetColorScheme()
{
$newScheme = new \Bramus\Monolog\Formatter\ColorSchemes\TrafficLight();
$newScheme = new TrafficLight();
$this->clf->setColorScheme($newScheme);

$this->assertEquals(
Expand All @@ -74,7 +72,6 @@ public function testSetColorSchemeViaSetColorScheme()

public function testSetColorSchemeFilter()
{

$dummyArray = array(
Logger::DEBUG => $this->ansi->sgr(array(SGR::COLOR_FG_GREEN, SGR::STYLE_INTENSITY_FAINT))->get(),
'123' => 'foo',
Expand Down Expand Up @@ -116,14 +113,14 @@ public function testFormatColorizesEntireLineByDefault()
'level_name' => Logger::getLevelName(Logger::INFO),
'channel' => 'DEMO',
'message' => 'Lorem ipsum dolor sit amet, consectetur adipiscing elit.',
'datetime' => new \DateTime(),
'datetime' => new DateTime(),
'context' => array(),
'extra' => array()
);

$formatter = new ColoredLineFormatter($colorScheme);
$output = $formatter->format($record);
$this->assertRegExp('/^foo.+bar\\n$/',$output);
$this->assertMatchesRegularExpression('/^foo.+bar\\n$/',$output);
}

/**
Expand All @@ -143,15 +140,15 @@ public function testFormatReplacesTokensWithColorizeStrings()
'level_name' => $levelName,
'channel' => 'DEMO',
'message' => 'Lorem ipsum dolor sit amet, consectetur adipiscing elit.',
'datetime' => new \DateTime(),
'datetime' => new DateTime(),
'context' => array(),
'extra' => array()
);

$format = "[%datetime%] %channel%.%color_begin%%level_name%%color_end%: %message% %context% %extra%\n";
$formatter = new ColoredLineFormatter($colorScheme, $format);
$output = $formatter->format($record);
$this->assertRegExp("/^.+foo{$levelName}bar.+$/",$output);
$this->assertMatchesRegularExpression("/^.+foo{$levelName}bar.+$/",$output);
}

// public function testDemo()
Expand Down

0 comments on commit 47ab1ba

Please sign in to comment.