11
11
namespace Wikimedia \Composer \Merge \V2 ;
12
12
13
13
use Composer \Composer ;
14
+ use Composer \Config ;
14
15
use Composer \DependencyResolver \Operation \InstallOperation ;
16
+ use Composer \Installer \PackageEvent ;
15
17
use Composer \Installer \PackageEvents ;
16
18
use Composer \IO \IOInterface ;
17
19
use Composer \Package \BasePackage ;
18
20
use Composer \Package \Link ;
21
+ use Composer \Package \Locker ;
19
22
use Composer \Package \Package ;
23
+ use Composer \Package \RootAliasPackage ;
20
24
use Composer \Package \RootPackage ;
25
+ use Composer \Package \RootPackageInterface ;
21
26
use Composer \Package \Version \VersionParser ;
22
27
use Composer \Plugin \PluginEvents ;
23
28
use Composer \Plugin \PluginInterface ;
29
+ use Composer \Repository \PathRepository ;
30
+ use Composer \Repository \RepositoryManager ;
31
+ use Composer \Repository \VcsRepository ;
24
32
use Composer \Script \Event ;
25
33
use Composer \Script \ScriptEvents ;
34
+ use Composer \Util \HttpDownloader ;
26
35
use Prophecy \Argument ;
27
36
use PHPUnit \Framework \TestCase ;
28
37
use Prophecy \Prophecy \ObjectProphecy ;
38
+ use ReflectionClass ;
29
39
use ReflectionProperty ;
30
40
31
41
/**
@@ -57,8 +67,8 @@ class MergePluginTest extends TestCase
57
67
protected function setUp (): void
58
68
{
59
69
parent ::setUp ();
60
- $ this ->composer = $ this ->prophesize (\ Composer \ Composer::class);
61
- $ this ->io = $ this ->prophesize (\ Composer \ IO \ IOInterface::class);
70
+ $ this ->composer = $ this ->prophesize (Composer::class);
71
+ $ this ->io = $ this ->prophesize (IOInterface::class);
62
72
63
73
$ this ->fixture = new MergePlugin ();
64
74
$ this ->fixture ->activate (
@@ -370,7 +380,7 @@ public function testRecursivePathRepositoriesWithSubDirectory()
370
380
$ dir = $ this ->fixtureDir (__FUNCTION__ );
371
381
372
382
$ repoManager = $ this ->prophesize (
373
- \ Composer \ Repository \ RepositoryManager::class
383
+ RepositoryManager::class
374
384
);
375
385
$ repoManager ->createRepository (
376
386
Argument::type ('string ' ),
@@ -383,17 +393,17 @@ function ($args) use ($that, $io) {
383
393
$ args [1 ]['url ' ]
384
394
);
385
395
386
- return new \ Composer \ Repository \ PathRepository (
396
+ return new PathRepository (
387
397
$ args [1 ],
388
398
$ io ->reveal (),
389
- new \ Composer \ Config ()
399
+ new Config ()
390
400
);
391
401
}
392
402
);
393
403
$ repoManager ->prependRepository (Argument::any ())->will (
394
404
function ($ args ) use ($ that ) {
395
405
$ that ->assertInstanceOf (
396
- \ Composer \ Repository \ PathRepository::class,
406
+ PathRepository::class,
397
407
$ args [0 ]
398
408
);
399
409
}
@@ -569,7 +579,7 @@ public function testMergedRepositories()
569
579
$ dir = $ this ->fixtureDir (__FUNCTION__ );
570
580
571
581
$ repoManager = $ this ->prophesize (
572
- \ Composer \ Repository \ RepositoryManager::class
582
+ RepositoryManager::class
573
583
);
574
584
$ repoManager ->createRepository (
575
585
Argument::type ('string ' ),
@@ -582,20 +592,20 @@ function ($args) use ($that, $io) {
582
592
$ args [1 ]['url ' ]
583
593
);
584
594
585
- $ config = new \ Composer \ Config ();
595
+ $ config = new Config ();
586
596
$ mockIO = $ io ->reveal ();
587
597
if (version_compare ('2.0.0 ' , PluginInterface::PLUGIN_API_VERSION , '> ' )) {
588
- return new \ Composer \ Repository \ VcsRepository (
598
+ return new VcsRepository (
589
599
$ args [1 ],
590
600
$ mockIO ,
591
601
$ config
592
602
);
593
603
} else {
594
- $ httpDownloader = new \ Composer \ Util \ HttpDownloader (
604
+ $ httpDownloader = new HttpDownloader (
595
605
$ mockIO ,
596
606
$ config
597
607
);
598
- return new \ Composer \ Repository \ VcsRepository (
608
+ return new VcsRepository (
599
609
$ args [1 ],
600
610
$ mockIO ,
601
611
$ config ,
@@ -607,7 +617,7 @@ function ($args) use ($that, $io) {
607
617
$ repoManager ->prependRepository (Argument::any ())->will (
608
618
function ($ args ) use ($ that ) {
609
619
$ that ->assertInstanceOf (
610
- \ Composer \ Repository \ VcsRepository::class,
620
+ VcsRepository::class,
611
621
$ args [0 ]
612
622
);
613
623
}
@@ -661,7 +671,7 @@ public function testPrependRepositories()
661
671
$ dir = $ this ->fixtureDir (__FUNCTION__ );
662
672
663
673
$ repoManager = $ this ->prophesize (
664
- \ Composer \ Repository \ RepositoryManager::class
674
+ RepositoryManager::class
665
675
);
666
676
$ repoManager ->createRepository (
667
677
Argument::type ('string ' ),
@@ -674,21 +684,21 @@ function ($args) use ($that, $io) {
674
684
$ args [1 ]['url ' ]
675
685
);
676
686
677
- $ config = new \ Composer \ Config ();
687
+ $ config = new Config ();
678
688
$ mockIO = $ io ->reveal ();
679
689
if (version_compare ('2.0.0 ' , PluginInterface::PLUGIN_API_VERSION , '> ' )) {
680
- return new \ Composer \ Repository \ VcsRepository (
690
+ return new VcsRepository (
681
691
$ args [1 ],
682
692
$ mockIO ,
683
693
$ config
684
694
);
685
695
} else {
686
- $ httpDownloader = new \ Composer \ Util \ HttpDownloader (
696
+ $ httpDownloader = new HttpDownloader (
687
697
$ mockIO ,
688
698
$ config
689
699
);
690
700
691
- return new \ Composer \ Repository \ VcsRepository (
701
+ return new VcsRepository (
692
702
$ args [1 ],
693
703
$ mockIO ,
694
704
$ config ,
@@ -700,7 +710,7 @@ function ($args) use ($that, $io) {
700
710
$ repoManager ->prependRepository (Argument::any ())->will (
701
711
function ($ args ) use ($ that ) {
702
712
$ that ->assertInstanceOf (
703
- \ Composer \ Repository \ VcsRepository::class,
713
+ VcsRepository::class,
704
714
$ args [0 ]
705
715
);
706
716
}
@@ -721,11 +731,11 @@ function ($args) use ($that) {
721
731
$ repos = $ args [0 ];
722
732
$ that ->assertCount (2 , $ repos );
723
733
$ prependedRepo = $ repos [0 ];
724
- $ that ->assertInstanceOf (\ Composer \ Repository \ VcsRepository::class, $ prependedRepo );
734
+ $ that ->assertInstanceOf (VcsRepository::class, $ prependedRepo );
725
735
// Ugly, be we need to check a protected member variable and
726
736
// PHPUnit decided that having the assertAttributeEquals
727
737
// assertion to make that easy was a code smell.
728
- $ clazz = new \ ReflectionClass ($ prependedRepo );
738
+ $ clazz = new ReflectionClass ($ prependedRepo );
729
739
$ url = $ clazz ->getProperty ('url ' );
730
740
$ url ->setAccessible (true );
731
741
$ that ->assertEquals (
@@ -1191,11 +1201,11 @@ public function testOnPostPackageInstall($package, $first, $locked)
1191
1201
$ operation = new InstallOperation (
1192
1202
new Package ($ package , '1.2.3.4 ' , '1.2.3 ' )
1193
1203
);
1194
- $ event = $ this ->prophesize (\ Composer \ Installer \ PackageEvent::class);
1204
+ $ event = $ this ->prophesize (PackageEvent::class);
1195
1205
$ event ->getOperation ()->willReturn ($ operation )->shouldBeCalled ();
1196
1206
1197
1207
if ($ first ) {
1198
- $ locker = $ this ->prophesize (\ Composer \ Package \ Locker::class);
1208
+ $ locker = $ this ->prophesize (Locker::class);
1199
1209
$ locker ->isLocked ()->willReturn ($ locked )
1200
1210
->shouldBeCalled ();
1201
1211
$ this ->composer ->getLocker ()->willReturn ($ locker ->reveal ())
@@ -1242,32 +1252,32 @@ public function testHasBranchAlias($fireInit)
1242
1252
// RootAliasPackage was updated in 06c44ce to include more setters
1243
1253
// that we take advantage of if available
1244
1254
$ haveComposerWithCompleteRootAlias = method_exists (
1245
- \ Composer \ Package \ RootPackageInterface::class,
1255
+ RootPackageInterface::class,
1246
1256
'setRepositories '
1247
1257
);
1248
1258
1249
1259
$ repoManager = $ this ->prophesize (
1250
- \ Composer \ Repository \ RepositoryManager::class
1260
+ RepositoryManager::class
1251
1261
);
1252
1262
$ repoManager ->createRepository (
1253
1263
Argument::type ('string ' ),
1254
1264
Argument::type ('array ' )
1255
1265
)->will (function ($ args ) use ($ io ) {
1256
- $ config = new \ Composer \ Config ();
1266
+ $ config = new Config ();
1257
1267
$ mockIO = $ io ->reveal ();
1258
1268
if (version_compare ('2.0.0 ' , PluginInterface::PLUGIN_API_VERSION , '> ' )) {
1259
- return new \ Composer \ Repository \ VcsRepository (
1269
+ return new VcsRepository (
1260
1270
$ args [1 ],
1261
1271
$ mockIO ,
1262
1272
$ config
1263
1273
);
1264
1274
} else {
1265
- $ httpDownloader = new \ Composer \ Util \ HttpDownloader (
1275
+ $ httpDownloader = new HttpDownloader (
1266
1276
$ mockIO ,
1267
1277
$ config
1268
1278
);
1269
1279
1270
- return new \ Composer \ Repository \ VcsRepository (
1280
+ return new VcsRepository (
1271
1281
$ args [1 ],
1272
1282
$ mockIO ,
1273
1283
$ config ,
@@ -1724,7 +1734,7 @@ protected function rootFromJson($file)
1724
1734
}
1725
1735
}
1726
1736
1727
- $ root = $ this ->prophesize (\ Composer \ Package \ RootPackage::class);
1737
+ $ root = $ this ->prophesize (RootPackage::class);
1728
1738
$ root ->getVersion ()->willReturn ($ vp ->normalize ($ data ['version ' ]));
1729
1739
$ root ->getPrettyVersion ()->willReturn ($ data ['version ' ]);
1730
1740
$ root ->getMinimumStability ()->willReturn ($ data ['minimum-stability ' ]);
@@ -1762,7 +1772,7 @@ function ($args) use ($that) {
1762
1772
*/
1763
1773
protected function makeAliasFor ($ root )
1764
1774
{
1765
- $ alias = $ this ->prophesize (\ Composer \ Package \ RootAliasPackage::class);
1775
+ $ alias = $ this ->prophesize (RootAliasPackage::class);
1766
1776
$ alias ->getAliasOf ()->willReturn ($ root );
1767
1777
$ alias ->getVersion ()->will (function () use ($ root ) {
1768
1778
return $ root ->getVersion ();
0 commit comments