1414
1515use Composer \Util \Perforce ;
1616use PHPUnit \Framework \TestCase ;
17+ use Composer \Util \ProcessExecutor ;
1718
1819/**
1920 * @author Matt Whittom <Matt.Whittom@veteransunited.com>
@@ -344,7 +345,7 @@ public function testGetBranchesWithStream()
344345 {
345346 $ this ->setPerforceToStream ();
346347
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/... ') ;
348349 $ this ->processExecutor ->expects ($ this ->at (0 ))
349350 ->method ('execute ' )
350351 ->with ($ this ->equalTo ($ expectedCommand ))
@@ -357,7 +358,7 @@ function ($command, &$output) {
357358 }
358359 )
359360 );
360- $ expectedCommand2 = 'p4 -u user -p port changes //depot/branch/... ' ;
361+ $ expectedCommand2 = 'p4 -u user -p port changes ' .ProcessExecutor:: escape ( ' //depot/branch/... ') ;
361362 $ expectedCallback = function ($ command , &$ output ) {
362363 $ output = 'Change 1234 on 2014/03/19 by Clark.Stuth@Clark.Stuth_test_client \'test changelist \'' ;
363364
@@ -374,7 +375,7 @@ function ($command, &$output) {
374375
375376 public function testGetBranchesWithoutStream ()
376377 {
377- $ expectedCommand = 'p4 -u user -p port changes //depot/... ' ;
378+ $ expectedCommand = 'p4 -u user -p port changes ' .ProcessExecutor:: escape ( ' //depot/... ') ;
378379 $ expectedCallback = function ($ command , &$ output ) {
379380 $ output = 'Change 5678 on 2014/03/19 by Clark.Stuth@Clark.Stuth_test_client \'test changelist \'' ;
380381
@@ -458,7 +459,7 @@ function ($command, &$output) {
458459
459460 public function testGetComposerInformationWithoutLabelWithoutStream ()
460461 {
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 ') ;
462463 $ this ->processExecutor ->expects ($ this ->at (0 ))
463464 ->method ('execute ' )
464465 ->with ($ this ->equalTo ($ expectedCommand ))
@@ -484,7 +485,7 @@ function ($command, &$output) {
484485
485486 public function testGetComposerInformationWithLabelWithoutStream ()
486487 {
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 ') ;
488489 $ this ->processExecutor ->expects ($ this ->at (0 ))
489490 ->method ('execute ' )
490491 ->with ($ this ->equalTo ($ expectedCommand ))
@@ -498,7 +499,7 @@ function ($command, &$output) {
498499 )
499500 );
500501
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 ') ;
502503 $ this ->processExecutor ->expects ($ this ->at (1 ))
503504 ->method ('execute ' )
504505 ->with ($ this ->equalTo ($ expectedCommand ))
@@ -527,7 +528,7 @@ public function testGetComposerInformationWithoutLabelWithStream()
527528 {
528529 $ this ->setPerforceToStream ();
529530
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 ') ;
531532 $ this ->processExecutor ->expects ($ this ->at (0 ))
532533 ->method ('execute ' )
533534 ->with ($ this ->equalTo ($ expectedCommand ))
@@ -555,7 +556,7 @@ function ($command, &$output) {
555556 public function testGetComposerInformationWithLabelWithStream ()
556557 {
557558 $ 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 ') ;
559560 $ this ->processExecutor ->expects ($ this ->at (0 ))
560561 ->method ('execute ' )
561562 ->with ($ this ->equalTo ($ expectedCommand ))
@@ -569,7 +570,7 @@ function ($command, &$output) {
569570 )
570571 );
571572
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 ') ;
573574 $ this ->processExecutor ->expects ($ this ->at (1 ))
574575 ->method ('execute ' )
575576 ->with ($ this ->equalTo ($ expectedCommand ))
@@ -621,7 +622,7 @@ public function testCheckServerExists()
621622 {
622623 $ processExecutor = $ this ->getMockBuilder ('Composer\Util\ProcessExecutor ' )->getMock ();
623624
624- $ expectedCommand = 'p4 -p perforce.does.exist:port info -s ' ;
625+ $ expectedCommand = 'p4 -p ' .ProcessExecutor:: escape ( ' perforce.does.exist:port ' ). ' info -s ' ;
625626 $ processExecutor ->expects ($ this ->at (0 ))
626627 ->method ('execute ' )
627628 ->with ($ this ->equalTo ($ expectedCommand ), $ this ->equalTo (null ))
@@ -642,7 +643,7 @@ public function testCheckServerClientError()
642643 {
643644 $ processExecutor = $ this ->getMockBuilder ('Composer\Util\ProcessExecutor ' )->getMock ();
644645
645- $ expectedCommand = 'p4 -p perforce.does.exist:port info -s ' ;
646+ $ expectedCommand = 'p4 -p ' .ProcessExecutor:: escape ( ' perforce.does.exist:port ' ). ' info -s ' ;
646647 $ processExecutor ->expects ($ this ->at (0 ))
647648 ->method ('execute ' )
648649 ->with ($ this ->equalTo ($ expectedCommand ), $ this ->equalTo (null ))
@@ -712,7 +713,7 @@ public function testCleanupClientSpecShouldDeleteClient()
712713 $ this ->perforce ->setFilesystem ($ fs );
713714
714715 $ 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) ;
716717 $ this ->processExecutor ->expects ($ this ->once ())->method ('execute ' )->with ($ this ->equalTo ($ expectedCommand ));
717718
718719 $ fs ->expects ($ this ->once ())->method ('remove ' )->with ($ this ->perforce ->getP4ClientSpec ());
0 commit comments