本文整理汇总了PHP中Composer\Repository\InstalledRepositoryInterface::expects方法的典型用法代码示例。如果您正苦于以下问题:PHP InstalledRepositoryInterface::expects方法的具体用法?PHP InstalledRepositoryInterface::expects怎么用?PHP InstalledRepositoryInterface::expects使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Composer\Repository\InstalledRepositoryInterface
的用法示例。
在下文中一共展示了InstalledRepositoryInterface::expects方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: update
/**
* @test
*/
public function update()
{
$initial = $this->createPackageMock();
$target = $this->createPackageMock();
$this->installer->expects($this->once())->method('update')->with($this->repository, $initial, $target);
$this->repository->expects($this->once())->method('hasPackage')->with($initial)->willReturn(true);
$this->createSolver()->update($this->repository, $initial, $target);
}
开发者ID:letudiant,项目名称:composer-shared-package-plugin,代码行数:11,代码来源:SharedPackageInstallerSolverSharedTest.php
示例2: testExcludeFromClassmap
public function testExcludeFromClassmap()
{
$package = new Package('a', '1.0', '1.0');
$package->setAutoload(array('psr-0' => array('Main' => 'src/', 'Lala' => array('src/', 'lib/')), 'psr-4' => array('Acme\\Fruit\\' => 'src-fruit/', 'Acme\\Cake\\' => array('src-cake/', 'lib-cake/')), 'classmap' => array('composersrc/'), 'exclude-from-classmap' => array('/composersrc/excludedTests/', '/composersrc/ClassToExclude.php', '/composersrc/*/excluded/excsubpath', '**/excsubpath')));
$this->repository->expects($this->once())->method('getCanonicalPackages')->will($this->returnValue(array()));
$this->fs->ensureDirectoryExists($this->workingDir . '/composer');
$this->fs->ensureDirectoryExists($this->workingDir . '/src/Lala/Test');
$this->fs->ensureDirectoryExists($this->workingDir . '/lib');
file_put_contents($this->workingDir . '/src/Lala/ClassMapMain.php', '<?php namespace Lala; class ClassMapMain {}');
file_put_contents($this->workingDir . '/src/Lala/Test/ClassMapMainTest.php', '<?php namespace Lala\\Test; class ClassMapMainTest {}');
$this->fs->ensureDirectoryExists($this->workingDir . '/src-fruit');
$this->fs->ensureDirectoryExists($this->workingDir . '/src-cake');
$this->fs->ensureDirectoryExists($this->workingDir . '/lib-cake');
file_put_contents($this->workingDir . '/src-cake/ClassMapBar.php', '<?php namespace Acme\\Cake; class ClassMapBar {}');
$this->fs->ensureDirectoryExists($this->workingDir . '/composersrc');
$this->fs->ensureDirectoryExists($this->workingDir . '/composersrc/tests');
file_put_contents($this->workingDir . '/composersrc/foo.php', '<?php class ClassMapFoo {}');
// this classes should not be found in the classmap
$this->fs->ensureDirectoryExists($this->workingDir . '/composersrc/excludedTests');
file_put_contents($this->workingDir . '/composersrc/excludedTests/bar.php', '<?php class ClassExcludeMapFoo {}');
file_put_contents($this->workingDir . '/composersrc/ClassToExclude.php', '<?php class ClassClassToExclude {}');
$this->fs->ensureDirectoryExists($this->workingDir . '/composersrc/long/excluded/excsubpath');
file_put_contents($this->workingDir . '/composersrc/long/excluded/excsubpath/foo.php', '<?php class ClassExcludeMapFoo2 {}');
file_put_contents($this->workingDir . '/composersrc/long/excluded/excsubpath/bar.php', '<?php class ClassExcludeMapBar {}');
$this->generator->dump($this->config, $this->repository, $package, $this->im, 'composer', true, '_1');
// Assert that autoload_classmap.php was correctly generated.
$this->assertAutoloadFiles('classmap', $this->vendorDir . '/composer', 'classmap');
}
示例3: uninstallKeepSources
/**
* @test
*/
public function uninstallKeepSources()
{
$this->io->expects($this->once())->method('askConfirmation')->willReturn(false);
/** @var SymlinkFilesystem|\PHPUnit_Framework_MockObject_MockObject $filesystem */
$filesystem = $this->getMock('\\LEtudiant\\Composer\\Util\\SymlinkFilesystem');
$filesystem->expects($this->once())->method('removeSymlink')->willReturn(true);
$installer = $this->createInstaller($this->config, $filesystem);
$package = $this->createPackageMock();
$this->repository->expects($this->once())->method('removePackage')->with($package);
$this->dm->expects($this->never())->method('remove');
$this->dataManager->expects($this->once())->method('removePackageUsage')->with($package);
$installer->uninstall($this->repository, $package);
}
示例4: uninstallDevelopment
/**
* @test
*/
public function uninstallDevelopment()
{
$this->io->expects($this->once())->method('askConfirmation')->willReturn(true);
/** @var SymlinkFilesystem|\PHPUnit_Framework_MockObject_MockObject $filesystem */
$filesystem = $this->getMock('\\LEtudiant\\Composer\\Util\\SymlinkFilesystem');
$filesystem->expects($this->once())->method('removeSymlink')->willReturn(true);
$library = new SharedPackageInstaller($this->io, $this->composer, $filesystem, $this->dataManager);
$package = $this->createDevelopmentPackageMock();
$this->repository->expects($this->exactly(1))->method('hasPackage')->with($package)->will($this->onConsecutiveCalls(true, true));
$this->repository->expects($this->once())->method('removePackage')->with($package);
$this->dm->expects($this->once())->method('remove')->with($package, $this->dependenciesDir . '/letudiant/foo-bar/dev-develop');
$this->dataManager->expects($this->once())->method('removePackageUsage')->with($package);
$library->uninstall($this->repository, $package);
}
示例5: 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()));
}
示例6: testVendorSubstringPath
public function testVendorSubstringPath()
{
$package = new Package('a', '1.0', '1.0');
$package->setAutoload(array('psr-0' => array('Foo' => 'composer-test-autoload-src/src'), 'psr-4' => array('Acme\\Foo\\' => 'composer-test-autoload-src/src-psr4')));
$this->repository->expects($this->once())->method('getCanonicalPackages')->will($this->returnValue(array()));
$this->fs->ensureDirectoryExists($this->vendorDir . '/a');
$expectedNamespace = <<<'EOF'
<?php
// autoload_namespaces.php @generated by Composer
$vendorDir = dirname(dirname(__FILE__));
$baseDir = dirname($vendorDir);
return array(
'Foo' => array($baseDir . '/composer-test-autoload-src/src'),
);
EOF;
$expectedPsr4 = <<<'EOF'
<?php
// autoload_psr4.php @generated by Composer
$vendorDir = dirname(dirname(__FILE__));
$baseDir = dirname($vendorDir);
return array(
'Acme\\Foo\\' => array($baseDir . '/composer-test-autoload-src/src-psr4'),
);
EOF;
$this->generator->dump($this->config, $this->repository, $package, $this->im, 'composer', false, 'VendorSubstring');
$this->assertEquals($expectedNamespace, file_get_contents($this->vendorDir . '/composer/autoload_namespaces.php'));
$this->assertEquals($expectedPsr4, file_get_contents($this->vendorDir . '/composer/autoload_psr4.php'));
}