@@ -32,6 +32,9 @@ public function setUp()
32
32
$ this ->config = new Config ();
33
33
$ this ->composer ->setConfig ($ this ->config );
34
34
35
+ $ this ->rootDir = realpath (sys_get_temp_dir ()) . DIRECTORY_SEPARATOR . 'baton-test-root-package ' ;
36
+ $ this ->ensureDirectoryExistsAndClear ($ this ->rootDir );
37
+
35
38
$ this ->vendorDir = realpath (sys_get_temp_dir ()) . DIRECTORY_SEPARATOR . 'baton-test-vendor ' ;
36
39
$ this ->ensureDirectoryExistsAndClear ($ this ->vendorDir );
37
40
@@ -61,6 +64,7 @@ public function setUp()
61
64
*/
62
65
public function tearDown ()
63
66
{
67
+ $ this ->fs ->removeDirectory ($ this ->rootDir );
64
68
$ this ->fs ->removeDirectory ($ this ->vendorDir );
65
69
$ this ->fs ->removeDirectory ($ this ->binDir );
66
70
}
@@ -198,12 +202,17 @@ public function dataForTestSupport()
198
202
*/
199
203
public function testInstallPath ($ type , $ path , $ name , $ version = '1.0.0 ' )
200
204
{
205
+ $ currentWorkDir = getcwd ();
206
+ chdir ($ this ->rootDir );
207
+
201
208
$ installer = new Installer ($ this ->io , $ this ->composer );
202
209
$ package = new Package ($ name , $ version , $ version );
203
210
204
211
$ package ->setType ($ type );
205
212
$ result = $ installer ->getInstallPath ($ package );
206
- $ this ->assertEquals ($ path , $ result );
213
+ $ this ->assertEquals ($ this ->rootDir .'/ ' .$ path , $ result );
214
+
215
+ chdir ($ currentWorkDir );
207
216
}
208
217
209
218
/**
@@ -354,6 +363,9 @@ public function testGetCakePHPInstallPathException()
354
363
*/
355
364
public function testCustomInstallPath ()
356
365
{
366
+ $ currentWorkDir = getcwd ();
367
+ chdir ($ this ->rootDir );
368
+
357
369
$ installer = new Installer ($ this ->io , $ this ->composer );
358
370
$ package = new Package ('shama/ftp ' , '1.0.0 ' , '1.0.0 ' );
359
371
$ package ->setType ('cakephp-plugin ' );
@@ -368,29 +380,39 @@ public function testCustomInstallPath()
368
380
),
369
381
));
370
382
$ result = $ installer ->getInstallPath ($ package );
371
- $ this ->assertEquals ('my/custom/path/Ftp/ ' , $ result );
383
+ $ this ->assertEquals ($ this ->rootDir .'/my/custom/path/Ftp/ ' , $ result );
384
+
385
+ chdir ($ currentWorkDir );
372
386
}
373
387
374
388
/**
375
389
* testCustomInstallerName
376
390
*/
377
391
public function testCustomInstallerName ()
378
392
{
393
+ $ currentWorkDir = getcwd ();
394
+ chdir ($ this ->rootDir );
395
+
379
396
$ installer = new Installer ($ this ->io , $ this ->composer );
380
397
$ package = new Package ('shama/cakephp-ftp-plugin ' , '1.0.0 ' , '1.0.0 ' );
381
398
$ package ->setType ('cakephp-plugin ' );
382
399
$ package ->setExtra (array (
383
400
'installer-name ' => 'FTP ' ,
384
401
));
385
402
$ result = $ installer ->getInstallPath ($ package );
386
- $ this ->assertEquals ('Plugin/FTP/ ' , $ result );
403
+ $ this ->assertEquals ($ this ->rootDir .'/Plugin/FTP/ ' , $ result );
404
+
405
+ chdir ($ currentWorkDir );
387
406
}
388
407
389
408
/**
390
409
* testCustomTypePath
391
410
*/
392
411
public function testCustomTypePath ()
393
412
{
413
+ $ currentWorkDir = getcwd ();
414
+ chdir ($ this ->rootDir );
415
+
394
416
$ installer = new Installer ($ this ->io , $ this ->composer );
395
417
$ package = new Package ('slbmeh/my_plugin ' , '1.0.0 ' , '1.0.0 ' );
396
418
$ package ->setType ('wordpress-plugin ' );
@@ -404,14 +426,19 @@ public function testCustomTypePath()
404
426
),
405
427
));
406
428
$ result = $ installer ->getInstallPath ($ package );
407
- $ this ->assertEquals ('my/custom/path/my_plugin/ ' , $ result );
429
+ $ this ->assertEquals ($ this ->rootDir .'/my/custom/path/my_plugin/ ' , $ result );
430
+
431
+ chdir ($ currentWorkDir );
408
432
}
409
433
410
434
/**
411
435
* testVendorPath
412
436
*/
413
437
public function testVendorPath ()
414
438
{
439
+ $ currentWorkDir = getcwd ();
440
+ chdir ($ this ->rootDir );
441
+
415
442
$ installer = new Installer ($ this ->io , $ this ->composer );
416
443
$ package = new Package ('penyaskito/my_module ' , '1.0.0 ' , '1.0.0 ' );
417
444
$ package ->setType ('drupal-module ' );
@@ -425,27 +452,37 @@ public function testVendorPath()
425
452
),
426
453
));
427
454
$ result = $ installer ->getInstallPath ($ package );
428
- $ this ->assertEquals ('modules/custom/my_module/ ' , $ result );
455
+ $ this ->assertEquals ($ this ->rootDir .'/modules/custom/my_module/ ' , $ result );
456
+
457
+ chdir ($ currentWorkDir );
429
458
}
430
459
431
460
/**
432
461
* testNoVendorName
433
462
*/
434
463
public function testNoVendorName ()
435
464
{
465
+ $ currentWorkDir = getcwd ();
466
+ chdir ($ this ->rootDir );
467
+
436
468
$ installer = new Installer ($ this ->io , $ this ->composer );
437
469
$ package = new Package ('sfPhpunitPlugin ' , '1.0.0 ' , '1.0.0 ' );
438
470
439
471
$ package ->setType ('symfony1-plugin ' );
440
472
$ result = $ installer ->getInstallPath ($ package );
441
- $ this ->assertEquals ('plugins/sfPhpunitPlugin/ ' , $ result );
473
+ $ this ->assertEquals ($ this ->rootDir .'/plugins/sfPhpunitPlugin/ ' , $ result );
474
+
475
+ chdir ($ currentWorkDir );
442
476
}
443
477
444
478
/**
445
479
* testTypo3Inflection
446
480
*/
447
481
public function testTypo3Inflection ()
448
482
{
483
+ $ currentWorkDir = getcwd ();
484
+ chdir ($ this ->rootDir );
485
+
449
486
$ installer = new Installer ($ this ->io , $ this ->composer );
450
487
$ package = new Package ('typo3/fluid ' , '1.0.0 ' , '1.0.0 ' );
451
488
@@ -457,7 +494,9 @@ public function testTypo3Inflection()
457
494
458
495
$ package ->setType ('typo3-flow-package ' );
459
496
$ result = $ installer ->getInstallPath ($ package );
460
- $ this ->assertEquals ('Packages/Application/TYPO3.Fluid/ ' , $ result );
497
+ $ this ->assertEquals ($ this ->rootDir .'/Packages/Application/TYPO3.Fluid/ ' , $ result );
498
+
499
+ chdir ($ currentWorkDir );
461
500
}
462
501
463
502
public function testUninstallAndDeletePackageFromLocalRepo ()
0 commit comments