本文整理汇总了PHP中Composer\Composer::setPackage方法的典型用法代码示例。如果您正苦于以下问题:PHP Composer::setPackage方法的具体用法?PHP Composer::setPackage怎么用?PHP Composer::setPackage使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Composer\Composer
的用法示例。
在下文中一共展示了Composer::setPackage方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: run
/**
* Runs the project configurator.
*
* @return void
*/
public function run()
{
$namespace = $this->ask('Namespace', function ($namespace) {
return $this->validateNamespace($namespace);
}, 'App');
$packageName = $this->ask('Package name', function ($packageName) {
return $this->validatePackageName($packageName);
}, $this->suggestPackageName($namespace));
$license = $this->ask('License', function ($license) {
return trim($license);
}, 'proprietary');
$description = $this->ask('Description', function ($description) {
return trim($description);
}, '');
$file = new JsonFile('./composer.json');
$config = $file->read();
$config['name'] = $packageName;
$config['license'] = $license;
$config['description'] = $description;
$config['autoload']['psr-4'] = [$namespace . '\\' => 'src/'];
$config['autoload-dev']['psr-4'] = [$namespace . '\\Tests\\' => 'tests/'];
unset($config['scripts']['post-root-package-install']);
$config['extra']['branch-alias']['dev-master'] = '1.0-dev';
$file->write($config);
$this->composer->setPackage(Factory::create($this->io, null, true)->getPackage());
// reload root package
$filesystem = new Filesystem();
$filesystem->removeDirectory('./app/Distribution');
}
示例2: setUp
/**
* {@inheritdoc}
*/
protected function setUp()
{
$this->io = new BufferIO();
$this->composer = new Composer();
$this->composer->setPackage(new RootPackage('my/project', '1.0.0', '1.0.0'));
$this->composer->setPluginManager(new PluginManager($this->io, $this->composer));
$this->composer->setEventDispatcher(new EventDispatcher($this->composer, $this->io));
}
示例3: setUp
public function setUp()
{
$this->plugin = $this->getMock('\\ContaoCommunityAlliance\\Composer\\Plugin\\Plugin');
$this->plugin->expects($this->any())->method('getContaoRoot')->will($this->returnValue('CONTAO_ROOT'));
$package = new RootPackage('test/me', '0.8.15', '0.8.15.0');
$package->setType(AbstractInstaller::MODULE_TYPE);
$this->composer = new Composer();
$this->composer->setConfig(new Config());
$this->composer->setPackage($package);
$this->installerStub = $this->getMockForAbstractClass('\\ContaoCommunityAlliance\\Composer\\Plugin\\AbstractInstaller', array(new NullIO(), $this->composer, $this->plugin));
}
示例4: setUp
/**
* {@inheritdoc}
*/
protected function setUp()
{
$this->localConfigPath = realpath(__DIR__ . '/../fixtures/local');
$this->globalConfigPath = realpath(__DIR__ . '/../fixtures/home');
$this->config = new Config(false, $this->localConfigPath);
$this->config->merge(['config' => ['home' => $this->globalConfigPath]]);
$package = new RootPackage('my/project', '1.0.0', '1.0.0');
$package->setExtra(['my-local-config' => ['foo' => 'bar']]);
$this->composer = new Composer();
$this->composer->setConfig($this->config);
$this->composer->setPackage($package);
$this->SUT = new ConfigLocator($this->composer);
}
示例5: setUp
/**
* {@inheritdoc}
*/
protected function setUp()
{
$this->tempDir = __DIR__ . '/temp';
$this->config = new Config(false, realpath(__DIR__ . '/fixtures/local'));
$this->config->merge(['config' => ['home' => __DIR__]]);
$this->io = new BufferIO();
$this->composer = new Composer();
$this->composer->setConfig($this->config);
$this->composer->setPackage(new RootPackage('my/project', '1.0.0', '1.0.0'));
$this->composer->setPluginManager(new PluginManager($this->io, $this->composer));
$this->composer->setEventDispatcher(new EventDispatcher($this->composer, $this->io));
self::cleanTempDir();
mkdir($this->tempDir);
}
示例6: setUp
/**
* @inheritdoc
*/
protected function setUp()
{
parent::setUp();
$this->composer = new Composer();
$config = new Config();
$this->composer->setConfig($config);
/** @var RootPackageInterface|\PHPUnit_Framework_MockObject_MockObject $package */
$package = $this->getMock('Composer\\Package\\RootPackageInterface');
$package->expects($this->any())->method('getExtra')->willReturn(array(SharedPackageInstaller::PACKAGE_TYPE => array('vendor-dir' => sys_get_temp_dir() . '/composer-test-vendor-shared')));
$this->composer->setPackage($package);
$this->im = $this->getMock('Composer\\Installer\\InstallationManager');
$this->composer->setInstallationManager($this->im);
$this->io = $this->getMock('Composer\\IO\\IOInterface');
}
示例7: setUp
protected function setUp()
{
$this->tempDir = TestUtil::makeTempDir('puli-composer-plugin', __CLASS__);
$filesystem = new Filesystem();
$filesystem->mirror(__DIR__ . '/Fixtures/root', $this->tempDir);
$this->io = $this->getMock('Composer\\IO\\IOInterface');
$this->config = new Config(false, $this->tempDir);
$this->config->merge(array('config' => array('vendor-dir' => 'the-vendor')));
$this->installationManager = $this->getMockBuilder('Composer\\Installer\\InstallationManager')->disableOriginalConstructor()->getMock();
$this->installationManager->expects($this->any())->method('getInstallPath')->will($this->returnCallback(array($this, 'getInstallPath')));
$this->rootPackage = new RootPackage('vendor/root', '1.0', '1.0');
$this->rootPackage->setRequires(array('vendor/package1' => new Link('vendor/root', 'vendor/package1'), 'vendor/package2' => new Link('vendor/root', 'vendor/package2')));
$this->localRepository = new TestLocalRepository(array(new Package('vendor/package1', '1.0', '1.0'), new Package('vendor/package2', '1.0', '1.0')));
$this->repositoryManager = new RepositoryManager($this->io, $this->config);
$this->repositoryManager->setLocalRepository($this->localRepository);
$this->installPaths = array();
$this->composer = new Composer();
$this->composer->setRepositoryManager($this->repositoryManager);
$this->composer->setInstallationManager($this->installationManager);
$this->composer->setConfig($this->config);
$this->composer->setPackage($this->rootPackage);
$this->puliRunner = $this->getMockBuilder('Puli\\ComposerPlugin\\PuliRunner')->disableOriginalConstructor()->getMock();
$this->previousWd = getcwd();
chdir($this->tempDir);
$this->plugin = new PuliPlugin($this->puliRunner);
}
示例8: setUp
protected function setUp()
{
while (false === mkdir($this->tempDir = sys_get_temp_dir() . '/puli-plugin/PuliPluginTest_root' . rand(10000, 99999), 0777, true)) {
}
$filesystem = new Filesystem();
$filesystem->mirror(__DIR__ . '/Fixtures/root', $this->tempDir);
$this->io = $this->getMock('Composer\\IO\\IOInterface');
$this->config = new Config(false, $this->tempDir);
$this->config->merge(array('config' => array('vendor-dir' => 'the-vendor')));
$this->installationManager = $this->getMockBuilder('Composer\\Installer\\InstallationManager')->disableOriginalConstructor()->getMock();
$this->installationManager->expects($this->any())->method('getInstallPath')->will($this->returnCallback(array($this, 'getInstallPath')));
$this->rootPackage = new RootPackage('vendor/root', '1.0', '1.0');
$this->localRepository = new TestLocalRepository(array(new Package('vendor/package1', '1.0', '1.0'), new Package('vendor/package2', '1.0', '1.0')));
$this->repositoryManager = new RepositoryManager($this->io, $this->config);
$this->repositoryManager->setLocalRepository($this->localRepository);
$this->installPaths = array();
$this->composer = new Composer();
$this->composer->setRepositoryManager($this->repositoryManager);
$this->composer->setInstallationManager($this->installationManager);
$this->composer->setConfig($this->config);
$this->composer->setPackage($this->rootPackage);
$this->puliRunner = $this->getMockBuilder('Puli\\ComposerPlugin\\PuliRunner')->disableOriginalConstructor()->getMock();
$this->previousWd = getcwd();
chdir($this->tempDir);
$this->plugin = new PuliPlugin($this->puliRunner);
}
示例9: setUp
/**
* @inheritdoc
*/
protected function setUp()
{
parent::setUp();
$this->fs = new SymlinkFilesystem();
$this->composer = new Composer();
$composerConfig = new Config();
$this->composer->setConfig($composerConfig);
$this->im = $this->getMock('Composer\\Installer\\InstallationManager');
$this->composer->setInstallationManager($this->im);
$this->vendorDir = realpath(sys_get_temp_dir()) . DIRECTORY_SEPARATOR . 'composer-test-vendor';
$this->ensureDirectoryExistsAndClear($this->vendorDir);
$this->binDir = realpath(sys_get_temp_dir()) . DIRECTORY_SEPARATOR . 'composer-test-bin';
$this->ensureDirectoryExistsAndClear($this->binDir);
$this->dependenciesDir = realpath(sys_get_temp_dir()) . DIRECTORY_SEPARATOR . 'composer-test-dependencies';
$this->ensureDirectoryExistsAndClear($this->dependenciesDir);
$this->symlinkDir = realpath(sys_get_temp_dir()) . DIRECTORY_SEPARATOR . 'composer-test-vendor-shared';
$composerConfig->merge(array('config' => array('vendor-dir' => $this->vendorDir, 'bin-dir' => $this->binDir)));
$this->dm = $this->getMockBuilder('Composer\\Downloader\\DownloadManager')->disableOriginalConstructor()->getMock();
$this->composer->setDownloadManager($this->dm);
$extraConfig = array(SharedPackageInstaller::PACKAGE_TYPE => array('vendor-dir' => $this->dependenciesDir, 'symlink-dir' => $this->symlinkDir));
/** @var RootPackage|\PHPUnit_Framework_MockObject_MockObject $package */
$package = $this->getMock('Composer\\Package\\RootPackageInterface');
$package->expects($this->any())->method('getExtra')->willReturn($extraConfig);
$this->composer->setPackage($package);
$this->repository = $this->getMock('Composer\\Repository\\InstalledRepositoryInterface');
$this->io = $this->getMock('Composer\\IO\\IOInterface');
$this->dataManager = $this->getMockBuilder('LEtudiant\\Composer\\Data\\Package\\SharedPackageDataManager')->disableOriginalConstructor()->getMock();
$vendorDirParams = explode(DIRECTORY_SEPARATOR, $this->vendorDir);
$this->config = new SharedPackageInstallerConfig(end($vendorDirParams), $this->vendorDir, $extraConfig);
}
示例10: testInstall
public function testInstall()
{
/* @var RootPackageInterface $rootPackage */
$rootPackage = $this->createRootPackageMock();
/* @var IOInterface $io */
$io = $this->io;
/* @var AssetTypeInterface $type */
$type = $this->type;
$vendorDir = realpath(sys_get_temp_dir()) . DIRECTORY_SEPARATOR . 'composer-test' . DIRECTORY_SEPARATOR . 'vendor';
$this->composer->setPackage($rootPackage);
$dm = $this->getMockBuilder('Composer\\Downloader\\DownloadManager')->disableOriginalConstructor()->getMock();
$this->composer->expects($this->any())->method('getDownloadManager')->will($this->returnValue($dm));
$library = new AssetInstaller($io, $this->composer, $type);
/* @var \PHPUnit_Framework_MockObject_MockObject $package */
$package = $this->createPackageMock('foo-asset/package');
/* @var PackageInterface $package */
$packageDir = $vendorDir . '/' . $package->getPrettyName();
$dm->expects($this->once())->method('download')->with($package, $vendorDir . DIRECTORY_SEPARATOR . 'foo-asset/package');
$repository = $this->getMock('Composer\\Repository\\InstalledRepositoryInterface');
$repository->expects($this->once())->method('addPackage')->with($package);
/* @var InstalledRepositoryInterface $repository */
$library->install($repository, $package);
$this->assertFileExists($vendorDir, 'Vendor dir should be created');
$this->ensureDirectoryExistsAndClear($packageDir);
}
示例11: setUp
/**
* @inheritdoc
*/
protected function setUp()
{
parent::setUp();
$this->vendorDir = sys_get_temp_dir() . '/composer-test-vendor-shared';
if (!is_dir($this->vendorDir)) {
if (!mkdir($this->vendorDir)) {
throw new \RuntimeException('Cannot create the temporary vendor dir');
}
} else {
$this->clearPackageData();
}
$this->composer = new Composer();
/** @var RootPackageInterface|\PHPUnit_Framework_MockObject_MockObject $rootPackage */
$this->rootPackage = $this->getMock('Composer\\Package\\RootPackageInterface');
$this->composer->setPackage($this->rootPackage);
}
示例12: testGetInstallPathWithTargetDir
public function testGetInstallPathWithTargetDir()
{
/* @var RootPackageInterface $rootPackage */
$rootPackage = $this->createRootPackageMock();
/* @var IOInterface $io */
$io = $this->io;
/* @var AssetTypeInterface $type */
$type = $this->type;
$this->composer->setPackage($rootPackage);
$library = new BowerInstaller($io, $this->composer, $type);
$package = $this->createPackageMock();
/* @var \PHPUnit_Framework_MockObject_MockObject $package */
$package
->expects($this->once())
->method('getTargetDir')
->will($this->returnValue('Some/Namespace'));
$package
->expects($this->any())
->method('getPrettyName')
->will($this->returnValue('foo-asset/bar'));
/* @var PackageInterface $package */
$exceptDir = $this->vendorDir.'/'.$package->getPrettyName().'/Some/Namespace';
$exceptDir = str_replace('\\', '/', $exceptDir);
$packageDir = $library->getInstallPath($package);
$packageDir = str_replace('\\', '/', $packageDir);
$this->assertEquals($exceptDir, $packageDir);
}
示例13: testSetGetPackage
public function testSetGetPackage()
{
$composer = new Composer();
$package = $this->getMock('Composer\\Package\\RootPackageInterface');
$composer->setPackage($package);
$this->assertSame($package, $composer->getPackage());
}
示例14: testGetInstallPathDoesNotReturnPathFromUnrelatedPackageThatIsConfiguredInRootPackage
/**
* Ensures that the installer does not use paths for other packages, which are configured
* in the root package.
*/
public function testGetInstallPathDoesNotReturnPathFromUnrelatedPackageThatIsConfiguredInRootPackage()
{
$options = array('installer-paths' => array('unrelated/package' => 'another/path'));
$rootPackage = $this->createRootPackage($options);
$this->composer->setPackage($rootPackage);
$package = $this->createPackage('installer/test', array('install-path' => 'public/asset'));
$this->assertNotEquals('another/path', $this->installer->getInstallPath($package));
}
示例15: setUp
/**
* Setup.
*/
protected function setUp()
{
parent::setUp();
$this->vendorDir = realpath(sys_get_temp_dir()) . DIRECTORY_SEPARATOR . 'composer-test-vendor';
$this->ensureDirectoryExistsAndClear($this->vendorDir);
$this->composer = new \Composer\Composer();
$config = new \Composer\Config();
$this->composer->setConfig($config);
/** @var \Composer\Package\RootPackageInterface|\PHPUnit_Framework_MockObject_MockObject $package */
$package = $this->getMock('Composer\\Package\\RootPackageInterface');
$package->expects($this->any())->method('getExtra')->willReturn(array(PhpCodesnifferStandardInstaller::PACKAGE_TYPE => array('vendor-dir' => $this->vendorDir)));
$config->merge(array('config' => array('vendor-dir' => $this->vendorDir)));
$this->composer->setPackage($package);
$this->im = $this->getMock('Composer\\Installer\\InstallationManager');
$this->composer->setInstallationManager($this->im);
$this->io = $this->getMock('Composer\\IO\\IOInterface');
}