Skip to content

Commit

Permalink
Merge 6064ba6 into f6dcab6
Browse files Browse the repository at this point in the history
  • Loading branch information
manuee committed Jul 24, 2018
2 parents f6dcab6 + 6064ba6 commit a7e51f9
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 5 deletions.
4 changes: 2 additions & 2 deletions src/Plugin.php
Original file line number Diff line number Diff line change
Expand Up @@ -26,9 +26,9 @@ class Plugin implements PluginInterface, EventSubscriberInterface, Capable
/**
* {@inheritdoc}
*/
public function activate(Composer $composer, IOInterface $io, array $configParameters = array())
public function activate(Composer $composer, IOInterface $io)
{
$this->pluginHandler = new PluginHandler($composer, $io, $configParameters);
$this->pluginHandler = new PluginHandler($composer, $io);
}

/**
Expand Down
15 changes: 12 additions & 3 deletions tests/src/Unit/PluginTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@

use EdisonLabs\MergeYaml\Plugin;
use Composer\Composer;
use Composer\Config;
use Composer\Script\ScriptEvents;
use PHPUnit\Framework\TestCase;

Expand Down Expand Up @@ -44,7 +45,14 @@ protected function setUp()
'output-dir' => '/tmp/merge-yaml',
];

$this->packageMock = $this->getMockBuilder('Composer\Package\RootPackageInterface')->getMock();
$this->packageMock = $this->getMockBuilder('Composer\Package\RootPackage')
->disableOriginalConstructor()
->setMethods(['getExtra', 'setExtra'])
->getMock();
$this->packageMock->expects($this->once())
->method('getExtra')
->will($this->returnValue(['merge-yaml' => $this->defaultConfig]));

$this->eventMock = $this->getMockBuilder('Composer\Script\Event')
->disableOriginalConstructor()
->getMock();
Expand Down Expand Up @@ -79,12 +87,13 @@ public function testPlugin()
$this->assertEquals(['postCmd', -1], $events[ScriptEvents::POST_UPDATE_CMD]);

$io = $this->getMockBuilder('Composer\IO\IOInterface')->getMock();

$composer = new Composer();
$composer->setPackage($this->packageMock);
$plugin->activate($composer, $io, $this->defaultConfig);
$plugin->activate($composer, $io);
$this->assertInstanceOf('\EdisonLabs\MergeYaml\PluginHandler', $plugin->getPluginHandler());

$plugin->postCmd($this->eventMock, $this->defaultConfig);
$plugin->postCmd($this->eventMock);
$this->assertFileExists('/tmp/merge-yaml/test.merge.yml');
}
}

0 comments on commit a7e51f9

Please sign in to comment.