/** * Creates the mock of package config. * * @param string $name The package name * @param string $version The version * * @return array The package config */ protected function createMockOfPackageConfig($name, $version) { return array( 'name' => $name, 'version' => $version, 'type' => $this->assetType->getComposerType(), ); }
/** * Constructor. * * @param IOInterface $io * @param Composer $composer * @param AssetTypeInterface $assetType * @param Filesystem $filesystem */ public function __construct(IOInterface $io, Composer $composer, AssetTypeInterface $assetType, Filesystem $filesystem = null) { parent::__construct($io, $composer, $assetType->getComposerType(), $filesystem); $extra = $composer->getPackage()->getExtra(); if (!empty($extra['asset-installer-paths'][$this->type])) { $this->vendorDir = rtrim($extra['asset-installer-paths'][$this->type], '/'); } else { $this->vendorDir = rtrim($this->vendorDir . '/' . $assetType->getComposerVendorName(), '/'); } }
public function testCustomFooDir() { $vendorDir = realpath(sys_get_temp_dir()) . '/composer-test/web'; $vendorDir = str_replace('\\', '/', $vendorDir); /* @var \PHPUnit_Framework_MockObject_MockObject $package */ $package = $this->package; $package->expects($this->any())->method('getExtra')->will($this->returnValue(array('asset-installer-paths' => array($this->type->getComposerType() => $vendorDir)))); $installer = $this->createInstaller(); $installerPath = $installer->getInstallPath($this->createPackageMock('foo-asset/foo')); $installerPath = str_replace('\\', '/', $installerPath); $this->assertEquals($vendorDir . '/foo', $installerPath); $installerPath2 = $installer->getInstallPath($this->createPackageMock('foo-asset/foo/bar')); $installerPath2 = str_replace('\\', '/', $installerPath2); $this->assertEquals($vendorDir . '/foo/bar', $installerPath2); }