@@ -286,6 +286,41 @@ function ($args) use (&$packages) {
286
286
$ this ->assertArrayHasKey ('monolog/monolog ' , $ packages );
287
287
}
288
288
289
+ /**
290
+ * Given a root package with no requires
291
+ * and a subdirectory/composer.local.json with one require, which includes a composer.local.2.json
292
+ * and a subdirectory/composer.local.2.json with one additional require
293
+ * When the plugin is run
294
+ * Then the root package should inherit both requires
295
+ * and no modifications should be made by the pre-dependency hook.
296
+ */
297
+ public function testRecursiveIncludesWithSubDirectory ()
298
+ {
299
+ $ dir = $ this ->fixtureDir (__FUNCTION__ );
300
+
301
+ $ root = $ this ->rootFromJson ("{$ dir }/composer.json " );
302
+
303
+ $ packages = array ();
304
+ $ root ->setRequires (Argument::type ('array ' ))->will (
305
+ function ($ args ) use (&$ packages ) {
306
+ $ packages = array_merge ($ packages , $ args [0 ]);
307
+ }
308
+ );
309
+
310
+ $ root ->getRepositories ()->shouldNotBeCalled ();
311
+ $ root ->getConflicts ()->shouldNotBeCalled ();
312
+ $ root ->getReplaces ()->shouldNotBeCalled ();
313
+ $ root ->getProvides ()->shouldNotBeCalled ();
314
+ $ root ->getSuggests ()->shouldNotBeCalled ();
315
+
316
+ $ extraInstalls = $ this ->triggerPlugin ($ root ->reveal (), $ dir );
317
+
318
+ $ this ->assertArrayHasKey ('foo ' , $ packages );
319
+ $ this ->assertArrayHasKey ('monolog/monolog ' , $ packages );
320
+
321
+ $ this ->assertEquals (null , $ extraInstalls );
322
+ }
323
+
289
324
/**
290
325
* Given a root package with no requires that disables recursion
291
326
* and a composer.local.json with one require, which includes a composer.local.2.json
@@ -319,6 +354,162 @@ function ($args) use (&$packages) {
319
354
$ this ->assertArrayNotHasKey ('monolog/monolog ' , $ packages );
320
355
}
321
356
357
+ /**
358
+ * Given a root package with no requires
359
+ * and a subdirectory/composer.local.json with one require, which includes a composer.local.2.json
360
+ * and a subdirectory/composer.local.2.json with one additional require and a repository of type 'path'
361
+ * and url with a value of 'localdirectory'
362
+ * When the plugin is run
363
+ * Then the root package should inherit both requires
364
+ * and should have the repository path url fixed to 'subdirectory/localdirectory'
365
+ * and no modifications should be made by the pre-dependency hook.
366
+ */
367
+ public function testRecursivePathRepositoriesWithSubDirectory ()
368
+ {
369
+ $ that = $ this ;
370
+ $ io = $ this ->io ;
371
+ $ dir = $ this ->fixtureDir (__FUNCTION__ );
372
+
373
+ $ repoManager = $ this ->prophesize (
374
+ 'Composer\Repository\RepositoryManager '
375
+ );
376
+ $ repoManager ->createRepository (
377
+ Argument::type ('string ' ),
378
+ Argument::type ('array ' )
379
+ )->will (
380
+ function ($ args ) use ($ that , $ io ) {
381
+ $ that ->assertEquals ('path ' , $ args [0 ]);
382
+ $ that ->assertEquals (
383
+ 'subdirectory/local/directory ' ,
384
+ $ args [1 ]['url ' ]
385
+ );
386
+
387
+ return new \Composer \Repository \PathRepository (
388
+ $ args [1 ],
389
+ $ io ->reveal (),
390
+ new \Composer \Config ()
391
+ );
392
+ }
393
+ );
394
+ $ repoManager ->prependRepository (Argument::any ())->will (
395
+ function ($ args ) use ($ that ) {
396
+ $ that ->assertInstanceOf (
397
+ 'Composer\Repository\PathRepository ' ,
398
+ $ args [0 ]
399
+ );
400
+ }
401
+ );
402
+ $ this ->composer ->getRepositoryManager ()->will (
403
+ function () use ($ repoManager ) {
404
+ return $ repoManager ->reveal ();
405
+ }
406
+ );
407
+
408
+ $ root = $ this ->rootFromJson ("{$ dir }/composer.json " );
409
+
410
+ $ packages = array ();
411
+ $ root ->setRequires (Argument::type ('array ' ))->will (
412
+ function ($ args ) use (&$ packages ) {
413
+ $ packages = array_merge ($ packages , $ args [0 ]);
414
+ }
415
+ );
416
+
417
+ $ root ->setDevRequires ()->shouldNotBeCalled ();
418
+
419
+ $ root ->setRepositories (Argument::type ('array ' ))->will (
420
+ function ($ args ) use ($ that ) {
421
+ $ repos = $ args [0 ];
422
+ $ that ->assertEquals (1 , count ($ repos ));
423
+ }
424
+ );
425
+
426
+ $ root ->getConflicts ()->shouldNotBeCalled ();
427
+ $ root ->getReplaces ()->shouldNotBeCalled ();
428
+ $ root ->getProvides ()->shouldNotBeCalled ();
429
+ $ root ->getSuggests ()->shouldNotBeCalled ();
430
+
431
+ $ extraInstalls = $ this ->triggerPlugin ($ root ->reveal (), $ dir );
432
+
433
+ $ this ->assertArrayHasKey ('foo ' , $ packages );
434
+ $ this ->assertArrayHasKey ('wikimedia/composer-merge-plugin ' , $ packages );
435
+
436
+ $ this ->assertEquals (null , $ extraInstalls );
437
+ }
438
+
439
+
440
+ /**
441
+ * Given a root package with no requires
442
+ * and a composer.local.json with one require, which requires a composer.local.2.json
443
+ * and a composer.local.2.json with one additional require
444
+ * When the plugin is run
445
+ * Then the root package should inherit both requires
446
+ * and no modifications should be made by the pre-dependency hook.
447
+ */
448
+ public function testRecursiveRequires ()
449
+ {
450
+ $ dir = $ this ->fixtureDir (__FUNCTION__ );
451
+
452
+ $ root = $ this ->rootFromJson ("{$ dir }/composer.json " );
453
+
454
+ $ packages = array ();
455
+
456
+ $ root ->setRequires (Argument::type ('array ' ))->will (
457
+ function ($ args ) use (&$ packages ) {
458
+ $ packages = array_merge ($ packages , $ args [0 ]);
459
+ }
460
+ );
461
+
462
+ $ root ->getRepositories ()->shouldNotBeCalled ();
463
+ $ root ->getConflicts ()->shouldNotBeCalled ();
464
+ $ root ->getReplaces ()->shouldNotBeCalled ();
465
+ $ root ->getProvides ()->shouldNotBeCalled ();
466
+ $ root ->getSuggests ()->shouldNotBeCalled ();
467
+
468
+ $ extraInstalls = $ this ->triggerPlugin ($ root ->reveal (), $ dir );
469
+
470
+
471
+
472
+ $ this ->assertArrayHasKey ('foo ' , $ packages );
473
+ $ this ->assertArrayHasKey ('monolog/monolog ' , $ packages );
474
+
475
+ $ this ->assertEquals (null , $ extraInstalls );
476
+ }
477
+
478
+ /**
479
+ * Given a root package with no requires
480
+ * and a subdirectory/composer.local.json with one require, which requires a composer.local.2.json
481
+ * and a subdirectory/composer.local.2.json with one additional require
482
+ * When the plugin is run
483
+ * Then the root package should inherit both requires
484
+ * and no modifications should be made by the pre-dependency hook.
485
+ */
486
+ public function testRecursiveRequiresWithSubDirectory ()
487
+ {
488
+ $ dir = $ this ->fixtureDir (__FUNCTION__ );
489
+
490
+ $ root = $ this ->rootFromJson ("{$ dir }/composer.json " );
491
+
492
+ $ packages = array ();
493
+ $ root ->setRequires (Argument::type ('array ' ))->will (
494
+ function ($ args ) use (&$ packages ) {
495
+ $ packages = array_merge ($ packages , $ args [0 ]);
496
+ }
497
+ );
498
+
499
+ $ root ->getRepositories ()->shouldNotBeCalled ();
500
+ $ root ->getConflicts ()->shouldNotBeCalled ();
501
+ $ root ->getReplaces ()->shouldNotBeCalled ();
502
+ $ root ->getProvides ()->shouldNotBeCalled ();
503
+ $ root ->getSuggests ()->shouldNotBeCalled ();
504
+
505
+ $ extraInstalls = $ this ->triggerPlugin ($ root ->reveal (), $ dir );
506
+
507
+ $ this ->assertArrayHasKey ('foo ' , $ packages );
508
+ $ this ->assertArrayHasKey ('monolog/monolog ' , $ packages );
509
+
510
+ $ this ->assertEquals (null , $ extraInstalls );
511
+ }
512
+
322
513
/**
323
514
* Given a root package with requires
324
515
* and a composer.local.json with requires
0 commit comments