forked from composer/composer
-
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.
Uses config data from Composer object whenever possible on ArchiveCom…
…mand It was previously blindly getting a new instance from the factory thus ignoring what is on Composer object config data.
- Loading branch information
1 parent
dbcf592
commit 97d077c
Showing
3 changed files
with
129 additions
and
1 deletion.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,121 @@ | ||
<?php | ||
|
||
/* | ||
* This file is part of Composer. | ||
* | ||
* (c) Nils Adermann <[email protected]> | ||
* Jordi Boggiano <[email protected]> | ||
* | ||
* For the full copyright and license information, please view the LICENSE | ||
* file that was distributed with this source code. | ||
*/ | ||
|
||
namespace Composer\Test\Command; | ||
|
||
use Composer\Composer; | ||
use Composer\Config; | ||
use Composer\Factory; | ||
use Composer\Test\TestCase; | ||
use Symfony\Component\Console\Input\ArrayInput; | ||
|
||
class ArchiveCommandTest extends TestCase | ||
{ | ||
public function testUsesConfigFromComposerObject() | ||
{ | ||
$input = new ArrayInput(array()); | ||
|
||
$output = $this->getMockBuilder('Symfony\Component\Console\Output\OutputInterface') | ||
->getMock(); | ||
|
||
$ed = $this->getMockBuilder('Composer\EventDispatcher\EventDispatcher') | ||
->disableOriginalConstructor()->getMock(); | ||
|
||
$composer = new Composer; | ||
$config = new Config; | ||
$config->merge(array('config' => array('archive-format' => 'zip'))); | ||
$composer->setConfig($config); | ||
|
||
$manager = $this->getMockBuilder('Composer\Package\Archiver\ArchiveManager') | ||
->disableOriginalConstructor()->getMock(); | ||
|
||
$package = $this->getMockBuilder('Composer\Package\RootPackageInterface') | ||
->getMock(); | ||
|
||
$manager->expects($this->once())->method('archive') | ||
->with($package, 'zip', '.', null, false)->willReturn(getcwd()); | ||
|
||
$composer->setArchiveManager($manager); | ||
$composer->setEventDispatcher($ed); | ||
$composer->setPackage($package); | ||
|
||
$command = $this->getMockBuilder('Composer\Command\ArchiveCommand') | ||
->setMethods(array( | ||
'mergeApplicationDefinition', | ||
'bind', | ||
'getSynopsis', | ||
'initialize', | ||
'isInteractive', | ||
'getComposer', | ||
))->getMock(); | ||
$command->expects($this->any())->method('getComposer') | ||
->willReturn($composer); | ||
$command->method('isInteractive')->willReturn(false); | ||
|
||
$command->run($input, $output); | ||
} | ||
|
||
public function testUsesConfigFromFactoryWhenComposerIsNotDefined() | ||
{ | ||
$input = new ArrayInput(array()); | ||
|
||
$output = $this->getMockBuilder('Symfony\Component\Console\Output\OutputInterface') | ||
->getMock(); | ||
|
||
$ed = $this->getMockBuilder('Composer\EventDispatcher\EventDispatcher') | ||
->disableOriginalConstructor()->getMock(); | ||
|
||
$composer = new Composer; | ||
$config = Factory::createConfig(); | ||
|
||
$manager = $this->getMockBuilder('Composer\Package\Archiver\ArchiveManager') | ||
->disableOriginalConstructor()->getMock(); | ||
|
||
$factory = $this->getMockBuilder('Composer\Factory')->getMock(); | ||
$factory->method('createArchiveManager')->willReturn($manager); | ||
|
||
$package = $this->getMockBuilder('Composer\Package\RootPackageInterface') | ||
->getMock(); | ||
|
||
$composer->setArchiveManager($manager); | ||
$composer->setEventDispatcher($ed); | ||
$composer->setPackage($package); | ||
|
||
$command = $this->getMockBuilder('Composer\Command\ArchiveCommand') | ||
->setMethods(array( | ||
'mergeApplicationDefinition', | ||
'bind', | ||
'getSynopsis', | ||
'initialize', | ||
'isInteractive', | ||
'getComposer', | ||
'archive', | ||
))->getMock(); | ||
$command->expects($this->any())->method('getComposer') | ||
->willReturnOnConsecutiveCalls(null, $composer); | ||
$command->expects($this->any())->method('archive') | ||
->with( | ||
$this->isType('object'), | ||
$config, | ||
null, | ||
null, | ||
'tar', | ||
'.', | ||
null, | ||
false, | ||
null | ||
); | ||
$command->method('isInteractive')->willReturn(false); | ||
|
||
$command->run($input, $output); | ||
} | ||
} |