mirror of
https://github.com/composer/composer
synced 2025-05-09 00:22:53 +00:00
Fix CS (#11003)
This commit is contained in:
parent
6e205a0c84
commit
131da999ac
357 changed files with 5943 additions and 9174 deletions
|
@ -33,9 +33,9 @@ class EventDispatcherTest extends TestCase
|
|||
self::expectException('RuntimeException');
|
||||
|
||||
$io = $this->getMockBuilder('Composer\IO\IOInterface')->getMock();
|
||||
$dispatcher = $this->getDispatcherStubForListenersTest(array(
|
||||
$dispatcher = $this->getDispatcherStubForListenersTest([
|
||||
'Composer\Test\EventDispatcher\EventDispatcherTest::call',
|
||||
), $io);
|
||||
], $io);
|
||||
|
||||
$io->expects($this->once())
|
||||
->method('isVerbose')
|
||||
|
@ -53,26 +53,24 @@ class EventDispatcherTest extends TestCase
|
|||
|
||||
/**
|
||||
* @dataProvider provideValidCommands
|
||||
*
|
||||
* @param string $command
|
||||
*/
|
||||
public function testDispatcherCanExecuteSingleCommandLineScript(string $command): void
|
||||
{
|
||||
$process = $this->getProcessExecutorMock();
|
||||
$process->expects(array(
|
||||
$process->expects([
|
||||
$command,
|
||||
), true);
|
||||
], true);
|
||||
|
||||
$dispatcher = $this->getMockBuilder('Composer\EventDispatcher\EventDispatcher')
|
||||
->setConstructorArgs(array(
|
||||
->setConstructorArgs([
|
||||
$this->createComposerInstance(),
|
||||
$this->getMockBuilder('Composer\IO\IOInterface')->getMock(),
|
||||
$process,
|
||||
))
|
||||
->onlyMethods(array('getListeners'))
|
||||
])
|
||||
->onlyMethods(['getListeners'])
|
||||
->getMock();
|
||||
|
||||
$listener = array($command);
|
||||
$listener = [$command];
|
||||
$dispatcher->expects($this->atLeastOnce())
|
||||
->method('getListeners')
|
||||
->will($this->returnValue($listener));
|
||||
|
@ -82,8 +80,6 @@ class EventDispatcherTest extends TestCase
|
|||
|
||||
/**
|
||||
* @dataProvider provideDevModes
|
||||
*
|
||||
* @param bool $devMode
|
||||
*/
|
||||
public function testDispatcherPassDevModeToAutoloadGeneratorForScriptEvents(bool $devMode): void
|
||||
{
|
||||
|
@ -97,7 +93,7 @@ class EventDispatcherTest extends TestCase
|
|||
$composer->setAutoloadGenerator($generator);
|
||||
|
||||
$package = $this->getMockBuilder('Composer\Package\RootPackageInterface')->getMock();
|
||||
$package->method('getScripts')->will($this->returnValue(array('scriptName' => array('scriptName'))));
|
||||
$package->method('getScripts')->will($this->returnValue(['scriptName' => ['scriptName']]));
|
||||
$composer->setPackage($package);
|
||||
|
||||
$composer->setRepositoryManager($this->getRepositoryManagerMockForDevModePassingTest());
|
||||
|
@ -122,10 +118,10 @@ class EventDispatcherTest extends TestCase
|
|||
|
||||
public function provideDevModes(): array
|
||||
{
|
||||
return array(
|
||||
array(true),
|
||||
array(false),
|
||||
);
|
||||
return [
|
||||
[true],
|
||||
[false],
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -135,19 +131,19 @@ class EventDispatcherTest extends TestCase
|
|||
{
|
||||
$generator = $this->getMockBuilder('Composer\Autoload\AutoloadGenerator')
|
||||
->disableOriginalConstructor()
|
||||
->onlyMethods(array(
|
||||
->onlyMethods([
|
||||
'buildPackageMap',
|
||||
'parseAutoloads',
|
||||
'createLoader',
|
||||
'setDevMode',
|
||||
))
|
||||
])
|
||||
->getMock();
|
||||
$generator
|
||||
->method('buildPackageMap')
|
||||
->will($this->returnValue(array()));
|
||||
->will($this->returnValue([]));
|
||||
$generator
|
||||
->method('parseAutoloads')
|
||||
->will($this->returnValue(array('psr-0' => array(), 'psr-4' => array(), 'classmap' => array(), 'files' => array(), 'exclude-from-classmap' => array())));
|
||||
->will($this->returnValue(['psr-0' => [], 'psr-4' => [], 'classmap' => [], 'files' => [], 'exclude-from-classmap' => []]));
|
||||
$generator
|
||||
->method('createLoader')
|
||||
->will($this->returnValue($this->getMockBuilder('Composer\Autoload\ClassLoader')->getMock()));
|
||||
|
@ -162,13 +158,13 @@ class EventDispatcherTest extends TestCase
|
|||
{
|
||||
$rm = $this->getMockBuilder('Composer\Repository\RepositoryManager')
|
||||
->disableOriginalConstructor()
|
||||
->onlyMethods(array('getLocalRepository'))
|
||||
->onlyMethods(['getLocalRepository'])
|
||||
->getMock();
|
||||
|
||||
$repo = $this->getMockBuilder('Composer\Repository\InstalledRepositoryInterface')->getMock();
|
||||
$repo
|
||||
->method('getCanonicalPackages')
|
||||
->will($this->returnValue(array()));
|
||||
->will($this->returnValue([]));
|
||||
|
||||
$rm
|
||||
->method('getLocalRepository')
|
||||
|
@ -190,8 +186,8 @@ class EventDispatcherTest extends TestCase
|
|||
$this->getProcessExecutorMock()
|
||||
);
|
||||
|
||||
$listener = array($this, 'someMethod');
|
||||
$listener2 = array($this, 'someMethod2');
|
||||
$listener = [$this, 'someMethod'];
|
||||
$listener2 = [$this, 'someMethod2'];
|
||||
$listener3 = 'Composer\\Test\\EventDispatcher\\EventDispatcherTest::someMethod';
|
||||
|
||||
$dispatcher->addListener('ev1', $listener, 0);
|
||||
|
@ -223,27 +219,27 @@ class EventDispatcherTest extends TestCase
|
|||
public function testDispatcherCanExecuteCliAndPhpInSameEventScriptStack(): void
|
||||
{
|
||||
$process = $this->getProcessExecutorMock();
|
||||
$process->expects(array(
|
||||
$process->expects([
|
||||
'echo -n foo',
|
||||
'echo -n bar',
|
||||
), true);
|
||||
], true);
|
||||
|
||||
$dispatcher = $this->getMockBuilder('Composer\EventDispatcher\EventDispatcher')
|
||||
->setConstructorArgs(array(
|
||||
->setConstructorArgs([
|
||||
$this->createComposerInstance(),
|
||||
$io = new BufferIO('', OutputInterface::VERBOSITY_VERBOSE),
|
||||
$process,
|
||||
))
|
||||
->onlyMethods(array(
|
||||
])
|
||||
->onlyMethods([
|
||||
'getListeners',
|
||||
))
|
||||
])
|
||||
->getMock();
|
||||
|
||||
$listeners = array(
|
||||
$listeners = [
|
||||
'echo -n foo',
|
||||
'Composer\\Test\\EventDispatcher\\EventDispatcherTest::someMethod',
|
||||
'echo -n bar',
|
||||
);
|
||||
];
|
||||
|
||||
$dispatcher->expects($this->atLeastOnce())
|
||||
->method('getListeners')
|
||||
|
@ -260,20 +256,20 @@ class EventDispatcherTest extends TestCase
|
|||
public function testDispatcherCanPutEnv(): void
|
||||
{
|
||||
$dispatcher = $this->getMockBuilder('Composer\EventDispatcher\EventDispatcher')
|
||||
->setConstructorArgs(array(
|
||||
->setConstructorArgs([
|
||||
$this->createComposerInstance(),
|
||||
$io = new BufferIO('', OutputInterface::VERBOSITY_VERBOSE),
|
||||
$this->getProcessExecutorMock(),
|
||||
))
|
||||
->onlyMethods(array(
|
||||
])
|
||||
->onlyMethods([
|
||||
'getListeners',
|
||||
))
|
||||
])
|
||||
->getMock();
|
||||
|
||||
$listeners = array(
|
||||
$listeners = [
|
||||
'@putenv ABC=123',
|
||||
'Composer\\Test\\EventDispatcher\\EventDispatcherTest::getTestEnv',
|
||||
);
|
||||
];
|
||||
|
||||
$dispatcher->expects($this->atLeastOnce())
|
||||
->method('getListeners')
|
||||
|
@ -293,18 +289,18 @@ class EventDispatcherTest extends TestCase
|
|||
chdir(__DIR__);
|
||||
Platform::putEnv('COMPOSER_BIN_DIR', __DIR__ . '/vendor/bin');
|
||||
|
||||
$dispatcher = $this->getMockBuilder('Composer\EventDispatcher\EventDispatcher')->setConstructorArgs(array(
|
||||
$dispatcher = $this->getMockBuilder('Composer\EventDispatcher\EventDispatcher')->setConstructorArgs([
|
||||
$this->createComposerInstance(),
|
||||
$io = new BufferIO('', OutputInterface::VERBOSITY_VERBOSE),
|
||||
$this->getProcessExecutorMock(),
|
||||
))->onlyMethods(array(
|
||||
])->onlyMethods([
|
||||
'getListeners',
|
||||
))->getMock();
|
||||
])->getMock();
|
||||
|
||||
$listeners = array(
|
||||
$listeners = [
|
||||
'Composer\\Test\\EventDispatcher\\EventDispatcherTest::createsVendorBinFolderChecksEnvDoesNotContainsBin',
|
||||
'Composer\\Test\\EventDispatcher\\EventDispatcherTest::createsVendorBinFolderChecksEnvContainsBin',
|
||||
);
|
||||
];
|
||||
|
||||
$dispatcher->expects($this->atLeastOnce())->method('getListeners')->will($this->returnValue($listeners));
|
||||
|
||||
|
@ -320,9 +316,6 @@ class EventDispatcherTest extends TestCase
|
|||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @return void
|
||||
*/
|
||||
public static function createsVendorBinFolderChecksEnvDoesNotContainsBin(): void
|
||||
{
|
||||
mkdir(__DIR__ . '/vendor/bin', 0700, true);
|
||||
|
@ -335,9 +328,6 @@ class EventDispatcherTest extends TestCase
|
|||
self::assertStringNotContainsString(__DIR__ . DIRECTORY_SEPARATOR . 'vendor' . DIRECTORY_SEPARATOR . 'bin', $val);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return void
|
||||
*/
|
||||
public static function createsVendorBinFolderChecksEnvContainsBin(): void
|
||||
{
|
||||
$val = getenv('PATH');
|
||||
|
@ -349,9 +339,6 @@ class EventDispatcherTest extends TestCase
|
|||
self::assertStringContainsString(__DIR__ . DIRECTORY_SEPARATOR . 'vendor' . DIRECTORY_SEPARATOR . 'bin', $val);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return void
|
||||
*/
|
||||
public static function getTestEnv(): void
|
||||
{
|
||||
$val = getenv('ABC');
|
||||
|
@ -363,39 +350,39 @@ class EventDispatcherTest extends TestCase
|
|||
public function testDispatcherCanExecuteComposerScriptGroups(): void
|
||||
{
|
||||
$process = $this->getProcessExecutorMock();
|
||||
$process->expects(array(
|
||||
$process->expects([
|
||||
'echo -n foo',
|
||||
'echo -n baz',
|
||||
'echo -n bar',
|
||||
), true);
|
||||
], true);
|
||||
|
||||
$dispatcher = $this->getMockBuilder('Composer\EventDispatcher\EventDispatcher')
|
||||
->setConstructorArgs(array(
|
||||
->setConstructorArgs([
|
||||
$composer = $this->createComposerInstance(),
|
||||
$io = new BufferIO('', OutputInterface::VERBOSITY_VERBOSE),
|
||||
$process,
|
||||
))
|
||||
->onlyMethods(array(
|
||||
])
|
||||
->onlyMethods([
|
||||
'getListeners',
|
||||
))
|
||||
])
|
||||
->getMock();
|
||||
|
||||
$dispatcher->expects($this->atLeastOnce())
|
||||
->method('getListeners')
|
||||
->will($this->returnCallback(function (Event $event): array {
|
||||
->will($this->returnCallback(static function (Event $event): array {
|
||||
if ($event->getName() === 'root') {
|
||||
return array('@group');
|
||||
return ['@group'];
|
||||
}
|
||||
|
||||
if ($event->getName() === 'group') {
|
||||
return array('echo -n foo', '@subgroup', 'echo -n bar');
|
||||
return ['echo -n foo', '@subgroup', 'echo -n bar'];
|
||||
}
|
||||
|
||||
if ($event->getName() === 'subgroup') {
|
||||
return array('echo -n baz');
|
||||
return ['echo -n baz'];
|
||||
}
|
||||
|
||||
return array();
|
||||
return [];
|
||||
}));
|
||||
|
||||
$dispatcher->dispatch('root', new ScriptEvent('root', $composer, $io));
|
||||
|
@ -410,33 +397,33 @@ class EventDispatcherTest extends TestCase
|
|||
public function testRecursionInScriptsNames(): void
|
||||
{
|
||||
$process = $this->getProcessExecutorMock();
|
||||
$process->expects(array(
|
||||
$process->expects([
|
||||
'echo Hello '.ProcessExecutor::escape('World'),
|
||||
), true);
|
||||
], true);
|
||||
|
||||
$dispatcher = $this->getMockBuilder('Composer\EventDispatcher\EventDispatcher')
|
||||
->setConstructorArgs(array(
|
||||
->setConstructorArgs([
|
||||
$composer = $this->createComposerInstance(),
|
||||
$io = new BufferIO('', OutputInterface::VERBOSITY_VERBOSE),
|
||||
$process,
|
||||
))
|
||||
->onlyMethods(array(
|
||||
])
|
||||
->onlyMethods([
|
||||
'getListeners',
|
||||
))
|
||||
])
|
||||
->getMock();
|
||||
|
||||
$dispatcher->expects($this->atLeastOnce())
|
||||
->method('getListeners')
|
||||
->will($this->returnCallback(function (Event $event): array {
|
||||
->will($this->returnCallback(static function (Event $event): array {
|
||||
if ($event->getName() === 'hello') {
|
||||
return array('echo Hello');
|
||||
return ['echo Hello'];
|
||||
}
|
||||
|
||||
if ($event->getName() === 'helloWorld') {
|
||||
return array('@hello World');
|
||||
return ['@hello World'];
|
||||
}
|
||||
|
||||
return array();
|
||||
return [];
|
||||
}));
|
||||
|
||||
$dispatcher->dispatch('helloWorld', new ScriptEvent('helloWorld', $composer, $io));
|
||||
|
@ -451,28 +438,28 @@ class EventDispatcherTest extends TestCase
|
|||
self::expectException('RuntimeException');
|
||||
|
||||
$dispatcher = $this->getMockBuilder('Composer\EventDispatcher\EventDispatcher')
|
||||
->setConstructorArgs(array(
|
||||
->setConstructorArgs([
|
||||
$composer = $this->createComposerInstance(),
|
||||
$io = $this->getMockBuilder('Composer\IO\IOInterface')->getMock(),
|
||||
$this->getProcessExecutorMock(),
|
||||
))
|
||||
->onlyMethods(array(
|
||||
])
|
||||
->onlyMethods([
|
||||
'getListeners',
|
||||
))
|
||||
])
|
||||
->getMock();
|
||||
|
||||
$dispatcher->expects($this->atLeastOnce())
|
||||
->method('getListeners')
|
||||
->will($this->returnCallback(function (Event $event): array {
|
||||
->will($this->returnCallback(static function (Event $event): array {
|
||||
if ($event->getName() === 'root') {
|
||||
return array('@recurse');
|
||||
return ['@recurse'];
|
||||
}
|
||||
|
||||
if ($event->getName() === 'recurse') {
|
||||
return array('@root');
|
||||
return ['@root'];
|
||||
}
|
||||
|
||||
return array();
|
||||
return [];
|
||||
}));
|
||||
|
||||
$dispatcher->dispatch('root', new ScriptEvent('root', $composer, $io));
|
||||
|
@ -486,11 +473,11 @@ class EventDispatcherTest extends TestCase
|
|||
private function getDispatcherStubForListenersTest(array $listeners, IOInterface $io)
|
||||
{
|
||||
$dispatcher = $this->getMockBuilder('Composer\EventDispatcher\EventDispatcher')
|
||||
->setConstructorArgs(array(
|
||||
->setConstructorArgs([
|
||||
$this->createComposerInstance(),
|
||||
$io,
|
||||
))
|
||||
->onlyMethods(array('getListeners'))
|
||||
])
|
||||
->onlyMethods(['getListeners'])
|
||||
->getMock();
|
||||
|
||||
$dispatcher->expects($this->atLeastOnce())
|
||||
|
@ -502,25 +489,25 @@ class EventDispatcherTest extends TestCase
|
|||
|
||||
public function provideValidCommands(): array
|
||||
{
|
||||
return array(
|
||||
array('phpunit'),
|
||||
array('echo foo'),
|
||||
array('echo -n foo'),
|
||||
);
|
||||
return [
|
||||
['phpunit'],
|
||||
['echo foo'],
|
||||
['echo -n foo'],
|
||||
];
|
||||
}
|
||||
|
||||
public function testDispatcherOutputsCommand(): void
|
||||
{
|
||||
$dispatcher = $this->getMockBuilder('Composer\EventDispatcher\EventDispatcher')
|
||||
->setConstructorArgs(array(
|
||||
->setConstructorArgs([
|
||||
$this->createComposerInstance(),
|
||||
$io = $this->getMockBuilder('Composer\IO\IOInterface')->getMock(),
|
||||
new ProcessExecutor($io),
|
||||
))
|
||||
->onlyMethods(array('getListeners'))
|
||||
])
|
||||
->onlyMethods(['getListeners'])
|
||||
->getMock();
|
||||
|
||||
$listener = array('echo foo');
|
||||
$listener = ['echo foo'];
|
||||
$dispatcher->expects($this->atLeastOnce())
|
||||
->method('getListeners')
|
||||
->will($this->returnValue($listener));
|
||||
|
@ -539,16 +526,16 @@ class EventDispatcherTest extends TestCase
|
|||
public function testDispatcherOutputsErrorOnFailedCommand(): void
|
||||
{
|
||||
$dispatcher = $this->getMockBuilder('Composer\EventDispatcher\EventDispatcher')
|
||||
->setConstructorArgs(array(
|
||||
->setConstructorArgs([
|
||||
$this->createComposerInstance(),
|
||||
$io = $this->getMockBuilder('Composer\IO\IOInterface')->getMock(),
|
||||
new ProcessExecutor,
|
||||
))
|
||||
->onlyMethods(array('getListeners'))
|
||||
])
|
||||
->onlyMethods(['getListeners'])
|
||||
->getMock();
|
||||
|
||||
$code = 'exit 1';
|
||||
$listener = array($code);
|
||||
$listener = [$code];
|
||||
$dispatcher->expects($this->atLeastOnce())
|
||||
->method('getListeners')
|
||||
->will($this->returnValue($listener));
|
||||
|
@ -575,26 +562,23 @@ class EventDispatcherTest extends TestCase
|
|||
public function testDispatcherInstallerEvents(): void
|
||||
{
|
||||
$dispatcher = $this->getMockBuilder('Composer\EventDispatcher\EventDispatcher')
|
||||
->setConstructorArgs(array(
|
||||
->setConstructorArgs([
|
||||
$this->createComposerInstance(),
|
||||
$this->getMockBuilder('Composer\IO\IOInterface')->getMock(),
|
||||
$this->getProcessExecutorMock(),
|
||||
))
|
||||
->onlyMethods(array('getListeners'))
|
||||
])
|
||||
->onlyMethods(['getListeners'])
|
||||
->getMock();
|
||||
|
||||
$dispatcher->expects($this->atLeastOnce())
|
||||
->method('getListeners')
|
||||
->will($this->returnValue(array()));
|
||||
->will($this->returnValue([]));
|
||||
|
||||
$transaction = $this->getMockBuilder('Composer\DependencyResolver\LockTransaction')->disableOriginalConstructor()->getMock();
|
||||
|
||||
$dispatcher->dispatchInstallerEvent(InstallerEvents::PRE_OPERATIONS_EXEC, true, true, $transaction);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return void
|
||||
*/
|
||||
public static function call(): void
|
||||
{
|
||||
throw new \RuntimeException();
|
||||
|
@ -616,9 +600,6 @@ class EventDispatcherTest extends TestCase
|
|||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return Composer
|
||||
*/
|
||||
private function createComposerInstance(): Composer
|
||||
{
|
||||
$composer = new Composer;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue