14
14
15
15
use Composer \Util \Perforce ;
16
16
use PHPUnit \Framework \TestCase ;
17
+ use Composer \Util \ProcessExecutor ;
17
18
18
19
/**
19
20
* @author Matt Whittom <Matt.Whittom@veteransunited.com>
@@ -344,7 +345,7 @@ public function testGetBranchesWithStream()
344
345
{
345
346
$ this ->setPerforceToStream ();
346
347
347
- $ expectedCommand = 'p4 -u user -c composer_perforce_TEST_depot_branch -p port streams //depot/... ' ;
348
+ $ expectedCommand = 'p4 -u user -c composer_perforce_TEST_depot_branch -p port streams ' .ProcessExecutor:: escape ( ' //depot/... ') ;
348
349
$ this ->processExecutor ->expects ($ this ->at (0 ))
349
350
->method ('execute ' )
350
351
->with ($ this ->equalTo ($ expectedCommand ))
@@ -357,7 +358,7 @@ function ($command, &$output) {
357
358
}
358
359
)
359
360
);
360
- $ expectedCommand2 = 'p4 -u user -p port changes //depot/branch/... ' ;
361
+ $ expectedCommand2 = 'p4 -u user -p port changes ' .ProcessExecutor:: escape ( ' //depot/branch/... ') ;
361
362
$ expectedCallback = function ($ command , &$ output ) {
362
363
$ output = 'Change 1234 on 2014/03/19 by Clark.Stuth@Clark.Stuth_test_client \'test changelist \'' ;
363
364
@@ -374,7 +375,7 @@ function ($command, &$output) {
374
375
375
376
public function testGetBranchesWithoutStream ()
376
377
{
377
- $ expectedCommand = 'p4 -u user -p port changes //depot/... ' ;
378
+ $ expectedCommand = 'p4 -u user -p port changes ' .ProcessExecutor:: escape ( ' //depot/... ') ;
378
379
$ expectedCallback = function ($ command , &$ output ) {
379
380
$ output = 'Change 5678 on 2014/03/19 by Clark.Stuth@Clark.Stuth_test_client \'test changelist \'' ;
380
381
@@ -458,7 +459,7 @@ function ($command, &$output) {
458
459
459
460
public function testGetComposerInformationWithoutLabelWithoutStream ()
460
461
{
461
- $ expectedCommand = 'p4 -u user -c composer_perforce_TEST_depot -p port print //depot/composer.json ' ;
462
+ $ expectedCommand = 'p4 -u user -c composer_perforce_TEST_depot -p port print ' .ProcessExecutor:: escape ( ' //depot/composer.json ') ;
462
463
$ this ->processExecutor ->expects ($ this ->at (0 ))
463
464
->method ('execute ' )
464
465
->with ($ this ->equalTo ($ expectedCommand ))
@@ -484,7 +485,7 @@ function ($command, &$output) {
484
485
485
486
public function testGetComposerInformationWithLabelWithoutStream ()
486
487
{
487
- $ expectedCommand = 'p4 -u user -p port files //depot/composer.json@0.0.1 ' ;
488
+ $ expectedCommand = 'p4 -u user -p port files ' .ProcessExecutor:: escape ( ' //depot/composer.json@0.0.1 ') ;
488
489
$ this ->processExecutor ->expects ($ this ->at (0 ))
489
490
->method ('execute ' )
490
491
->with ($ this ->equalTo ($ expectedCommand ))
@@ -498,7 +499,7 @@ function ($command, &$output) {
498
499
)
499
500
);
500
501
501
- $ expectedCommand = 'p4 -u user -c composer_perforce_TEST_depot -p port print //depot/composer.json@10001 ' ;
502
+ $ expectedCommand = 'p4 -u user -c composer_perforce_TEST_depot -p port print ' .ProcessExecutor:: escape ( ' //depot/composer.json@10001 ') ;
502
503
$ this ->processExecutor ->expects ($ this ->at (1 ))
503
504
->method ('execute ' )
504
505
->with ($ this ->equalTo ($ expectedCommand ))
@@ -527,7 +528,7 @@ public function testGetComposerInformationWithoutLabelWithStream()
527
528
{
528
529
$ this ->setPerforceToStream ();
529
530
530
- $ expectedCommand = 'p4 -u user -c composer_perforce_TEST_depot_branch -p port print //depot/branch/composer.json ' ;
531
+ $ expectedCommand = 'p4 -u user -c composer_perforce_TEST_depot_branch -p port print ' .ProcessExecutor:: escape ( ' //depot/branch/composer.json ') ;
531
532
$ this ->processExecutor ->expects ($ this ->at (0 ))
532
533
->method ('execute ' )
533
534
->with ($ this ->equalTo ($ expectedCommand ))
@@ -555,7 +556,7 @@ function ($command, &$output) {
555
556
public function testGetComposerInformationWithLabelWithStream ()
556
557
{
557
558
$ this ->setPerforceToStream ();
558
- $ expectedCommand = 'p4 -u user -p port files //depot/branch/composer.json@0.0.1 ' ;
559
+ $ expectedCommand = 'p4 -u user -p port files ' .ProcessExecutor:: escape ( ' //depot/branch/composer.json@0.0.1 ') ;
559
560
$ this ->processExecutor ->expects ($ this ->at (0 ))
560
561
->method ('execute ' )
561
562
->with ($ this ->equalTo ($ expectedCommand ))
@@ -569,7 +570,7 @@ function ($command, &$output) {
569
570
)
570
571
);
571
572
572
- $ expectedCommand = 'p4 -u user -c composer_perforce_TEST_depot_branch -p port print //depot/branch/composer.json@10001 ' ;
573
+ $ expectedCommand = 'p4 -u user -c composer_perforce_TEST_depot_branch -p port print ' .ProcessExecutor:: escape ( ' //depot/branch/composer.json@10001 ') ;
573
574
$ this ->processExecutor ->expects ($ this ->at (1 ))
574
575
->method ('execute ' )
575
576
->with ($ this ->equalTo ($ expectedCommand ))
@@ -621,7 +622,7 @@ public function testCheckServerExists()
621
622
{
622
623
$ processExecutor = $ this ->getMockBuilder ('Composer\Util\ProcessExecutor ' )->getMock ();
623
624
624
- $ expectedCommand = 'p4 -p perforce.does.exist:port info -s ' ;
625
+ $ expectedCommand = 'p4 -p ' .ProcessExecutor:: escape ( ' perforce.does.exist:port ' ). ' info -s ' ;
625
626
$ processExecutor ->expects ($ this ->at (0 ))
626
627
->method ('execute ' )
627
628
->with ($ this ->equalTo ($ expectedCommand ), $ this ->equalTo (null ))
@@ -642,7 +643,7 @@ public function testCheckServerClientError()
642
643
{
643
644
$ processExecutor = $ this ->getMockBuilder ('Composer\Util\ProcessExecutor ' )->getMock ();
644
645
645
- $ expectedCommand = 'p4 -p perforce.does.exist:port info -s ' ;
646
+ $ expectedCommand = 'p4 -p ' .ProcessExecutor:: escape ( ' perforce.does.exist:port ' ). ' info -s ' ;
646
647
$ processExecutor ->expects ($ this ->at (0 ))
647
648
->method ('execute ' )
648
649
->with ($ this ->equalTo ($ expectedCommand ), $ this ->equalTo (null ))
@@ -712,7 +713,7 @@ public function testCleanupClientSpecShouldDeleteClient()
712
713
$ this ->perforce ->setFilesystem ($ fs );
713
714
714
715
$ testClient = $ this ->perforce ->getClient ();
715
- $ expectedCommand = 'p4 -u ' . self ::TEST_P4USER . ' -p ' . self ::TEST_PORT . ' client -d ' . $ testClient ;
716
+ $ expectedCommand = 'p4 -u ' . self ::TEST_P4USER . ' -p ' . self ::TEST_PORT . ' client -d ' . ProcessExecutor:: escape ( $ testClient) ;
716
717
$ this ->processExecutor ->expects ($ this ->once ())->method ('execute ' )->with ($ this ->equalTo ($ expectedCommand ));
717
718
718
719
$ fs ->expects ($ this ->once ())->method ('remove ' )->with ($ this ->perforce ->getP4ClientSpec ());
0 commit comments