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


PHP Package::setRequires方法代码示例

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


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

示例1: testPackageNotExists

 public function testPackageNotExists()
 {
     $io = new NullIO();
     $pkg = new Package('test/test', 1, 1);
     $pkg->setRequires([]);
     $pkg->setDevRequires([]);
     $this->assertFalse(Setup::checkDependencies($io, $pkg));
 }
开发者ID:wecodemore,项目名称:wp-cli-composer,代码行数:8,代码来源:Test.php

示例2: testGetRequires

 public function testGetRequires()
 {
     $package = new Package('hostnet/foo', 1.0, 1.0);
     $content = self::createMock('Hostnet\\Component\\EntityPlugin\\PackageContentInterface');
     $entity_package = new EntityPackage($package, $content, $content);
     $this->assertEquals([], $entity_package->getRequires());
     $link = new Link('hostnet/a', 'hostnet/foo');
     $package->setRequires([$link]);
     $this->assertSame([$link], $entity_package->getRequires());
 }
开发者ID:hostnet,项目名称:entity-plugin-lib,代码行数:10,代码来源:EntityPackageTest.php

示例3: addsDependenciesProvider

 public function addsDependenciesProvider()
 {
     $requires_external = new Package('hostnet/requires-external', 1, 1);
     $requires_external->setRequires([new Link('hostnet/requires-external', 'hostnet/not-linked')]);
     $foo = new Package('hostnet/foo', 1, 1);
     $bar = new Package('hostnet/bar', 1, 1);
     $foobar = new Package('hostnet/foobar', 1, 1);
     $bar->setRequires([new Link('hostnet/bar', 'hostnet/foo')]);
     $foo->setSuggests(['hostnet/foobar' => 'Very useless text...']);
     return [[[]], [[$requires_external]], [[$foo], ['hostnet/foo' => []], ['hostnet/foo' => []]], [[$foo, $bar, $foobar], ['hostnet/foo' => [$foobar], 'hostnet/bar' => [$foo]], ['hostnet/foo' => [$bar], 'hostnet/bar' => []]]];
 }
开发者ID:hostnet,项目名称:entity-plugin-lib,代码行数:11,代码来源:EntityPackageBuilderTest.php

示例4: dataGetRequired

 /**
  * @return array
  */
 public function dataGetRequired()
 {
     $package = new Package('vendor/name', '1.0.0.0', '1.0');
     $link = new Link('test', 'name');
     $devLink = new Link('devTest', 'name');
     $package->setRequires([$link]);
     $package->setDevRequires([$devLink]);
     $data = [];
     $data['both require false'] = [[], $package, false, false];
     $data['require true'] = [[$link], $package, true, false];
     $data['requireDev true'] = [[$devLink], $package, false, true];
     $data['both require true'] = [[$link, $devLink], $package, true, true];
     return $data;
 }
开发者ID:composer,项目名称:satis,代码行数:17,代码来源:PackageSelectionTest.php

示例5: dataGetRequired

 public function dataGetRequired()
 {
     $package = new Package('vendor/name', '1.0.0.0', '1.0');
     $link = new Link('test', 'name');
     $devLink = new Link('devTest', 'name');
     $package->setRequires(array($link));
     $package->setDevRequires(array($devLink));
     $data = array();
     $data['both require false'] = array(array(), $package, false, false);
     $data['require true'] = array(array($link), $package, true, false);
     $data['requireDev true'] = array(array($devLink), $package, false, true);
     $data['both require true'] = array(array($link, $devLink), $package, true, true);
     return $data;
 }
开发者ID:robertgit,项目名称:satis,代码行数:14,代码来源:PackageSelectionTest.php

示例6: testOverrideVendorsAutoloading

    /**
     * Test that PSR-0 and PSR-4 mappings are processed in the correct order for
     * autoloading and for classmap generation:
     * - The main package has priority over other packages.
     * - Longer namespaces have priority over shorter namespaces.
     */
    public function testOverrideVendorsAutoloading()
    {
        $mainPackage = new Package('z', '1.0', '1.0');
        $mainPackage->setAutoload(array('psr-0' => array('A\\B' => $this->workingDir . '/lib'), 'classmap' => array($this->workingDir . '/src')));
        $mainPackage->setRequires(array(new Link('z', 'a/a')));
        $packages = array();
        $packages[] = $a = new Package('a/a', '1.0', '1.0');
        $packages[] = $b = new Package('b/b', '1.0', '1.0');
        $a->setAutoload(array('psr-0' => array('A' => 'src/', 'A\\B' => 'lib/'), 'classmap' => array('classmap')));
        $b->setAutoload(array('psr-0' => array('B\\Sub\\Name' => 'src/')));
        $this->repository->expects($this->once())->method('getCanonicalPackages')->will($this->returnValue($packages));
        $this->fs->ensureDirectoryExists($this->workingDir . '/lib/A/B');
        $this->fs->ensureDirectoryExists($this->workingDir . '/src/');
        $this->fs->ensureDirectoryExists($this->vendorDir . '/composer');
        $this->fs->ensureDirectoryExists($this->vendorDir . '/a/a/classmap');
        $this->fs->ensureDirectoryExists($this->vendorDir . '/a/a/src');
        $this->fs->ensureDirectoryExists($this->vendorDir . '/a/a/lib/A/B');
        $this->fs->ensureDirectoryExists($this->vendorDir . '/b/b/src');
        // Define the classes A\B\C and Foo\Bar in the main package.
        file_put_contents($this->workingDir . '/lib/A/B/C.php', '<?php namespace A\\B; class C {}');
        file_put_contents($this->workingDir . '/src/classes.php', '<?php namespace Foo; class Bar {}');
        // Define the same two classes in the package a/a.
        file_put_contents($this->vendorDir . '/a/a/lib/A/B/C.php', '<?php namespace A\\B; class C {}');
        file_put_contents($this->vendorDir . '/a/a/classmap/classes.php', '<?php namespace Foo; class Bar {}');
        $expectedNamespace = <<<EOF
<?php

// autoload_namespaces.php @generated by Composer

\$vendorDir = dirname(dirname(__FILE__));
\$baseDir = dirname(\$vendorDir);

return array(
    'B\\\\Sub\\\\Name' => array(\$vendorDir . '/b/b/src'),
    'A\\\\B' => array(\$baseDir . '/lib', \$vendorDir . '/a/a/lib'),
    'A' => array(\$vendorDir . '/a/a/src'),
);

EOF;
        // autoload_psr4.php is expected to be empty in this example.
        $expectedPsr4 = <<<EOF
<?php

// autoload_psr4.php @generated by Composer

\$vendorDir = dirname(dirname(__FILE__));
\$baseDir = dirname(\$vendorDir);

return array(
);

EOF;
        $expectedClassmap = <<<EOF
<?php

// autoload_classmap.php @generated by Composer

\$vendorDir = dirname(dirname(__FILE__));
\$baseDir = dirname(\$vendorDir);

return array(
    'A\\\\B\\\\C' => \$baseDir . '/lib/A/B/C.php',
    'Foo\\\\Bar' => \$baseDir . '/src/classes.php',
);

EOF;
        $this->generator->dump($this->config, $this->repository, $mainPackage, $this->im, 'composer', true, '_9');
        $this->assertEquals($expectedNamespace, file_get_contents($this->vendorDir . '/composer/autoload_namespaces.php'));
        $this->assertEquals($expectedPsr4, file_get_contents($this->vendorDir . '/composer/autoload_psr4.php'));
        $this->assertEquals($expectedClassmap, file_get_contents($this->vendorDir . '/composer/autoload_classmap.php'));
    }
开发者ID:Teino1978-Corp,项目名称:Teino1978-Corp-composer,代码行数:77,代码来源:AutoloadGeneratorTest.php

示例7: testFilesAutoloadOrderByDependencies

 public function testFilesAutoloadOrderByDependencies()
 {
     $package = new Package('a', '1.0', '1.0');
     $package->setAutoload(array('files' => array('root.php')));
     $package->setRequires(array(new Link('a', 'a/foo')));
     $packages = array();
     $packages[] = $a = new Package('a/foo', '1.0', '1.0');
     $packages[] = $b = new Package('b/bar', '1.0', '1.0');
     $packages[] = $c = new Package('c/lorem', '1.0', '1.0');
     $a->setAutoload(array('files' => array('testA.php')));
     $a->setRequires(array(new Link('a/foo', 'c/lorem')));
     $b->setAutoload(array('files' => array('testB.php')));
     $b->setRequires(array(new Link('b/bar', 'c/lorem')));
     $c->setAutoload(array('files' => array('testC.php')));
     $this->repository->expects($this->once())->method('getPackages')->will($this->returnValue($packages));
     $this->fs->ensureDirectoryExists($this->vendorDir . '/a/foo');
     $this->fs->ensureDirectoryExists($this->vendorDir . '/b/bar');
     $this->fs->ensureDirectoryExists($this->vendorDir . '/c/lorem');
     file_put_contents($this->vendorDir . '/a/foo/testA.php', '<?php function testFilesAutoloadOrderByDependency1() {}');
     file_put_contents($this->vendorDir . '/b/bar/testB.php', '<?php function testFilesAutoloadOrderByDependency2() {}');
     file_put_contents($this->vendorDir . '/c/lorem/testC.php', '<?php function testFilesAutoloadOrderByDependency3() {}');
     file_put_contents($this->workingDir . '/root.php', '<?php function testFilesAutoloadOrderByDependencyRoot() {}');
     $this->generator->dump($this->config, $this->repository, $package, $this->im, 'composer', false, 'FilesAutoloadOrder');
     $this->assertFileEquals(__DIR__ . '/Fixtures/autoload_functions_by_dependency.php', $this->vendorDir . '/autoload.php');
     $this->assertFileEquals(__DIR__ . '/Fixtures/autoload_real_files_by_dependency.php', $this->vendorDir . '/composer/autoload_realFilesAutoloadOrder.php');
     // suppress the class loader to avoid fatals if the class is redefined
     file_put_contents($this->vendorDir . '/composer/ClassLoader.php', '');
     include $this->vendorDir . '/autoload.php';
     $this->assertTrue(function_exists('testFilesAutoloadOrderByDependency1'));
     $this->assertTrue(function_exists('testFilesAutoloadOrderByDependency2'));
     $this->assertTrue(function_exists('testFilesAutoloadOrderByDependency3'));
     $this->assertTrue(function_exists('testFilesAutoloadOrderByDependencyRoot'));
 }
开发者ID:rufinus,项目名称:composer,代码行数:33,代码来源:AutoloadGeneratorTest.php

示例8: testInstallNewPuliPackagesInDifferentEnvironments

 public function testInstallNewPuliPackagesInDifferentEnvironments()
 {
     $event = new CommandEvent(ScriptEvents::POST_INSTALL_CMD, $this->composer, $this->io);
     $this->localRepository->setPackages(array($package1 = new Package('vendor/package1', '1.0', '1.0'), $package2 = new Package('vendor/package2', '1.0', '1.0'), $package3 = new Package('vendor/package3', '1.0', '1.0'), $package4 = new Package('vendor/package4', '1.0', '1.0')));
     // Check whether package is in "require"
     $this->rootPackage->setRequires(array('vendor/package1' => new Link('vendor/root', 'vendor/package1')));
     // Recursively resolve all "require" packages
     $package1->setRequires(array('vendor/package2' => new Link('vendor/package1', 'vendor/package2')));
     // Ignore "require" blocks of "require-dev" dependencies
     $package3->setRequires(array('vendor/package4' => new Link('vendor/package3', 'vendor/package4')));
     $this->io->expects($this->at(0))->method('write')->with('<info>Looking for updated Puli packages</info>');
     $this->io->expects($this->at(1))->method('write')->with('Installing <info>vendor/package1</info> (<comment>package1</comment>) in <comment>prod</comment>');
     $this->io->expects($this->at(2))->method('write')->with('Installing <info>vendor/package2</info> (<comment>package2</comment>) in <comment>prod</comment>');
     $this->io->expects($this->never())->method('writeError');
     $this->puliRunner->expects($this->at(0))->method('run')->with('package --list --format "%name%;%installer%;%install_path%;%state%;%env%"')->willReturn("vendor/root;;{$this->tempDir};enabled;prod\n");
     $this->puliRunner->expects($this->at(1))->method('run')->with("package --install '{$this->tempDir}/package1' 'vendor/package1' --installer 'composer'");
     $this->puliRunner->expects($this->at(2))->method('run')->with("package --install '{$this->tempDir}/package2' 'vendor/package2' --installer 'composer'");
     $this->puliRunner->expects($this->at(3))->method('run')->with("package --install --dev '{$this->tempDir}/package3' 'vendor/package3' --installer 'composer'");
     $this->puliRunner->expects($this->at(4))->method('run')->with("package --install --dev '{$this->tempDir}/package4' 'vendor/package4' --installer 'composer'");
     $this->puliRunner->expects($this->at(5))->method('run')->with('build');
     $this->plugin->postInstall($event);
 }
开发者ID:kormik,项目名称:composer-plugin,代码行数:22,代码来源:PuliPluginTest.php

示例9: testOverrideVendorsAutoloading

    public function testOverrideVendorsAutoloading()
    {
        $package = new Package('z', '1.0', '1.0');
        $package->setAutoload(array('psr-0' => array('A\\B' => $this->workingDir . '/lib'), 'classmap' => array($this->workingDir . '/src')));
        $package->setRequires(array(new Link('z', 'a/a')));
        $packages = array();
        $packages[] = $a = new Package('a/a', '1.0', '1.0');
        $packages[] = $b = new Package('b/b', '1.0', '1.0');
        $a->setAutoload(array('psr-0' => array('A' => 'src/', 'A\\B' => 'lib/'), 'classmap' => array('classmap')));
        $b->setAutoload(array('psr-0' => array('B\\Sub\\Name' => 'src/')));
        $this->repository->expects($this->once())->method('getPackages')->will($this->returnValue($packages));
        $this->fs->ensureDirectoryExists($this->workingDir . '/lib/A/B');
        $this->fs->ensureDirectoryExists($this->workingDir . '/src/');
        $this->fs->ensureDirectoryExists($this->vendorDir . '/composer');
        $this->fs->ensureDirectoryExists($this->vendorDir . '/a/a/classmap');
        $this->fs->ensureDirectoryExists($this->vendorDir . '/a/a/src');
        $this->fs->ensureDirectoryExists($this->vendorDir . '/a/a/lib/A/B');
        $this->fs->ensureDirectoryExists($this->vendorDir . '/b/b/src');
        file_put_contents($this->workingDir . '/lib/A/B/C.php', '<?php namespace A\\B; class C {}');
        file_put_contents($this->workingDir . '/src/classes.php', '<?php namespace Foo; class Bar {}');
        file_put_contents($this->vendorDir . '/a/a/lib/A/B/C.php', '<?php namespace A\\B; class C {}');
        file_put_contents($this->vendorDir . '/a/a/classmap/classes.php', '<?php namespace Foo; class Bar {}');
        $workDir = strtr($this->workingDir, '\\', '/');
        $expectedNamespace = <<<EOF
<?php

// autoload_namespaces.php generated by Composer

\$vendorDir = dirname(__DIR__);
\$baseDir = dirname(\$vendorDir);

return array(
    'B\\\\Sub\\\\Name' => \$vendorDir . '/b/b/src/',
    'A\\\\B' => array('{$workDir}/lib', \$vendorDir . '/a/a/lib/'),
    'A' => \$vendorDir . '/a/a/src/',
);

EOF;
        $expectedClassmap = <<<EOF
<?php

// autoload_classmap.php generated by Composer

\$vendorDir = dirname(__DIR__);
\$baseDir = dirname(\$vendorDir);

return array(
    'A\\\\B\\\\C' => \$baseDir . '/lib/A/B/C.php',
    'Foo\\\\Bar' => \$baseDir . '/src/classes.php',
);

EOF;
        $this->generator->dump($this->config, $this->repository, $package, $this->im, 'composer', true, '_9');
        $this->assertEquals($expectedNamespace, file_get_contents($this->vendorDir . '/composer/autoload_namespaces.php'));
        $this->assertEquals($expectedClassmap, file_get_contents($this->vendorDir . '/composer/autoload_classmap.php'));
    }
开发者ID:rkallensee,项目名称:composer,代码行数:56,代码来源:AutoloadGeneratorTest.php


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