-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #2 from mleko/register
Register
- Loading branch information
Showing
19 changed files
with
279 additions
and
34 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,36 @@ | ||
<?php | ||
/** | ||
* Wingman | ||
* | ||
* @link http://github.com/mleko/wingman | ||
* @copyright Copyright (c) 2017 Daniel Król | ||
* @license MIT | ||
*/ | ||
|
||
namespace Mleko\Wingman\Console; | ||
|
||
|
||
use Mleko\Wingman\Wingman; | ||
use Symfony\Component\Console\Command\Command; | ||
use Symfony\Component\Console\Input\InputArgument; | ||
use Symfony\Component\Console\Input\InputInterface; | ||
use Symfony\Component\Console\Output\OutputInterface; | ||
|
||
class RegisterCommand extends Command | ||
{ | ||
protected function configure() | ||
{ | ||
parent::configure(); | ||
$this->setName("register") | ||
->setDescription("Register wingman as post-update script and format composer.json file") | ||
->addArgument("path", InputArgument::OPTIONAL, "Path to composer.json file", "./composer.json"); | ||
} | ||
|
||
protected function execute(InputInterface $input, OutputInterface $output) | ||
{ | ||
$path = $input->getArgument("path"); | ||
$wingman = new Wingman(); | ||
$wingman->registerInFile($path, new ConsoleOutputAdapter($output)); | ||
} | ||
|
||
} |
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,52 @@ | ||
<?php | ||
/** | ||
* Wingman | ||
* | ||
* @link http://github.com/mleko/wingman | ||
* @copyright Copyright (c) 2017 Daniel Król | ||
* @license MIT | ||
*/ | ||
|
||
namespace Mleko\Wingman\Console; | ||
|
||
use org\bovigo\vfs\vfsStream; | ||
use org\bovigo\vfs\vfsStreamDirectory; | ||
use PHPUnit\Framework\TestCase; | ||
use Symfony\Component\Console\Tester\CommandTester; | ||
|
||
class RegisterCommandTest extends TestCase | ||
{ | ||
/** | ||
* @var vfsStreamDirectory | ||
*/ | ||
private $root; | ||
|
||
/** | ||
* set up test environment | ||
*/ | ||
public function setUp() | ||
{ | ||
$this->root = vfsStream::setup('testRoot'); | ||
} | ||
|
||
public function testRegisterCommand() | ||
{ | ||
$virtualFile = vfsStream::newFile("composer.json"); | ||
$this->root->addChild($virtualFile); | ||
$virtualFile->setContent(json_encode(["name" => "acme/test"])); | ||
|
||
$application = new Application(); | ||
$registerCommand = $application->find("register"); | ||
$commandTester = new CommandTester($registerCommand); | ||
|
||
$resultCode = $commandTester->execute([ | ||
"command" => $registerCommand->getName(), | ||
"path" => $virtualFile->url() | ||
]); | ||
|
||
$this->assertEquals(0, $resultCode); | ||
$contents = json_decode($virtualFile->getContent()); | ||
$this->assertContains("Mleko\\Wingman\\Composer\\EventHandler::format", $contents->scripts->{"post-update-cmd"}); | ||
$this->assertEquals("Register wingman in file: vfs://testRoot/composer.json\nWingman registered\nFormatting file: vfs://testRoot/composer.json\n", $commandTester->getDisplay()); | ||
} | ||
} |
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,9 @@ | ||
{ | ||
"license": "MIT", | ||
"name": "mleko/wingman", | ||
"scripts": { | ||
"post-update-cmd": [ | ||
"Mleko\\Wingman\\Composer\\EventHandler::format" | ||
] | ||
} | ||
} |
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,4 @@ | ||
{ | ||
"license": "MIT", | ||
"name": "mleko/wingman" | ||
} |
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,7 @@ | ||
{ | ||
"scripts": { | ||
"post-update-cmd": [ | ||
"Mleko\\Wingman\\Composer\\EventHandler::format" | ||
] | ||
} | ||
} |
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,7 @@ | ||
{ | ||
"scripts": { | ||
"post-update-cmd": [ | ||
"Mleko\\Wingman\\Composer\\EventHandler::format" | ||
] | ||
} | ||
} |
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,8 @@ | ||
{ | ||
"scripts": { | ||
"test": "phpunit", | ||
"post-update-cmd": [ | ||
"Mleko\\Wingman\\Composer\\EventHandler::format" | ||
] | ||
} | ||
} |
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,5 @@ | ||
{ | ||
"scripts": { | ||
"test": "phpunit" | ||
} | ||
} |
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,8 @@ | ||
{ | ||
"scripts": { | ||
"post-update-cmd": [ | ||
"noop", | ||
"Mleko\\Wingman\\Composer\\EventHandler::format" | ||
] | ||
} | ||
} |
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,5 @@ | ||
{ | ||
"scripts": { | ||
"post-update-cmd": "noop" | ||
} | ||
} |
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,8 @@ | ||
{ | ||
"scripts": { | ||
"post-update-cmd": [ | ||
"noop", | ||
"Mleko\\Wingman\\Composer\\EventHandler::format" | ||
] | ||
} | ||
} |
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,7 @@ | ||
{ | ||
"scripts": { | ||
"post-update-cmd": [ | ||
"noop" | ||
] | ||
} | ||
} |
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,5 @@ | ||
{ | ||
"scripts": { | ||
"post-update-cmd": "Mleko\\Wingman\\Composer\\EventHandler::format" | ||
} | ||
} |
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,5 @@ | ||
{ | ||
"scripts": { | ||
"post-update-cmd": "Mleko\\Wingman\\Composer\\EventHandler::format" | ||
} | ||
} |