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));
    }
 /**
  * @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());
 }
 /**
  * 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);
 }
Esempio n. 4
0
 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);
 }
Esempio n. 5
0
 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);
 }
 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));
 }
 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()));
 }
 /**
  * @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();
 }
Esempio n. 9
0
 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));
 }