forked from phalcon/cphalcon
-
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.
[phalcon#13438] - Added more tests for formatters
- Loading branch information
1 parent
e9a74b3
commit b20f27c
Showing
7 changed files
with
284 additions
and
9 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,37 @@ | ||
<?php | ||
declare(strict_types=1); | ||
|
||
/** | ||
* This file is part of the Phalcon Framework. | ||
* | ||
* (c) Phalcon Team <team@phalconphp.com> | ||
* | ||
* For the full copyright and license information, please view the LICENSE.txt | ||
* file that was distributed with this source code. | ||
*/ | ||
|
||
namespace Phalcon\Test\Unit\Logger\Adapter\File; | ||
|
||
use UnitTester; | ||
|
||
/** | ||
* Class AddCest | ||
* | ||
* @package Phalcon\Test\Unit\Logger | ||
*/ | ||
class AddCest | ||
{ | ||
/** | ||
* Tests Phalcon\Logger\Adapter\File :: add() | ||
* | ||
* @param UnitTester $I | ||
* | ||
* @author Phalcon Team <team@phalconphp.com> | ||
* @since 2018-11-13 | ||
*/ | ||
public function loggerAdapterFileAdd(UnitTester $I) | ||
{ | ||
$I->wantToTest("Logger\Adapter\File - add()"); | ||
$I->skipTest("Need implementation"); | ||
} | ||
} |
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
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,78 @@ | ||
<?php | ||
declare(strict_types=1); | ||
|
||
/** | ||
* This file is part of the Phalcon Framework. | ||
* | ||
* (c) Phalcon Team <team@phalconphp.com> | ||
* | ||
* For the full copyright and license information, please view the LICENSE.txt | ||
* file that was distributed with this source code. | ||
*/ | ||
|
||
namespace Phalcon\Test\Unit\Logger\Formatter\Json; | ||
|
||
use Phalcon\Logger; | ||
use Phalcon\Logger\Formatter\Json; | ||
use Phalcon\Logger\Item; | ||
use UnitTester; | ||
|
||
/** | ||
* Class InterpolateCest | ||
* | ||
* @package Phalcon\Test\Unit\Logger | ||
*/ | ||
class InterpolateCest | ||
{ | ||
/** | ||
* Tests Phalcon\Logger\Formatter\Json :: interpolate() | ||
* | ||
* @param UnitTester $I | ||
* | ||
* @author Phalcon Team <team@phalconphp.com> | ||
* @since 2018-11-13 | ||
*/ | ||
public function loggerFormatterJsonInterpolate(UnitTester $I) | ||
{ | ||
$I->wantToTest("Logger\Formatter\Json - interpolate()"); | ||
$formatter = new Json(); | ||
|
||
$message = 'The sky is {color}'; | ||
$context = [ | ||
'color' => 'blue', | ||
]; | ||
|
||
$expected = 'The sky is blue'; | ||
$actual = $formatter->interpolate($message, $context); | ||
$I->assertEquals($expected, $actual); | ||
} | ||
|
||
/** | ||
* Tests Phalcon\Logger\Formatter\Json :: interpolate() - format | ||
* | ||
* @param UnitTester $I | ||
* | ||
* @author Phalcon Team <team@phalconphp.com> | ||
* @since 2018-11-13 | ||
*/ | ||
public function loggerFormatterJsonInterpolateFormat(UnitTester $I) | ||
{ | ||
$I->wantToTest("Logger\Formatter\Json - interpolate() - format()"); | ||
$formatter = new Json(); | ||
|
||
$message = 'The sky is {color}'; | ||
$context = [ | ||
'color' => 'blue', | ||
]; | ||
|
||
$time = time(); | ||
$item = new Item($message, 'debug', Logger::DEBUG, $time, $context); | ||
|
||
$expected = sprintf( | ||
'{"type":"debug","message":"The sky is blue","timestamp":"%s"}', | ||
date('D, d M y H:i:s O', $time) | ||
); | ||
$actual = $formatter->format($item); | ||
$I->assertEquals($expected, $actual); | ||
} | ||
} |
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
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
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,47 @@ | ||
<?php | ||
declare(strict_types=1); | ||
|
||
/** | ||
* This file is part of the Phalcon Framework. | ||
* | ||
* (c) Phalcon Team <team@phalconphp.com> | ||
* | ||
* For the full copyright and license information, please view the LICENSE.txt | ||
* file that was distributed with this source code. | ||
*/ | ||
|
||
namespace Phalcon\Test\Unit\Logger\Formatter\Syslog; | ||
|
||
use Phalcon\Logger; | ||
use Phalcon\Logger\Formatter\Syslog; | ||
use Phalcon\Logger\Item; | ||
use UnitTester; | ||
|
||
/** | ||
* Class FormatCest | ||
* | ||
* @package Phalcon\Test\Unit\Logger | ||
*/ | ||
class FormatCest | ||
{ | ||
/** | ||
* Tests Phalcon\Logger\Formatter\Syslog :: format() | ||
* | ||
* @param UnitTester $I | ||
* | ||
* @author Phalcon Team <team@phalconphp.com> | ||
* @since 2018-11-13 | ||
*/ | ||
public function loggerFormatterSyslogFormat(UnitTester $I) | ||
{ | ||
$I->wantToTest("Logger\Formatter\Syslog - format()"); | ||
$formatter = new Syslog(); | ||
|
||
$time = time(); | ||
$item = new Item('log message', 'debug', Logger::DEBUG, $time); | ||
|
||
$expected = [Logger::DEBUG, 'log message']; | ||
$actual = $formatter->format($item); | ||
$I->assertEquals($expected, $actual); | ||
} | ||
} |
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,75 @@ | ||
<?php | ||
declare(strict_types=1); | ||
|
||
/** | ||
* This file is part of the Phalcon Framework. | ||
* | ||
* (c) Phalcon Team <team@phalconphp.com> | ||
* | ||
* For the full copyright and license information, please view the LICENSE.txt | ||
* file that was distributed with this source code. | ||
*/ | ||
|
||
namespace Phalcon\Test\Unit\Logger\Formatter\Syslog; | ||
|
||
use Phalcon\Logger; | ||
use Phalcon\Logger\Formatter\Syslog; | ||
use Phalcon\Logger\Item; | ||
use UnitTester; | ||
|
||
/** | ||
* Class InterpolateCest | ||
* | ||
* @package Phalcon\Test\Unit\Logger | ||
*/ | ||
class InterpolateCest | ||
{ | ||
/** | ||
* Tests Phalcon\Logger\Formatter\Syslog :: interpolate() | ||
* | ||
* @param UnitTester $I | ||
* | ||
* @author Phalcon Team <team@phalconphp.com> | ||
* @since 2018-11-13 | ||
*/ | ||
public function loggerFormatterSyslogInterpolate(UnitTester $I) | ||
{ | ||
$I->wantToTest("Logger\Formatter\Syslog - interpolate()"); | ||
$formatter = new Syslog(); | ||
|
||
$message = 'The sky is {color}'; | ||
$context = [ | ||
'color' => 'blue', | ||
]; | ||
|
||
$expected = 'The sky is blue'; | ||
$actual = $formatter->interpolate($message, $context); | ||
$I->assertEquals($expected, $actual); | ||
} | ||
|
||
/** | ||
* Tests Phalcon\Logger\Formatter\Syslog :: interpolate() - format | ||
* | ||
* @param UnitTester $I | ||
* | ||
* @author Phalcon Team <team@phalconphp.com> | ||
* @since 2018-11-13 | ||
*/ | ||
public function loggerFormatterSyslogInterpolateFormat(UnitTester $I) | ||
{ | ||
$I->wantToTest("Logger\Formatter\Syslog - interpolate() - format()"); | ||
$formatter = new Syslog(); | ||
|
||
$message = 'The sky is {color}'; | ||
$context = [ | ||
'color' => 'blue', | ||
]; | ||
|
||
$time = time(); | ||
$item = new Item($message, 'debug', Logger::DEBUG, $time, $context); | ||
|
||
$expected = [Logger::DEBUG, 'The sky is blue']; | ||
$actual = $formatter->format($item); | ||
$I->assertEquals($expected, $actual); | ||
} | ||
} |