Refactor command line utilities

This commit is contained in:
Romain Neutron
2013-07-16 16:01:17 +02:00
parent 86e108b20f
commit 056ac28120
59 changed files with 1031 additions and 592 deletions

View File

@@ -19,57 +19,57 @@ class AddPluginTest extends PluginCommandTestCase
$output = $this->getMock('Symfony\Component\Console\Output\OutputInterface');
$command = new AddPlugin();
$command->setContainer(self::$DI['app']);
$command->setContainer(self::$DI['cli']);
$manifest = $this->createManifestMock();
$manifest->expects($this->any())
->method('getName')
->will($this->returnValue($source));
self::$DI['app']['temporary-filesystem'] = $this->createTemporaryFilesystemMock();
self::$DI['app']['plugins.autoloader-generator'] = $this->createPluginsAutoloaderGeneratorMock();
self::$DI['app']['plugins.explorer'] = array(self::$DI['app']['plugins.directory'].'/TestPlugin');
self::$DI['app']['plugins.plugins-validator'] = $this->createPluginsValidatorMock();
self::$DI['app']['filesystem'] = $this->createFilesystemMock();
self::$DI['app']['plugins.composer-installer'] = $this->createComposerInstallerMock();
self::$DI['app']['plugins.importer'] = $this->createPluginsImporterMock();
self::$DI['cli']['temporary-filesystem'] = $this->createTemporaryFilesystemMock();
self::$DI['cli']['plugins.autoloader-generator'] = $this->createPluginsAutoloaderGeneratorMock();
self::$DI['cli']['plugins.explorer'] = array(self::$DI['cli']['plugins.directory'].'/TestPlugin');
self::$DI['cli']['plugins.plugins-validator'] = $this->createPluginsValidatorMock();
self::$DI['cli']['filesystem'] = $this->createFilesystemMock();
self::$DI['cli']['plugins.composer-installer'] = $this->createComposerInstallerMock();
self::$DI['cli']['plugins.importer'] = $this->createPluginsImporterMock();
self::$DI['app']['temporary-filesystem']->expects($this->once())
self::$DI['cli']['temporary-filesystem']->expects($this->once())
->method('createTemporaryDirectory')
->will($this->returnValue('tempdir'));
self::$DI['app']['plugins.importer']->expects($this->once())
self::$DI['cli']['plugins.importer']->expects($this->once())
->method('import')
->with($source, 'tempdir');
// the plugin is checked when updating config files
self::$DI['app']['plugins.plugins-validator']->expects($this->at(0))
self::$DI['cli']['plugins.plugins-validator']->expects($this->at(0))
->method('validatePlugin')
->with('tempdir')
->will($this->returnValue($manifest));
self::$DI['app']['plugins.plugins-validator']->expects($this->at(1))
self::$DI['cli']['plugins.plugins-validator']->expects($this->at(1))
->method('validatePlugin')
->with(self::$DI['app']['plugins.directory'].'/TestPlugin')
->with(self::$DI['cli']['plugins.directory'].'/TestPlugin')
->will($this->returnValue($manifest));
self::$DI['app']['plugins.composer-installer']->expects($this->once())
self::$DI['cli']['plugins.composer-installer']->expects($this->once())
->method('install')
->with('tempdir');
self::$DI['app']['filesystem']->expects($this->at(0))
self::$DI['cli']['filesystem']->expects($this->at(0))
->method('mirror')
->with('tempdir', self::$DI['app']['plugins.directory'].'/TestPlugin');
->with('tempdir', self::$DI['cli']['plugins.directory'].'/TestPlugin');
self::$DI['app']['filesystem']->expects($this->at(1))
self::$DI['cli']['filesystem']->expects($this->at(1))
->method('mirror')
->with(self::$DI['app']['plugins.directory'].'/TestPlugin/public', self::$DI['app']['root.path'].'/www/plugins/TestPlugin');
->with(self::$DI['cli']['plugins.directory'].'/TestPlugin/public', self::$DI['cli']['root.path'].'/www/plugins/TestPlugin');
self::$DI['app']['filesystem']->expects($this->at(2))
self::$DI['cli']['filesystem']->expects($this->at(2))
->method('remove')
->with('tempdir');
self::$DI['app']['plugins.autoloader-generator']->expects($this->once())
self::$DI['cli']['plugins.autoloader-generator']->expects($this->once())
->method('write')
->with(array($manifest));