当前位置: 首页>>代码示例>>PHP>>正文


PHP ArrayRepository::addPackage方法代码示例

本文整理汇总了PHP中Composer\Repository\ArrayRepository::addPackage方法的典型用法代码示例。如果您正苦于以下问题:PHP ArrayRepository::addPackage方法的具体用法?PHP ArrayRepository::addPackage怎么用?PHP ArrayRepository::addPackage使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Composer\Repository\ArrayRepository的用法示例。


在下文中一共展示了ArrayRepository::addPackage方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: testPrettyString

 public function testPrettyString()
 {
     $repo = new ArrayRepository();
     $repo->addPackage($p1 = $this->getPackage('foo', '2.1'));
     $repo->addPackage($p2 = $this->getPackage('baz', '1.1'));
     $this->pool->addRepository($repo);
     $rule = new Rule(array($p1->getId(), -$p2->getId()), 'job1', null);
     $this->assertEquals('(don\'t install baz 1.1|install foo 2.1)', $rule->getPrettyString($this->pool));
 }
开发者ID:alancleaver,项目名称:composer,代码行数:9,代码来源:RuleTest.php

示例2: testGetMaxId

 public function testGetMaxId()
 {
     $pool = new Pool();
     $repository = new ArrayRepository();
     $firstPackage = $this->getPackage('foo', '1');
     $secondPackage = $this->getPackage('foo1', '1');
     $this->assertEquals(0, $pool->getMaxId());
     $repository->addPackage($firstPackage);
     $repository->addPackage($secondPackage);
     $pool->addRepository($repository);
     $this->assertEquals(2, $pool->getMaxId());
 }
开发者ID:natxet,项目名称:composer,代码行数:12,代码来源:PoolTest.php

示例3: testSearchWithPackageType

 public function testSearchWithPackageType()
 {
     $repo = new ArrayRepository();
     $repo->addPackage($this->getPackage('foo', '1', 'Composer\\Package\\CompletePackage'));
     $repo->addPackage($this->getPackage('bar', '1', 'Composer\\Package\\CompletePackage'));
     $package = $this->getPackage('foobar', '1', 'Composer\\Package\\CompletePackage');
     $package->setType('composer-plugin');
     $repo->addPackage($package);
     $this->assertSame(array(array('name' => 'foo', 'description' => null)), $repo->search('foo', RepositoryInterface::SEARCH_FULLTEXT, 'library'));
     $this->assertEmpty($repo->search('bar', RepositoryInterface::SEARCH_FULLTEXT, 'package'));
     $this->assertSame(array(array('name' => 'foobar', 'description' => null)), $repo->search('foo', 0, 'composer-plugin'));
 }
开发者ID:neon64,项目名称:composer,代码行数:12,代码来源:ArrayRepositoryTest.php

示例4: testFindPackagesByName

 public function testFindPackagesByName()
 {
     $repo = new ArrayRepository();
     $repo->addPackage($this->getPackage('foo', '1'));
     $repo->addPackage($this->getPackage('bar', '2'));
     $repo->addPackage($this->getPackage('bar', '3'));
     $foo = $repo->findPackagesByName('foo');
     $this->assertCount(1, $foo);
     $this->assertEquals('foo', $foo[0]->getName());
     $bar = $repo->findPackagesByName('bar');
     $this->assertCount(2, $bar);
     $this->assertEquals('bar', $bar[0]->getName());
 }
开发者ID:natxet,项目名称:composer,代码行数:13,代码来源:ArrayRepositoryTest.php

示例5: initialize

 protected function initialize()
 {
     parent::initialize();
     $versionParser = new VersionParser();
     try {
         $prettyVersion = PHP_VERSION;
         $version = $versionParser->normalize($prettyVersion);
     } catch (\UnexpectedValueException $e) {
         $prettyVersion = preg_replace('#^(.+?)(-.+)?$#', '$1', PHP_VERSION);
         $version = $versionParser->normalize($prettyVersion);
     }
     $php = new MemoryPackage('php', $version, $prettyVersion);
     $php->setDescription('The PHP interpreter');
     parent::addPackage($php);
     foreach (get_loaded_extensions() as $name) {
         if (in_array($name, array('standard', 'Core'))) {
             continue;
         }
         $reflExt = new \ReflectionExtension($name);
         try {
             $prettyVersion = $reflExt->getVersion();
             $version = $versionParser->normalize($prettyVersion);
         } catch (\UnexpectedValueException $e) {
             $prettyVersion = '0';
             $version = $versionParser->normalize($prettyVersion);
         }
         $ext = new MemoryPackage('ext-' . $name, $version, $prettyVersion);
         $ext->setDescription('The ' . $name . ' PHP extension');
         parent::addPackage($ext);
     }
 }
开发者ID:nlegoff,项目名称:composer,代码行数:31,代码来源:PlatformRepository.php

示例6: testRequestInstallAndRemove

 public function testRequestInstallAndRemove()
 {
     $pool = new Pool();
     $repo = new ArrayRepository();
     $foo = $this->getPackage('foo', '1');
     $bar = $this->getPackage('bar', '1');
     $foobar = $this->getPackage('foobar', '1');
     $repo->addPackage($foo);
     $repo->addPackage($bar);
     $repo->addPackage($foobar);
     $pool->addRepository($repo);
     $request = new Request($pool);
     $request->install('foo');
     $request->install('bar');
     $request->remove('foobar');
     $this->assertEquals(array(array('packages' => array($foo), 'cmd' => 'install', 'packageName' => 'foo'), array('packages' => array($bar), 'cmd' => 'install', 'packageName' => 'bar'), array('packages' => array($foobar), 'cmd' => 'remove', 'packageName' => 'foobar')), $request->getJobs());
 }
开发者ID:natxet,项目名称:composer,代码行数:17,代码来源:RequestTest.php

示例7: testToString

 public function testToString()
 {
     $repo = new ArrayRepository();
     $repo->addPackage($p1 = $this->getPackage('foo', '2.1'));
     $repo->addPackage($p2 = $this->getPackage('baz', '1.1'));
     $this->pool->addRepository($repo);
     $rule = new Rule($this->pool, array($p1->getId(), -$p2->getId()), 'job1', null);
     $this->assertEquals('(-baz-1.1.0.0|+foo-2.1.0.0)', $rule->__toString());
 }
开发者ID:shabbirvividads,项目名称:magento2,代码行数:9,代码来源:RuleTest.php

示例8: testAutomaticallyAddAliasedPackage

 public function testAutomaticallyAddAliasedPackage()
 {
     $repo = new ArrayRepository();
     $package = $this->getPackage('foo', '1');
     $alias = $this->getAliasPackage($package, '2');
     $repo->addPackage($alias);
     $this->assertEquals(2, count($repo));
     $this->assertTrue($repo->hasPackage($this->getPackage('foo', '1')));
     $this->assertTrue($repo->hasPackage($this->getPackage('foo', '2')));
 }
开发者ID:ilosada,项目名称:chamilo-lms-icpna,代码行数:10,代码来源:ArrayRepositoryTest.php

示例9: dataGetPackages

 /**
  * @return array
  */
 public function dataGetPackages()
 {
     $emptyRepo = new ArrayRepository();
     $vendorRepo = new ArrayRepository();
     $vendorRepo2 = new ArrayRepository();
     $package = new Package('vendor/name', '1.0.0.0', '1.0');
     $package2 = new Package('vendor2/name', '1.0.0.0', '1.0');
     $package3 = new Package('vendor2/name2', '1.0.0.0', '1.0');
     $vendorRepo->addPackage($package);
     $vendorRepo2->addPackage($package2);
     $vendorRepo2->addPackage($package3);
     $data = [];
     $data['empty repository'] = [[], [], $emptyRepo];
     $data['empty repository with filter'] = [[], ['vendor/name'], $emptyRepo];
     $data['repository with one package'] = [[$package], [], $vendorRepo];
     $data['repository with one package and filter'] = [[], ['othervendor/othername'], $vendorRepo];
     $data['repository with two packages'] = [[$package2, $package3], [], $vendorRepo2];
     $data['repository with two packages and filter'] = [[$package2], ['vendor2/name'], $vendorRepo2];
     return $data;
 }
开发者ID:composer,项目名称:satis,代码行数:23,代码来源:PackageSelectionTest.php

示例10: dataGetPackages

 public function dataGetPackages()
 {
     $emptyRepo = new ArrayRepository();
     $vendorRepo = new ArrayRepository();
     $vendorRepo2 = new ArrayRepository();
     $package = new Package('vendor/name', '1.0.0.0', '1.0');
     $package2 = new Package('vendor2/name', '1.0.0.0', '1.0');
     $package3 = new Package('vendor2/name2', '1.0.0.0', '1.0');
     $vendorRepo->addPackage($package);
     $vendorRepo2->addPackage($package2);
     $vendorRepo2->addPackage($package3);
     $data = array();
     $data['empty repository'] = array(array(), array(), $emptyRepo);
     $data['empty repository with filter'] = array(array(), array('vendor/name'), $emptyRepo);
     $data['repository with one package'] = array(array($package), array(), $vendorRepo);
     $data['repository with one package and filter'] = array(array(), array('othervendor/othername'), $vendorRepo);
     $data['repository with two packages'] = array(array($package2, $package3), array(), $vendorRepo2);
     $data['repository with two packages and filter'] = array(array($package2), array('vendor2/name'), $vendorRepo2);
     return $data;
 }
开发者ID:robertgit,项目名称:satis,代码行数:20,代码来源:PackageSelectionTest.php

示例11: testRequestInstallSamePackageFromDifferentRepositories

 public function testRequestInstallSamePackageFromDifferentRepositories()
 {
     $repo1 = new ArrayRepository();
     $repo2 = new ArrayRepository();
     $foo1 = $this->getPackage('foo', '1');
     $foo2 = $this->getPackage('foo', '1');
     $repo1->addPackage($foo1);
     $repo2->addPackage($foo2);
     $request = new Request();
     $request->install('foo', $constraint = $this->getVersionConstraint('=', '1'));
     $this->assertEquals(array(array('cmd' => 'install', 'packageName' => 'foo', 'constraint' => $constraint, 'fixed' => false)), $request->getJobs());
 }
开发者ID:alancleaver,项目名称:composer,代码行数:12,代码来源:RequestTest.php

示例12: testSolverInstallSamePackageFromDifferentRepositories

 public function testSolverInstallSamePackageFromDifferentRepositories()
 {
     $repo1 = new ArrayRepository();
     $repo2 = new ArrayRepository();
     $repo1->addPackage($foo1 = $this->getPackage('foo', '1'));
     $repo2->addPackage($foo2 = $this->getPackage('foo', '1'));
     $this->pool->addRepository($this->repoInstalled);
     $this->pool->addRepository($repo1);
     $this->pool->addRepository($repo2);
     $this->request->install('foo');
     $this->checkSolverResult(array(array('job' => 'install', 'package' => $foo1)));
 }
开发者ID:nicodmf,项目名称:composer,代码行数:12,代码来源:SolverTest.php

示例13: testSelectLowest

    public function testSelectLowest()
    {
        $policy = new DefaultPolicy(false, true);

        $this->repo->addPackage($packageA1 = $this->getPackage('A', '1.0'));
        $this->repo->addPackage($packageA2 = $this->getPackage('A', '2.0'));
        $this->pool->addRepository($this->repo);

        $literals = array($packageA1->getId(), $packageA2->getId());
        $expected = array($packageA1->getId());

        $selected = $policy->selectPreferredPackages($this->pool, array(), $literals);

        $this->assertSame($expected, $selected);
    }
开发者ID:Rudloff,项目名称:composer,代码行数:15,代码来源:DefaultPolicyTest.php

示例14: Construct

 public static function Construct(IOInterface $io)
 {
     $repo = new ArrayRepository();
     try {
         $web_folder = Locator::getWebFolderPath();
         $version_file = $web_folder . '/intranet/setup/_init/version.txt';
         if (!file_exists($version_file)) {
             throw new \Exception("No version.txt for core found - assuming framework is not installed");
         }
         $version_data = file($version_file);
         $core_version = $version_data[1];
         $normalizer = new VersionParser();
         $core_version_normalized = $normalizer->normalize($core_version);
         $io->write("Detected core version {$core_version} ({$core_version_normalized})");
         $core_package = new Package(FrameworkInstallerV8::PACKAGE_NAME, $core_version_normalized, $core_version);
         $repo->addPackage($core_package);
     } catch (\Exception $e) {
         $io->write($e->getMessage());
         // if can't determine location of 'web' folder, not adding the core package therefore letting
         // composer install it
     }
     return $repo;
 }
开发者ID:claromentis,项目名称:installer-composer-plugin,代码行数:23,代码来源:FrameworkInstalledRepository.php

示例15: getLockedRepository

 public function getLockedRepository($withDevReqs = false)
 {
     $lockData = $this->getLockData();
     $packages = new ArrayRepository();
     $lockedPackages = $lockData['packages'];
     if ($withDevReqs) {
         if (isset($lockData['packages-dev'])) {
             $lockedPackages = array_merge($lockedPackages, $lockData['packages-dev']);
         } else {
             throw new \RuntimeException('The lock file does not contain require-dev information, run install with the --no-dev option or run update to install those packages.');
         }
     }
     if (empty($lockedPackages)) {
         return $packages;
     }
     if (isset($lockedPackages[0]['name'])) {
         foreach ($lockedPackages as $info) {
             $packages->addPackage($this->loader->load($info));
         }
         return $packages;
     }
     throw new \RuntimeException('Your composer.lock was created before 2012-09-15, and is not supported anymore. Run "composer update" to generate a new one.');
 }
开发者ID:VicDeo,项目名称:poc,代码行数:23,代码来源:Locker.php


注:本文中的Composer\Repository\ArrayRepository::addPackage方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。