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->config->expects($this->at(0))->method('get')->with($this->equalTo('vendor-dir'))->will($this->returnCallback(function () use($that) { return $that->vendorDir; })); $this->config->expects($this->at(1))->method('get')->with($this->equalTo('vendor-dir'))->will($this->returnCallback(function () use($that) { return $that->vendorDir; })); $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); }
protected function setUp() { $this->package = $this->getMockBuilder('Composer\\Package\\RootPackageInterface')->getMock(); $this->assetType = $this->getMockBuilder('Fxp\\Composer\\AssetPlugin\\Type\\AssetTypeInterface')->getMock(); $versionConverter = $this->getMockBuilder('Fxp\\Composer\\AssetPlugin\\Converter\\VersionConverterInterface')->getMock(); $versionConverter->expects($this->any())->method('convertVersion')->will($this->returnCallback(function ($value) { return $value; })); $this->assetType->expects($this->any())->method('getVersionConverter')->will($this->returnValue($versionConverter)); $this->installationManager = $this->getMockBuilder('Composer\\Installer\\InstallationManager')->disableOriginalConstructor()->getMock(); $this->installationManager->expects($this->any())->method('isPackageInstalled')->will($this->returnValue(true)); }
protected function setUp() { $this->tempDir = TestUtil::makeTempDir('puli-composer-plugin', __CLASS__); $filesystem = new Filesystem(); $filesystem->mirror(__DIR__ . '/Fixtures/root', $this->tempDir); $this->io = $this->getMock('Composer\\IO\\IOInterface'); $this->config = new Config(false, $this->tempDir); $this->config->merge(array('config' => array('vendor-dir' => 'the-vendor'))); $this->installationManager = $this->getMockBuilder('Composer\\Installer\\InstallationManager')->disableOriginalConstructor()->getMock(); $this->installationManager->expects($this->any())->method('getInstallPath')->will($this->returnCallback(array($this, 'getInstallPath'))); $this->rootPackage = new RootPackage('vendor/root', '1.0', '1.0'); $this->rootPackage->setRequires(array('vendor/package1' => new Link('vendor/root', 'vendor/package1'), 'vendor/package2' => new Link('vendor/root', 'vendor/package2'))); $this->localRepository = new TestLocalRepository(array(new Package('vendor/package1', '1.0', '1.0'), new Package('vendor/package2', '1.0', '1.0'))); $this->repositoryManager = new RepositoryManager($this->io, $this->config); $this->repositoryManager->setLocalRepository($this->localRepository); $this->installPaths = array(); $this->composer = new Composer(); $this->composer->setRepositoryManager($this->repositoryManager); $this->composer->setInstallationManager($this->installationManager); $this->composer->setConfig($this->config); $this->composer->setPackage($this->rootPackage); $this->puliRunner = $this->getMockBuilder('Puli\\ComposerPlugin\\PuliRunner')->disableOriginalConstructor()->getMock(); $this->previousWd = getcwd(); chdir($this->tempDir); $this->plugin = new PuliPlugin($this->puliRunner); }
protected function setUp() { while (false === mkdir($this->tempDir = sys_get_temp_dir() . '/puli-plugin/PuliPluginTest_root' . rand(10000, 99999), 0777, true)) { } $filesystem = new Filesystem(); $filesystem->mirror(__DIR__ . '/Fixtures/root', $this->tempDir); $this->io = $this->getMock('Composer\\IO\\IOInterface'); $this->config = new Config(false, $this->tempDir); $this->config->merge(array('config' => array('vendor-dir' => 'the-vendor'))); $this->installationManager = $this->getMockBuilder('Composer\\Installer\\InstallationManager')->disableOriginalConstructor()->getMock(); $this->installationManager->expects($this->any())->method('getInstallPath')->will($this->returnCallback(array($this, 'getInstallPath'))); $this->rootPackage = new RootPackage('vendor/root', '1.0', '1.0'); $this->localRepository = new TestLocalRepository(array(new Package('vendor/package1', '1.0', '1.0'), new Package('vendor/package2', '1.0', '1.0'))); $this->repositoryManager = new RepositoryManager($this->io, $this->config); $this->repositoryManager->setLocalRepository($this->localRepository); $this->installPaths = array(); $this->composer = new Composer(); $this->composer->setRepositoryManager($this->repositoryManager); $this->composer->setInstallationManager($this->installationManager); $this->composer->setConfig($this->config); $this->composer->setPackage($this->rootPackage); $this->puliRunner = $this->getMockBuilder('Puli\\ComposerPlugin\\PuliRunner')->disableOriginalConstructor()->getMock(); $this->previousWd = getcwd(); chdir($this->tempDir); $this->plugin = new PuliPlugin($this->puliRunner); }
protected function setUp() { $this->fs = new Filesystem(); $that = $this; $this->workingDir = $this->getUniqueTmpDirectory(); $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); }
/** * @test * * @depends testInstallerCreationShouldNotCreateVendorDirectory * @depends testInstallerCreationShouldNotCreateBinDirectory */ public function updateFull() { /** @var InstallationManager|\PHPUnit_Framework_MockObject_MockObject $im */ $this->im->expects($this->once())->method('uninstall'); $this->im->expects($this->once())->method('install'); $installer = $this->createInstaller(); $initial = $this->createPackageMock('letudiant/bar-foo'); $target = $this->createPackageMock(); $installer->update($this->repository, $initial, $target); }
/** * @test */ public function active() { $this->im->expects($this->once())->method('addInstaller'); $plugin = new SharedPackagePlugin(); $plugin->activate($this->composer, $this->io); }