-
Notifications
You must be signed in to change notification settings - Fork 71
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
Showing
10 changed files
with
109 additions
and
24 deletions.
There are no files selected for viewing
33 changes: 33 additions & 0 deletions
33
src/ComposerRequireChecker/Cli/ApplicationHeaderWriter.php
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,33 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
namespace ComposerRequireChecker\Cli; | ||
|
||
use Symfony\Component\Console\Application as AbstractApplication; | ||
use Symfony\Component\Console\Output\OutputInterface; | ||
|
||
final class ApplicationHeaderWriter | ||
{ | ||
private ?AbstractApplication $application; | ||
|
||
public function __construct(?AbstractApplication $application = null) | ||
{ | ||
$this->application = $application; | ||
} | ||
|
||
public function __invoke(OutputInterface $output): void | ||
{ | ||
if ($output->isQuiet()) { | ||
return; | ||
} | ||
|
||
if ($this->application === null) { | ||
$output->writeln('Unknown version'); | ||
|
||
return; | ||
} | ||
|
||
$output->writeln($this->application->getLongVersion()); | ||
} | ||
} |
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
36 changes: 36 additions & 0 deletions
36
test/ComposerRequireCheckerTest/Cli/ApplicationHeaderWriterTest.php
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,36 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
namespace ComposerRequireCheckerTest\Cli; | ||
|
||
use ComposerRequireChecker\Cli\ApplicationHeaderWriter; | ||
use PHPUnit\Framework\TestCase; | ||
use Symfony\Component\Console\Application; | ||
use Symfony\Component\Console\Output\BufferedOutput; | ||
|
||
/** | ||
* @covers \ComposerRequireChecker\Cli\ApplicationHeaderWriter | ||
*/ | ||
final class ApplicationHeaderWriterTest extends TestCase | ||
{ | ||
public function testWithoutApplication(): void | ||
{ | ||
$output = new BufferedOutput(); | ||
|
||
(new ApplicationHeaderWriter())->__invoke($output); | ||
|
||
self::assertStringContainsString('Unknown version', $output->fetch()); | ||
} | ||
|
||
public function testWithApplication(): void | ||
{ | ||
$output = new BufferedOutput(); | ||
|
||
$application = new Application('APPNAME', 'APPVERSION'); | ||
|
||
(new ApplicationHeaderWriter($application))->__invoke($output); | ||
|
||
self::assertStringContainsString('APPNAME APPVERSION', $output->fetch()); | ||
} | ||
} |
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