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); })); }