本文整理汇总了PHP中Composer\Config::expects方法的典型用法代码示例。如果您正苦于以下问题:PHP Config::expects方法的具体用法?PHP Config::expects怎么用?PHP Config::expects使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Composer\Config
的用法示例。
在下文中一共展示了Config::expects方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: setUp
public function setUp()
{
$this->config = $this->getMock('Composer\Config');
$this->config->expects($this->any())
->method('get')
->will($this->returnCallback(function ($key) {
switch ($key) {
case 'cache-repo-dir':
return sys_get_temp_dir() . '/composer-test-repo-cache';
case 'vendor-dir':
return sys_get_temp_dir() . '/composer-test/vendor';
}
return null;
}));
$this->rootPackage = $this->getMock('Composer\Package\RootPackageInterface');
$this->package = $this->getMock('Composer\Package\PackageInterface');
$this->package->expects($this->any())
->method('getName')
->will($this->returnValue('foo-asset/foo'));
$this->composer = $this->getMock('Composer\Composer');
$this->composer->expects($this->any())
->method('getPackage')
->will($this->returnValue($this->rootPackage));
$this->composer->expects($this->any())
->method('getConfig')
->will($this->returnValue($this->config));
}
示例2: setUp
protected function setUp()
{
$this->fs = new Filesystem();
$that = $this;
$this->workingDir = realpath(sys_get_temp_dir()) . DIRECTORY_SEPARATOR . 'cmptest-' . md5(uniqid('', true));
$this->fs->ensureDirectoryExists($this->workingDir);
$this->vendorDir = $this->workingDir . DIRECTORY_SEPARATOR . 'composer-test-autoload';
$this->ensureDirectoryExistsAndClear($this->vendorDir);
$this->config = $this->getMock('Composer\\Config');
$this->configValueMap = array('vendor-dir' => function () use($that) {
return $that->vendorDir;
});
$this->config->expects($this->atLeastOnce())->method('get')->will($this->returnCallback(function ($arg) use($that) {
$ret = null;
if (isset($that->configValueMap[$arg])) {
$ret = $that->configValueMap[$arg];
if (is_callable($ret)) {
$ret = $ret();
}
}
return $ret;
}));
$this->origDir = getcwd();
chdir($this->workingDir);
$this->im = $this->getMockBuilder('Composer\\Installer\\InstallationManager')->disableOriginalConstructor()->getMock();
$this->im->expects($this->any())->method('getInstallPath')->will($this->returnCallback(function ($package) use($that) {
$targetDir = $package->getTargetDir();
return $that->vendorDir . '/' . $package->getName() . ($targetDir ? '/' . $targetDir : '');
}));
$this->repository = $this->getMock('Composer\\Repository\\InstalledRepositoryInterface');
$this->eventDispatcher = $this->getMockBuilder('Composer\\EventDispatcher\\EventDispatcher')->disableOriginalConstructor()->getMock();
$this->generator = new AutoloadGenerator($this->eventDispatcher);
}
示例3: testUseGlobalIncludePath
public function testUseGlobalIncludePath()
{
$package = new Package('a', '1.0', '1.0');
$package->setAutoload(array('psr-0' => array('Main\\Foo' => '', 'Main\\Bar' => '')));
$package->setTargetDir('Main/Foo/');
$this->repository->expects($this->once())->method('getCanonicalPackages')->will($this->returnValue(array()));
$this->config->expects($this->at(2))->method('get')->with($this->equalTo('use-include-path'))->will($this->returnValue(true));
$this->fs->ensureDirectoryExists($this->vendorDir . '/a');
$this->generator->dump($this->config, $this->repository, $package, $this->im, 'composer', false, 'IncludePath');
$this->assertFileEquals(__DIR__ . '/Fixtures/autoload_real_include_path.php', $this->vendorDir . '/composer/autoload_real.php');
}