Skip to content

Commit 68fc247

Browse files
Inject the config in the asset repository manager
1 parent 2b652ae commit 68fc247

4 files changed

+36
-5
lines changed

FxpAssetPlugin.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -87,7 +87,7 @@ public function activate(Composer $composer, IOInterface $io)
8787
$this->composer = $composer;
8888
$this->io = $io;
8989
$this->packageFilter = new VcsPackageFilter($this->config, $composer->getPackage(), $composer->getInstallationManager(), $installedRepository);
90-
$this->assetRepositoryManager = new AssetRepositoryManager($io, $composer->getRepositoryManager(), $this->packageFilter);
90+
$this->assetRepositoryManager = new AssetRepositoryManager($io, $composer->getRepositoryManager(), $this->config, $this->packageFilter);
9191
$this->assetRepositoryManager->setResolutionManager(new ResolutionManager($this->config->getArray('resolutions')));
9292

9393
AssetPlugin::addRegistryRepositories($this->assetRepositoryManager, $this->packageFilter, $this->config);

Repository/AssetRepositoryManager.php

+19-1
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515
use Composer\IO\IOInterface;
1616
use Composer\Repository\RepositoryInterface;
1717
use Composer\Repository\RepositoryManager;
18+
use Fxp\Composer\AssetPlugin\Config\Config;
1819

1920
/**
2021
* The asset repository manager.
@@ -33,6 +34,11 @@ class AssetRepositoryManager
3334
*/
3435
protected $rm;
3536

37+
/**
38+
* @var Config
39+
*/
40+
protected $config;
41+
3642
/**
3743
* @var VcsPackageFilter
3844
*/
@@ -63,12 +69,14 @@ class AssetRepositoryManager
6369
*
6470
* @param IOInterface $io The IO
6571
* @param RepositoryManager $rm The repository manager
72+
* @param Config $config The asset config
6673
* @param VcsPackageFilter $packageFilter The package filter
6774
*/
68-
public function __construct(IOInterface $io, RepositoryManager $rm, VcsPackageFilter $packageFilter)
75+
public function __construct(IOInterface $io, RepositoryManager $rm, Config $config, VcsPackageFilter $packageFilter)
6976
{
7077
$this->io = $io;
7178
$this->rm = $rm;
79+
$this->config = $config;
7280
$this->packageFilter = $packageFilter;
7381
}
7482

@@ -82,6 +90,16 @@ public function getRepositoryManager()
8290
return $this->rm;
8391
}
8492

93+
/**
94+
* Get the asset config.
95+
*
96+
* @return Config
97+
*/
98+
public function getConfig()
99+
{
100+
return $this->config;
101+
}
102+
85103
/**
86104
* Set the pool.
87105
*

Tests/Repository/AbstractAssetsRepositoryTest.php

+3-2
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
1717
use Composer\EventDispatcher\EventDispatcher;
1818
use Composer\IO\IOInterface;
1919
use Composer\Repository\RepositoryManager;
20+
use Fxp\Composer\AssetPlugin\Config\Config as AssetConfig;
2021
use Fxp\Composer\AssetPlugin\Repository\AbstractAssetsRepository;
2122
use Fxp\Composer\AssetPlugin\Repository\AssetRepositoryManager;
2223
use Fxp\Composer\AssetPlugin\Repository\AssetVcsRepository;
@@ -45,7 +46,7 @@ abstract class AbstractAssetsRepositoryTest extends \PHPUnit_Framework_TestCase
4546
protected $rm;
4647

4748
/**
48-
* @var AssetRepositoryManager|\PHPUnit_Framework_MockObject_MockObject
49+
* @var AssetRepositoryManager
4950
*/
5051
protected $assertRepositoryManager;
5152

@@ -77,7 +78,7 @@ protected function setUp()
7778
$filter = $this->getMockBuilder(VcsPackageFilter::class)->disableOriginalConstructor()->getMock();
7879
$rm = new RepositoryManager($io, $config);
7980
$rm->setRepositoryClass($this->getType().'-vcs', 'Fxp\Composer\AssetPlugin\Tests\Fixtures\Repository\MockAssetRepository');
80-
$this->assertRepositoryManager = new AssetRepositoryManager($io, $rm, $filter);
81+
$this->assertRepositoryManager = new AssetRepositoryManager($io, $rm, new AssetConfig(array()), $filter);
8182
$repoConfig = array_merge(array(
8283
'asset-repository-manager' => $this->assertRepositoryManager,
8384
'asset-options' => array(

Tests/Repository/AssetRepositoryManagerTest.php

+13-1
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515
use Composer\IO\IOInterface;
1616
use Composer\Repository\RepositoryInterface;
1717
use Composer\Repository\RepositoryManager;
18+
use Fxp\Composer\AssetPlugin\Config\Config;
1819
use Fxp\Composer\AssetPlugin\Repository\AssetRepositoryManager;
1920
use Fxp\Composer\AssetPlugin\Repository\ResolutionManager;
2021
use Fxp\Composer\AssetPlugin\Repository\VcsPackageFilter;
@@ -36,6 +37,11 @@ class AssetRepositoryManagerTest extends \PHPUnit_Framework_TestCase
3637
*/
3738
protected $io;
3839

40+
/**
41+
* @var Config
42+
*/
43+
protected $config;
44+
3945
/**
4046
* @var VcsPackageFilter|\PHPUnit_Framework_MockObject_MockObject
4147
*/
@@ -55,10 +61,11 @@ protected function setUp()
5561
{
5662
$this->io = $this->getMockBuilder(IOInterface::class)->getMock();
5763
$this->rm = $this->getMockBuilder(RepositoryManager::class)->disableOriginalConstructor()->getMock();
64+
$this->config = new Config(array());
5865
$this->filter = $this->getMockBuilder(VcsPackageFilter::class)->disableOriginalConstructor()->getMock();
5966

6067
$this->resolutionManager = $this->getMockBuilder(ResolutionManager::class)->getMock();
61-
$this->assertRepositoryManager = new AssetRepositoryManager($this->io, $this->rm, $this->filter);
68+
$this->assertRepositoryManager = new AssetRepositoryManager($this->io, $this->rm, $this->config, $this->filter);
6269
}
6370

6471
public function getDataForSolveResolutions()
@@ -128,4 +135,9 @@ public function testAddRepositoryInPool()
128135

129136
$this->assertRepositoryManager->setPool($pool);
130137
}
138+
139+
public function testGetConfig()
140+
{
141+
$this->assertSame($this->config, $this->assertRepositoryManager->getConfig());
142+
}
131143
}

0 commit comments

Comments
 (0)