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] - Correction to the logger trait; Added more tests
- Loading branch information
1 parent
9ea4da1
commit f3670b5
Showing
7 changed files
with
253 additions
and
76 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
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,82 @@ | ||
<?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; | ||
|
||
use Phalcon\Logger; | ||
use Phalcon\Logger\Adapter\File; | ||
use UnitTester; | ||
|
||
/** | ||
* Class ExcludeAdaptersCest | ||
* | ||
* @package Phalcon\Test\Unit\Logger | ||
*/ | ||
class ExcludeAdaptersCest | ||
{ | ||
/** | ||
* Tests Phalcon\Logger :: excludeAdapters() | ||
* | ||
* @param UnitTester $I | ||
* | ||
* @author Phalcon Team <team@phalconphp.com> | ||
* @since 2018-11-13 | ||
*/ | ||
public function loggerExcludeAdapters(UnitTester $I) | ||
{ | ||
$I->wantToTest('Logger - excludeAdapters()'); | ||
|
||
$fileName1 = $I->getNewFileName('log', 'log'); | ||
$fileName2 = $I->getNewFileName('log', 'log'); | ||
$outputPath = outputFolder('tests/logs/'); | ||
$adapter1 = new File($outputPath . $fileName1); | ||
$adapter2 = new File($outputPath . $fileName2); | ||
|
||
$logger = new Logger( | ||
'my-logger', | ||
[ | ||
'one' => $adapter1, | ||
'two' => $adapter2, | ||
] | ||
); | ||
|
||
/** | ||
* Log into both | ||
*/ | ||
$logger->debug('Hello'); | ||
|
||
$I->amInPath($outputPath); | ||
$I->openFile($fileName1); | ||
$I->seeInThisFile('Hello'); | ||
|
||
$I->amInPath($outputPath); | ||
$I->openFile($fileName2); | ||
$I->seeInThisFile('Hello'); | ||
|
||
/** | ||
* Exclude a logger | ||
*/ | ||
$logger | ||
->excludeAdapters(['two']) | ||
->debug('Goodbye'); | ||
|
||
$I->amInPath($outputPath); | ||
$I->openFile($fileName1); | ||
$I->seeInThisFile('Goodbye'); | ||
$I->safeDeleteFile($fileName1); | ||
|
||
$I->amInPath($outputPath); | ||
$I->openFile($fileName2); | ||
$I->seeInThisFile('Goodbye'); | ||
$I->safeDeleteFile($fileName2); | ||
} | ||
} |
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