diff --git a/FxpAssetPlugin.php b/FxpAssetPlugin.php index 93e4cabd..3442f45f 100644 --- a/FxpAssetPlugin.php +++ b/FxpAssetPlugin.php @@ -87,7 +87,7 @@ public function activate(Composer $composer, IOInterface $io) $this->composer = $composer; $this->io = $io; $this->packageFilter = new VcsPackageFilter($this->config, $composer->getPackage(), $composer->getInstallationManager(), $installedRepository); - $this->assetRepositoryManager = new AssetRepositoryManager($io, $composer->getRepositoryManager(), $this->packageFilter); + $this->assetRepositoryManager = new AssetRepositoryManager($io, $composer->getRepositoryManager(), $this->config, $this->packageFilter); $this->assetRepositoryManager->setResolutionManager(new ResolutionManager($this->config->getArray('resolutions'))); AssetPlugin::addRegistryRepositories($this->assetRepositoryManager, $this->packageFilter, $this->config); diff --git a/Repository/AssetRepositoryManager.php b/Repository/AssetRepositoryManager.php index 4b0fac76..0e8503c1 100644 --- a/Repository/AssetRepositoryManager.php +++ b/Repository/AssetRepositoryManager.php @@ -15,6 +15,7 @@ use Composer\IO\IOInterface; use Composer\Repository\RepositoryInterface; use Composer\Repository\RepositoryManager; +use Fxp\Composer\AssetPlugin\Config\Config; /** * The asset repository manager. @@ -33,6 +34,11 @@ class AssetRepositoryManager */ protected $rm; + /** + * @var Config + */ + protected $config; + /** * @var VcsPackageFilter */ @@ -63,12 +69,14 @@ class AssetRepositoryManager * * @param IOInterface $io The IO * @param RepositoryManager $rm The repository manager + * @param Config $config The asset config * @param VcsPackageFilter $packageFilter The package filter */ - public function __construct(IOInterface $io, RepositoryManager $rm, VcsPackageFilter $packageFilter) + public function __construct(IOInterface $io, RepositoryManager $rm, Config $config, VcsPackageFilter $packageFilter) { $this->io = $io; $this->rm = $rm; + $this->config = $config; $this->packageFilter = $packageFilter; } @@ -82,6 +90,16 @@ public function getRepositoryManager() return $this->rm; } + /** + * Get the asset config. + * + * @return Config + */ + public function getConfig() + { + return $this->config; + } + /** * Set the pool. * diff --git a/Tests/Repository/AbstractAssetsRepositoryTest.php b/Tests/Repository/AbstractAssetsRepositoryTest.php index 4a790ff8..51a9f4a3 100644 --- a/Tests/Repository/AbstractAssetsRepositoryTest.php +++ b/Tests/Repository/AbstractAssetsRepositoryTest.php @@ -17,6 +17,7 @@ use Composer\EventDispatcher\EventDispatcher; use Composer\IO\IOInterface; use Composer\Repository\RepositoryManager; +use Fxp\Composer\AssetPlugin\Config\Config as AssetConfig; use Fxp\Composer\AssetPlugin\Repository\AbstractAssetsRepository; use Fxp\Composer\AssetPlugin\Repository\AssetRepositoryManager; use Fxp\Composer\AssetPlugin\Repository\AssetVcsRepository; @@ -45,7 +46,7 @@ abstract class AbstractAssetsRepositoryTest extends \PHPUnit_Framework_TestCase protected $rm; /** - * @var AssetRepositoryManager|\PHPUnit_Framework_MockObject_MockObject + * @var AssetRepositoryManager */ protected $assertRepositoryManager; @@ -77,7 +78,7 @@ protected function setUp() $filter = $this->getMockBuilder(VcsPackageFilter::class)->disableOriginalConstructor()->getMock(); $rm = new RepositoryManager($io, $config); $rm->setRepositoryClass($this->getType().'-vcs', 'Fxp\Composer\AssetPlugin\Tests\Fixtures\Repository\MockAssetRepository'); - $this->assertRepositoryManager = new AssetRepositoryManager($io, $rm, $filter); + $this->assertRepositoryManager = new AssetRepositoryManager($io, $rm, new AssetConfig(array()), $filter); $repoConfig = array_merge(array( 'asset-repository-manager' => $this->assertRepositoryManager, 'asset-options' => array( diff --git a/Tests/Repository/AssetRepositoryManagerTest.php b/Tests/Repository/AssetRepositoryManagerTest.php index e46e67a8..a783888d 100644 --- a/Tests/Repository/AssetRepositoryManagerTest.php +++ b/Tests/Repository/AssetRepositoryManagerTest.php @@ -15,6 +15,7 @@ use Composer\IO\IOInterface; use Composer\Repository\RepositoryInterface; use Composer\Repository\RepositoryManager; +use Fxp\Composer\AssetPlugin\Config\Config; use Fxp\Composer\AssetPlugin\Repository\AssetRepositoryManager; use Fxp\Composer\AssetPlugin\Repository\ResolutionManager; use Fxp\Composer\AssetPlugin\Repository\VcsPackageFilter; @@ -36,6 +37,11 @@ class AssetRepositoryManagerTest extends \PHPUnit_Framework_TestCase */ protected $io; + /** + * @var Config + */ + protected $config; + /** * @var VcsPackageFilter|\PHPUnit_Framework_MockObject_MockObject */ @@ -55,10 +61,11 @@ protected function setUp() { $this->io = $this->getMockBuilder(IOInterface::class)->getMock(); $this->rm = $this->getMockBuilder(RepositoryManager::class)->disableOriginalConstructor()->getMock(); + $this->config = new Config(array()); $this->filter = $this->getMockBuilder(VcsPackageFilter::class)->disableOriginalConstructor()->getMock(); $this->resolutionManager = $this->getMockBuilder(ResolutionManager::class)->getMock(); - $this->assertRepositoryManager = new AssetRepositoryManager($this->io, $this->rm, $this->filter); + $this->assertRepositoryManager = new AssetRepositoryManager($this->io, $this->rm, $this->config, $this->filter); } public function getDataForSolveResolutions() @@ -128,4 +135,9 @@ public function testAddRepositoryInPool() $this->assertRepositoryManager->setPool($pool); } + + public function testGetConfig() + { + $this->assertSame($this->config, $this->assertRepositoryManager->getConfig()); + } }