protected function setUp() { $this->fs = new Filesystem(); $this->composer = new Composer(); $this->config = new Config(); $this->composer->setConfig($this->config); $this->vendorDir = realpath(sys_get_temp_dir()) . DIRECTORY_SEPARATOR . 'composer-test-vendor'; $this->ensureDirectoryExistsAndClear($this->vendorDir); $this->binDir = realpath(sys_get_temp_dir()) . DIRECTORY_SEPARATOR . 'composer-test-bin'; $this->ensureDirectoryExistsAndClear($this->binDir); $this->config->merge(array('config' => array('vendor-dir' => $this->vendorDir, 'bin-dir' => $this->binDir))); $this->dm = $this->getMockBuilder('Composer\\Downloader\\DownloadManager')->disableOriginalConstructor()->getMock(); /* @var DownloadManager $dm */ $dm = $this->dm; $this->composer->setDownloadManager($dm); $this->repository = $this->getMock('Composer\\Repository\\InstalledRepositoryInterface'); $this->io = $this->getMock('Composer\\IO\\IOInterface'); $this->type = $this->getMock('Fxp\\Composer\\AssetPlugin\\Type\\AssetTypeInterface'); $this->type->expects($this->any())->method('getName')->will($this->returnValue('foo')); $this->type->expects($this->any())->method('getComposerVendorName')->will($this->returnValue('foo-asset')); $this->type->expects($this->any())->method('getComposerType')->will($this->returnValue('foo-asset-library')); $this->type->expects($this->any())->method('getFilename')->will($this->returnValue('foo.json')); $this->type->expects($this->any())->method('getVersionConverter')->will($this->returnValue($this->getMock('Fxp\\Composer\\AssetPlugin\\Converter\\VersionConverterInterface'))); $this->type->expects($this->any())->method('getPackageConverter')->will($this->returnValue($this->getMock('Fxp\\Composer\\AssetPlugin\\Converter\\PackageConverterInterface'))); }
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->package = $this->getMock('Composer\Package\RootPackageInterface'); $this->assetType = $this->getMock('Fxp\Composer\AssetPlugin\Type\AssetTypeInterface'); $versionConverter = $this->getMock('Fxp\Composer\AssetPlugin\Converter\VersionConverterInterface'); $versionConverter->expects($this->any()) ->method('convertVersion') ->will($this->returnCallback(function ($value) { return $value; })); $this->assetType->expects($this->any()) ->method('getVersionConverter') ->will($this->returnValue($versionConverter)); }
protected function setUp() { $this->io = $this->getMock('Composer\\IO\\IOInterface'); $config = $this->getMock('Composer\\Config'); $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; })); $this->package = $this->getMock('Composer\\Package\\PackageInterface'); $this->composer = $this->getMock('Composer\\Composer'); $this->composer->expects($this->any())->method('getPackage')->will($this->returnValue($this->package)); $this->composer->expects($this->any())->method('getConfig')->will($this->returnValue($config)); $this->type = $this->getMock('Fxp\\Composer\\AssetPlugin\\Type\\AssetTypeInterface'); $this->type->expects($this->any())->method('getName')->will($this->returnValue('foo')); $this->type->expects($this->any())->method('getComposerVendorName')->will($this->returnValue('foo-asset')); $this->type->expects($this->any())->method('getComposerType')->will($this->returnValue('foo-asset-library')); $this->type->expects($this->any())->method('getFilename')->will($this->returnValue('foo.json')); $this->type->expects($this->any())->method('getVersionConverter')->will($this->returnValue($this->getMock('Fxp\\Composer\\AssetPlugin\\Converter\\VersionConverterInterface'))); $this->type->expects($this->any())->method('getPackageConverter')->will($this->returnValue($this->getMock('Fxp\\Composer\\AssetPlugin\\Converter\\PackageConverterInterface'))); }
protected function setUp() { $this->lazyPackage = $this->getMock('Fxp\\Composer\\AssetPlugin\\Package\\LazyPackageInterface'); $this->assetType = $this->getMock('Fxp\\Composer\\AssetPlugin\\Type\\AssetTypeInterface'); $this->loader = $this->getMock('Composer\\Package\\Loader\\LoaderInterface'); $this->driver = $this->getMock('Composer\\Repository\\Vcs\\VcsDriverInterface'); $this->dispatcher = $this->getMockBuilder('Composer\\EventDispatcher\\EventDispatcher')->disableOriginalConstructor()->getMock(); $this->lazyPackage->expects($this->any())->method('getName')->will($this->returnValue('PACKAGE_NAME')); $this->lazyPackage->expects($this->any())->method('getUniqueName')->will($this->returnValue('PACKAGE_NAME-1.0.0.0')); $this->lazyPackage->expects($this->any())->method('getPrettyVersion')->will($this->returnValue('1.0')); $this->lazyPackage->expects($this->any())->method('getVersion')->will($this->returnValue('1.0.0.0')); $versionConverter = $this->getMock('Fxp\\Composer\\AssetPlugin\\Converter\\VersionConverterInterface'); $versionConverter->expects($this->any())->method('convertVersion')->will($this->returnValue('VERSION_CONVERTED')); $versionConverter->expects($this->any())->method('convertRange')->will($this->returnCallback(function ($value) { return $value; })); $packageConverter = $this->getMock('Fxp\\Composer\\AssetPlugin\\Converter\\PackageConverterInterface'); /* @var LazyPackageInterface $lasyPackage */ $lasyPackage = $this->lazyPackage; $packageConverter->expects($this->any())->method('convert')->will($this->returnCallback(function ($value) use($lasyPackage) { $value['version'] = $lasyPackage->getPrettyVersion(); $value['version_normalized'] = $lasyPackage->getVersion(); return $value; })); $this->assetType->expects($this->any())->method('getComposerVendorName')->will($this->returnValue('ASSET')); $this->assetType->expects($this->any())->method('getComposerType')->will($this->returnValue('ASSET_TYPE')); $this->assetType->expects($this->any())->method('getFilename')->will($this->returnValue('ASSET.json')); $this->assetType->expects($this->any())->method('getVersionConverter')->will($this->returnValue($versionConverter)); $this->assetType->expects($this->any())->method('getPackageConverter')->will($this->returnValue($packageConverter)); $this->driver->expects($this->any())->method('getDist')->will($this->returnCallback(function ($value) { return array('type' => 'vcs', 'url' => 'http://foobar.tld/dist/' . $value); })); $this->driver->expects($this->any())->method('getSource')->will($this->returnCallback(function ($value) { return array('type' => 'vcs', 'url' => 'http://foobar.tld/source/' . $value); })); }