本文整理汇总了PHP中Composer\Composer::expects方法的典型用法代码示例。如果您正苦于以下问题:PHP Composer::expects方法的具体用法?PHP Composer::expects怎么用?PHP Composer::expects使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Composer\Composer
的用法示例。
在下文中一共展示了Composer::expects方法的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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: testIsMagentoRoot
/**
* @param string $packageName
* @param boolean $expected
* @dataProvider isMagentoRootDataProvider
*/
public function testIsMagentoRoot($packageName, $expected)
{
$rootPackageMock = $this->getMockForAbstractClass(\Composer\Package\RootPackageInterface::class);
$this->composerMock->expects($this->once())->method('getPackage')->willReturn($rootPackageMock);
$rootPackageMock->method('getName')->willReturn($packageName);
$this->assertEquals($expected, $this->composerInformation->isMagentoRoot());
}
示例3: testActivate
/**
* All we can do is confirm that the plugin tried to register the
* correct installer class during ::activate().
*
* @return void
*/
public function testActivate()
{
$this->composer = $this->getMock('Composer\\Composer', ['getInstallationManager', 'addInstaller']);
$this->composer->setConfig(new Config(false));
$this->composer->expects($this->once())->method('getInstallationManager')->will($this->returnSelf());
$this->composer->expects($this->once())->method('addInstaller')->with($this->isInstanceOf('Loadsys\\Composer\\PuphpetReleaseInstaller'));
$this->plugin->activate($this->composer, $this->io);
}
开发者ID:loadsys,项目名称:puphpet-release-composer-installer,代码行数:14,代码来源:PuphpetReleaseInstallerPluginTest.php
示例4: 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);
}
示例5: testWillDeleteExistingTagfile
public function testWillDeleteExistingTagfile()
{
touch($this->testTempDir . '/tags');
$this->assertFileExists($this->testTempDir . '/tags');
$this->composerMock->expects($this->once())->method('getConfig')->will($this->returnValue($this->composerConfig));
Ctagger::setTagsDir($this->testTempDir);
Ctagger::ctag($this->event);
}
示例6: setUp
public function setUp()
{
$this->composer = $this->getMockBuilder('Composer\\Composer')->getMock();
$this->io = $this->getMockBuilder('Composer\\IO\\IOInterface')->getMock();
$this->package = $this->getMockBuilder('Composer\\Package\\PackageInterface')->getMock();
$config = $this->getMockBuilder('Composer\\Config')->getMock();
$config->expects($this->any())->method('get')->will($this->returnCallback(function ($key) {
$val = null;
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 $val;
}));
$rootPackage = $this->getMockBuilder('Composer\\Package\\RootPackageInterface')->getMock();
$this->composer->expects($this->any())->method('getConfig')->will($this->returnValue($config));
$this->composer->expects($this->any())->method('getPackage')->will($this->returnValue($rootPackage));
}
示例7: testIgnoredBundles
public function testIgnoredBundles()
{
$packages = array($this->createPackage('foo/foo-bundle', 'symfony-bundle', array('psr-0' => array('Acme\\FooBundle' => ''))), $this->createPackage('acme/library-bundle', 'symfony-bundle', array('psr-0' => array('Acme\\LibraryBundle' => ''))));
$rootPackage = new RootPackage('DemoPackage', 'dev-master', '1.x-dev');
$rootPackage->setExtra(array('checkbundles-ignore' => array('Acme\\LibraryBundle\\AcmeLibraryBundle')));
$this->composerMock->expects($this->any())->method('getPackage')->will($this->returnValue($rootPackage));
$this->localRepository->expects($this->any())->method('getPackages')->will($this->returnValue($packages));
$kernelHelper = $this->getMockBuilder('WillemJan\\Util\\KernelHelper')->disableOriginalConstructor()->setMethods(array('getBundlesForKernels'))->getMock();
$kernelHelper->expects($this->any())->method('getBundlesForKernels')->will($this->returnValue(array('Acme\\FooBundle\\AcmeFooBundle')));
$composerHelper = $this->getMockBuilder('WillemJan\\CheckBundles\\Util\\ComposerHelper')->setConstructorArgs(array($this->composerMock))->setMethods(array('getInstalledRepository', 'findBundleFiles'))->getMock();
$composerHelper->expects($this->any())->method('findBundleFiles')->will($this->returnCallback(function ($package) use($packages) {
switch ($package->getName()) {
case 'foo/foo-bundle':
return array('AcmeFooBundle.php');
break;
case 'acme/library-bundle':
return array('AcmeLibraryBundle.php');
break;
}
return array('ShouldNotHappenBundle.php');
}));
$composerHelper->expects($this->any())->method('getInstalledRepository')->will($this->returnValue($this->localRepository));
$this->assertEquals(array(), $composerHelper->getNonActiveSymfonyBundles($kernelHelper->getBundlesForKernels()));
}
示例8: testGetPackageVersionsFailed
/**
* @expectedException \RuntimeException
* @expectedExceptionMessage We cannot retrieve information on magento/product-community-edition.
*/
public function testGetPackageVersionsFailed()
{
$communityPackage = $this->getMock('\\Composer\\Package\\Package', [], [], '', false);
$enterprisePackage = $this->getMock('\\Composer\\Package\\Package', [], [], '', false);
$communityPackage->expects($this->once())->method('getName')->willReturn('magento/product-community-edition');
$enterprisePackage->expects($this->once())->method('getName')->willReturn('magento/product-enterprise-edition');
$this->composerInformation->expects($this->any())->method('isSystemPackage')->willReturn(true);
$this->composerInformation->expects($this->once())->method('isPackageInComposerJson')->willReturn(true);
$this->repository->expects($this->once())->method('getPackages')->willReturn([$communityPackage, $enterprisePackage]);
$this->locker->expects($this->once())->method('getLockedRepository')->willReturn($this->repository);
$this->composer->expects($this->once())->method('getLocker')->willReturn($this->locker);
$this->magentoComposerApp->expects($this->once())->method('createComposer')->willReturn($this->composer);
$this->composerAppFactory->expects($this->once())->method('create')->willReturn($this->magentoComposerApp);
$this->composerAppFactory->expects($this->once())->method('createInfoCommand')->willReturn($this->infoCommand);
$this->systemPackage = new SystemPackage($this->composerAppFactory, $this->composerInformation);
$this->infoCommand->expects($this->once())->method('run')->with('magento/product-community-edition')->willReturn(false);
$this->systemPackage->getPackageVersions();
}
示例9: getRootPackage
protected function getRootPackage()
{
$this->event_command->expects($this->once())->method('getComposer')->will($this->returnValue($this->composer));
$this->composer->expects($this->once())->method('getPackage')->will($this->returnValue($this->package));
}