class ProcessFactoryTest

@coversDefaultClass \Drupal\package_manager\ProcessFactory @group auto_updates @internal

Hierarchy

Expanded class hierarchy of ProcessFactoryTest

File

core/modules/package_manager/tests/src/Kernel/ProcessFactoryTest.php, line 15

Namespace

Drupal\Tests\package_manager\Kernel
View source
class ProcessFactoryTest extends PackageManagerKernelTestBase {
    
    /**
     * Tests that the process factory prepends the PHP directory to PATH.
     */
    public function testPhpDirectoryPrependedToPath() : void {
        $factory = $this->container
            ->get(ProcessFactoryInterface::class);
        $this->assertInstanceOf(ProcessFactory::class, $factory);
        // Ensure that the directory of the PHP interpreter can be found.
        $reflector = new \ReflectionObject($factory);
        $method = $reflector->getMethod('getPhpDirectory');
        $php_dir = $method->invoke(NULL);
        $this->assertNotEmpty($php_dir);
        // The process factory should always put the PHP interpreter's directory
        // at the beginning of the PATH environment variable.
        $env = $factory->create([
            'whoami',
        ])
            ->getEnv();
        $this->assertStringStartsWith("{$php_dir}:", $env['PATH']);
    }

}

Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.