mirror of
https://github.com/composer/composer
synced 2025-05-09 00:22:53 +00:00
Uses config data from Composer object whenever possible on ArchiveCommand
It was previously blindly getting a new instance from the factory thus ignoring what is on Composer object config data.
This commit is contained in:
parent
dbcf592ea2
commit
97d077c43b
3 changed files with 129 additions and 1 deletions
121
tests/Composer/Test/Command/ArchiveCommandTest.php
Normal file
121
tests/Composer/Test/Command/ArchiveCommandTest.php
Normal file
|
@ -0,0 +1,121 @@
|
|||
<?php
|
||||
|
||||
/*
|
||||
* This file is part of Composer.
|
||||
*
|
||||
* (c) Nils Adermann <naderman@naderman.de>
|
||||
* Jordi Boggiano <j.boggiano@seld.be>
|
||||
*
|
||||
* 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);
|
||||
}
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue