Updated to Drupal 8.5. Core Media not yet in use.
[yaffs-website] / vendor / symfony / process / Tests / ProcessBuilderTest.php
index cd0933f3263aa9682fa8fcb47e6ee208cd7d9147..36c40bf03fcc37ac223b39019911c016e2e26b33 100644 (file)
@@ -14,6 +14,9 @@ namespace Symfony\Component\Process\Tests;
 use PHPUnit\Framework\TestCase;
 use Symfony\Component\Process\ProcessBuilder;
 
+/**
+ * @group legacy
+ */
 class ProcessBuilderTest extends TestCase
 {
     public function testInheritEnvironmentVars()
@@ -23,6 +26,13 @@ class ProcessBuilderTest extends TestCase
             ->getProcess();
 
         $this->assertTrue($proc->areEnvironmentVariablesInherited());
+
+        $proc = ProcessBuilder::create()
+            ->add('foo')
+            ->inheritEnvironmentVariables(false)
+            ->getProcess();
+
+        $this->assertFalse($proc->areEnvironmentVariablesInherited());
     }
 
     public function testAddEnvironmentVariables()
@@ -36,12 +46,10 @@ class ProcessBuilderTest extends TestCase
             ->add('command')
             ->setEnv('foo', 'bar2')
             ->addEnvironmentVariables($env)
-            ->inheritEnvironmentVariables(false)
             ->getProcess()
         ;
 
         $this->assertSame($env, $proc->getEnv());
-        $this->assertFalse($proc->areEnvironmentVariablesInherited());
     }
 
     /**
@@ -83,14 +91,14 @@ class ProcessBuilderTest extends TestCase
 
         $proc = $pb->setArguments(array('-v'))->getProcess();
         if ('\\' === DIRECTORY_SEPARATOR) {
-            $this->assertEquals('"/usr/bin/php" "-v"', $proc->getCommandLine());
+            $this->assertEquals('"/usr/bin/php" -v', $proc->getCommandLine());
         } else {
             $this->assertEquals("'/usr/bin/php' '-v'", $proc->getCommandLine());
         }
 
         $proc = $pb->setArguments(array('-i'))->getProcess();
         if ('\\' === DIRECTORY_SEPARATOR) {
-            $this->assertEquals('"/usr/bin/php" "-i"', $proc->getCommandLine());
+            $this->assertEquals('"/usr/bin/php" -i', $proc->getCommandLine());
         } else {
             $this->assertEquals("'/usr/bin/php' '-i'", $proc->getCommandLine());
         }
@@ -103,14 +111,14 @@ class ProcessBuilderTest extends TestCase
 
         $proc = $pb->setArguments(array('-v'))->getProcess();
         if ('\\' === DIRECTORY_SEPARATOR) {
-            $this->assertEquals('"/usr/bin/php" "composer.phar" "-v"', $proc->getCommandLine());
+            $this->assertEquals('"/usr/bin/php" composer.phar -v', $proc->getCommandLine());
         } else {
             $this->assertEquals("'/usr/bin/php' 'composer.phar' '-v'", $proc->getCommandLine());
         }
 
         $proc = $pb->setArguments(array('-i'))->getProcess();
         if ('\\' === DIRECTORY_SEPARATOR) {
-            $this->assertEquals('"/usr/bin/php" "composer.phar" "-i"', $proc->getCommandLine());
+            $this->assertEquals('"/usr/bin/php" composer.phar -i', $proc->getCommandLine());
         } else {
             $this->assertEquals("'/usr/bin/php' 'composer.phar' '-i'", $proc->getCommandLine());
         }
@@ -122,7 +130,7 @@ class ProcessBuilderTest extends TestCase
         $proc = $pb->getProcess();
 
         if ('\\' === DIRECTORY_SEPARATOR) {
-            $this->assertSame('^%"path"^% "foo \\" bar" "%baz%baz"', $proc->getCommandLine());
+            $this->assertSame('""^%"path"^%"" "foo "" bar" ""^%"baz"^%"baz"', $proc->getCommandLine());
         } else {
             $this->assertSame("'%path%' 'foo \" bar' '%baz%baz'", $proc->getCommandLine());
         }
@@ -135,7 +143,7 @@ class ProcessBuilderTest extends TestCase
         $proc = $pb->getProcess();
 
         if ('\\' === DIRECTORY_SEPARATOR) {
-            $this->assertSame('^%"prefix"^% "arg"', $proc->getCommandLine());
+            $this->assertSame('""^%"prefix"^%"" arg', $proc->getCommandLine());
         } else {
             $this->assertSame("'%prefix%' 'arg'", $proc->getCommandLine());
         }
@@ -202,4 +210,17 @@ class ProcessBuilderTest extends TestCase
         $builder = ProcessBuilder::create();
         $builder->setInput(array());
     }
+
+    public function testDoesNotPrefixExec()
+    {
+        if ('\\' === DIRECTORY_SEPARATOR) {
+            $this->markTestSkipped('This test cannot run on Windows.');
+        }
+
+        $builder = ProcessBuilder::create(array('command', '-v', 'ls'));
+        $process = $builder->getProcess();
+        $process->run();
+
+        $this->assertTrue($process->isSuccessful());
+    }
 }