-
-
Notifications
You must be signed in to change notification settings - Fork 52
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
4ca43af
commit be7a740
Showing
9 changed files
with
203 additions
and
33 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
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,26 @@ | ||
<?php | ||
|
||
namespace TYPO3\Surf\Tests\Unit\Cli\Symfony; | ||
|
||
/* | ||
* This file is part of TYPO3 Surf. | ||
* | ||
* For the full copyright and license information, please view the LICENSE.txt | ||
* file that was distributed with this source code. | ||
*/ | ||
|
||
use PHPUnit\Framework\TestCase; | ||
use Symfony\Component\Console\Output\ConsoleOutput; | ||
use TYPO3\Surf\Cli\Symfony\ConsoleOutputFactory; | ||
|
||
class ConsoleOutputFactoryTest extends TestCase | ||
{ | ||
/** | ||
* @test | ||
*/ | ||
public function createOutput(): void | ||
{ | ||
$consoleOutputFactory = new ConsoleOutputFactory(); | ||
$this->assertInstanceOf(ConsoleOutput::class, $consoleOutputFactory->createOutput()); | ||
} | ||
} |
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,74 @@ | ||
<?php | ||
|
||
namespace TYPO3\Surf\Tests\Unit\Cli\Symfony\Logger; | ||
|
||
/* | ||
* This file is part of TYPO3 Surf. | ||
* | ||
* For the full copyright and license information, please view the LICENSE.txt | ||
* file that was distributed with this source code. | ||
*/ | ||
|
||
use Monolog\Logger; | ||
use PHPUnit\Framework\TestCase; | ||
use TYPO3\Surf\Cli\Symfony\Logger\ConsoleFormatter; | ||
|
||
class ConsoleFormatterTest extends TestCase | ||
{ | ||
/** | ||
* @var ConsoleFormatter | ||
*/ | ||
protected $subject; | ||
|
||
public function records(): array | ||
{ | ||
return [ | ||
[ | ||
[ | ||
'level' => Logger::ERROR, | ||
'extra' => [], | ||
'context' => [] | ||
], | ||
"<error>%message%</error>\n" | ||
], | ||
[ | ||
[ | ||
'level' => Logger::NOTICE, | ||
'extra' => [], | ||
'context' => [] | ||
], | ||
"<comment>%message%</comment>\n" | ||
], | ||
[ | ||
[ | ||
'level' => Logger::INFO, | ||
'extra' => [], | ||
'context' => [] | ||
], | ||
"<info>%message%</info>\n" | ||
], | ||
[ | ||
[ | ||
'level' => Logger::DEBUG, | ||
'extra' => [], | ||
'context' => [] | ||
], | ||
"<debug>%message%</debug>\n" | ||
], | ||
]; | ||
} | ||
|
||
protected function setUp() | ||
{ | ||
$this->subject = new ConsoleFormatter(); | ||
} | ||
|
||
/** | ||
* @test | ||
* @dataProvider records | ||
*/ | ||
public function format(array $record, string $expectedOutput): void | ||
{ | ||
$this->assertEquals($expectedOutput, $this->subject->format($record)); | ||
} | ||
} |
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,61 @@ | ||
<?php | ||
|
||
namespace TYPO3\Surf\Tests\Unit\Cli\Symfony\Logger; | ||
|
||
/* | ||
* This file is part of TYPO3 Surf. | ||
* | ||
* For the full copyright and license information, please view the LICENSE.txt | ||
* file that was distributed with this source code. | ||
*/ | ||
|
||
use Monolog\Logger; | ||
use PHPUnit\Framework\TestCase; | ||
use Symfony\Component\Console\Output\OutputInterface; | ||
use TYPO3\Surf\Cli\Symfony\Logger\ConsoleFormatter; | ||
use TYPO3\Surf\Cli\Symfony\Logger\ConsoleHandler; | ||
|
||
class ConsoleHandlerTest extends TestCase | ||
{ | ||
/** | ||
* @test | ||
*/ | ||
public function constructor(): void | ||
{ | ||
$output = $this->prophesize(OutputInterface::class); | ||
$handler = new ConsoleHandler($output->reveal(), false); | ||
$this->assertFalse($handler->getBubble(), 'the bubble parameter gets propagated'); | ||
} | ||
|
||
/** | ||
* @test | ||
*/ | ||
public function isHandlingReturnsTrue(): void | ||
{ | ||
$output = $this->prophesize(OutputInterface::class); | ||
$output->getVerbosity()->willReturn(OutputInterface::VERBOSITY_DEBUG)->shouldBeCalled(); | ||
$handler = new ConsoleHandler($output->reveal()); | ||
$this->assertTrue($handler->isHandling(['level' => Logger::ERROR])); | ||
} | ||
|
||
/** | ||
* @test | ||
*/ | ||
public function isHandlingReturnsFalseIfOutputIsQuiet(): void | ||
{ | ||
$output = $this->prophesize(OutputInterface::class); | ||
$output->getVerbosity()->willReturn(OutputInterface::VERBOSITY_QUIET)->shouldBeCalled(); | ||
$handler = new ConsoleHandler($output->reveal()); | ||
$this->assertFalse($handler->isHandling(['level' => Logger::ERROR])); | ||
} | ||
|
||
/** | ||
* @test | ||
*/ | ||
public function getFormatter(): void | ||
{ | ||
$output = $this->prophesize(OutputInterface::class); | ||
$handler = new ConsoleHandler($output->reveal()); | ||
$this->assertInstanceOf(ConsoleFormatter::class, $handler->getFormatter()); | ||
} | ||
} |
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,29 @@ | ||
<?php | ||
|
||
namespace TYPO3\Surf\Tests\Unit\Cli\Symfony\Logger; | ||
|
||
/* | ||
* This file is part of TYPO3 Surf. | ||
* | ||
* For the full copyright and license information, please view the LICENSE.txt | ||
* file that was distributed with this source code. | ||
*/ | ||
|
||
use Monolog\Logger; | ||
use PHPUnit\Framework\TestCase; | ||
use TYPO3\Surf\Cli\Symfony\Logger\ConsoleHandler; | ||
use TYPO3\Surf\Cli\Symfony\Logger\LoggerFactory; | ||
|
||
class LoggerFactoryTest extends TestCase | ||
{ | ||
/** | ||
* @test | ||
*/ | ||
public function createLogger(): void | ||
{ | ||
$consoleHandler = $this->prophesize(ConsoleHandler::class); | ||
$loggerFactory = new LoggerFactory($consoleHandler->reveal()); | ||
|
||
$this->assertInstanceOf(Logger::class, $loggerFactory->createLogger()); | ||
} | ||
} |