From eb0f324f70ed211a3598b41e58a2d3f355ff5d13 Mon Sep 17 00:00:00 2001 From: Zoe Slattery Date: Fri, 25 May 2007 13:44:23 +0000 Subject: [PATCH] New testcaes for file/strings/general_functions --- ext/standard/tests/file/fgetc_basic.phpt | 543 +++++++++ ext/standard/tests/file/fgetc_error.phpt | 73 ++ ext/standard/tests/file/file.inc | 472 ++++++++ ext/standard/tests/file/fileinode_basic.phpt | 37 + ext/standard/tests/file/fileinode_error.phpt | 41 + .../tests/file/fileinode_variation.phpt | 96 ++ ext/standard/tests/file/filetype_basic.phpt | 22 + ext/standard/tests/file/filetype_error.phpt | 39 + .../tests/file/filetype_variation.phpt | 69 ++ ext/standard/tests/file/flock_basic.phpt | 44 + ext/standard/tests/file/flock_error.phpt | 112 ++ ext/standard/tests/file/flock_variation.phpt | 328 +++++ ext/standard/tests/file/fnmatch_basic.phpt | 49 + ext/standard/tests/file/fnmatch_error.phpt | 57 + .../tests/file/fnmatch_variation.phpt | 402 +++++++ ext/standard/tests/file/fpassthru_basic.phpt | 126 ++ ext/standard/tests/file/fpassthru_error.phpt | 40 + .../tests/file/fpassthru_variation.phpt | 114 ++ .../tests/general_functions/intval.phpt | 302 +++++ .../tests/general_functions/var_export.phpt | 1052 +++++++++++++++++ ext/standard/tests/strings/dirname_basic.phpt | 153 +++ ext/standard/tests/strings/dirname_error.phpt | 25 + .../tests/strings/dirname_variation.phpt | 143 +++ ext/standard/tests/strings/explode1.phpt | 508 ++++++++ 24 files changed, 4847 insertions(+) create mode 100644 ext/standard/tests/file/fgetc_basic.phpt create mode 100644 ext/standard/tests/file/fgetc_error.phpt create mode 100644 ext/standard/tests/file/file.inc create mode 100644 ext/standard/tests/file/fileinode_basic.phpt create mode 100644 ext/standard/tests/file/fileinode_error.phpt create mode 100644 ext/standard/tests/file/fileinode_variation.phpt create mode 100644 ext/standard/tests/file/filetype_basic.phpt create mode 100644 ext/standard/tests/file/filetype_error.phpt create mode 100644 ext/standard/tests/file/filetype_variation.phpt create mode 100644 ext/standard/tests/file/flock_basic.phpt create mode 100644 ext/standard/tests/file/flock_error.phpt create mode 100644 ext/standard/tests/file/flock_variation.phpt create mode 100644 ext/standard/tests/file/fnmatch_basic.phpt create mode 100644 ext/standard/tests/file/fnmatch_error.phpt create mode 100644 ext/standard/tests/file/fnmatch_variation.phpt create mode 100644 ext/standard/tests/file/fpassthru_basic.phpt create mode 100644 ext/standard/tests/file/fpassthru_error.phpt create mode 100644 ext/standard/tests/file/fpassthru_variation.phpt create mode 100644 ext/standard/tests/general_functions/intval.phpt create mode 100644 ext/standard/tests/general_functions/var_export.phpt create mode 100644 ext/standard/tests/strings/dirname_basic.phpt create mode 100644 ext/standard/tests/strings/dirname_error.phpt create mode 100644 ext/standard/tests/strings/dirname_variation.phpt create mode 100644 ext/standard/tests/strings/explode1.phpt diff --git a/ext/standard/tests/file/fgetc_basic.phpt b/ext/standard/tests/file/fgetc_basic.phpt new file mode 100644 index 0000000000..fca3a312a7 --- /dev/null +++ b/ext/standard/tests/file/fgetc_basic.phpt @@ -0,0 +1,543 @@ +--TEST-- +Test fgetc() function : basic functionality +--FILE-- + +--EXPECTF-- +*** Testing fgetc() : basic operations *** +--- Outerloop iteration 1 --- +-- Innerloop iteration 1 of Outerloop Iteration 1 -- +-- Testing fgetc() : file opened using r mode -- +string(1) "2" +int(1) +bool(false) +resource(8) of type (stream) +string(1) "2" +int(2) +bool(false) +resource(8) of type (stream) +string(1) "2" +int(3) +bool(false) +resource(8) of type (stream) +string(1) "2" +int(4) +bool(false) +resource(8) of type (stream) +string(1) "2" +int(5) +bool(false) +resource(8) of type (stream) +string(1) "2" +int(6) +bool(false) +resource(8) of type (stream) +-- Innerloop iteration 2 of Outerloop Iteration 1 -- +-- Testing fgetc() : file opened using rb mode -- +string(1) "2" +int(1) +bool(false) +resource(9) of type (stream) +string(1) "2" +int(2) +bool(false) +resource(9) of type (stream) +string(1) "2" +int(3) +bool(false) +resource(9) of type (stream) +string(1) "2" +int(4) +bool(false) +resource(9) of type (stream) +string(1) "2" +int(5) +bool(false) +resource(9) of type (stream) +string(1) "2" +int(6) +bool(false) +resource(9) of type (stream) +-- Innerloop iteration 3 of Outerloop Iteration 1 -- +-- Testing fgetc() : file opened using rt mode -- +string(1) "2" +int(1) +bool(false) +resource(10) of type (stream) +string(1) "2" +int(2) +bool(false) +resource(10) of type (stream) +string(1) "2" +int(3) +bool(false) +resource(10) of type (stream) +string(1) "2" +int(4) +bool(false) +resource(10) of type (stream) +string(1) "2" +int(5) +bool(false) +resource(10) of type (stream) +string(1) "2" +int(6) +bool(false) +resource(10) of type (stream) +-- Innerloop iteration 4 of Outerloop Iteration 1 -- +-- Testing fgetc() : file opened using r+ mode -- +string(1) "2" +int(1) +bool(false) +resource(11) of type (stream) +string(1) "2" +int(2) +bool(false) +resource(11) of type (stream) +string(1) "2" +int(3) +bool(false) +resource(11) of type (stream) +string(1) "2" +int(4) +bool(false) +resource(11) of type (stream) +string(1) "2" +int(5) +bool(false) +resource(11) of type (stream) +string(1) "2" +int(6) +bool(false) +resource(11) of type (stream) +-- Innerloop iteration 5 of Outerloop Iteration 1 -- +-- Testing fgetc() : file opened using r+b mode -- +string(1) "2" +int(1) +bool(false) +resource(12) of type (stream) +string(1) "2" +int(2) +bool(false) +resource(12) of type (stream) +string(1) "2" +int(3) +bool(false) +resource(12) of type (stream) +string(1) "2" +int(4) +bool(false) +resource(12) of type (stream) +string(1) "2" +int(5) +bool(false) +resource(12) of type (stream) +string(1) "2" +int(6) +bool(false) +resource(12) of type (stream) +-- Innerloop iteration 6 of Outerloop Iteration 1 -- +-- Testing fgetc() : file opened using r+t mode -- +string(1) "2" +int(1) +bool(false) +resource(13) of type (stream) +string(1) "2" +int(2) +bool(false) +resource(13) of type (stream) +string(1) "2" +int(3) +bool(false) +resource(13) of type (stream) +string(1) "2" +int(4) +bool(false) +resource(13) of type (stream) +string(1) "2" +int(5) +bool(false) +resource(13) of type (stream) +string(1) "2" +int(6) +bool(false) +resource(13) of type (stream) +--- Outerloop iteration 2 --- +-- Innerloop iteration 1 of Outerloop Iteration 2 -- +-- Testing fgetc() : file opened using r mode -- +string(1) "t" +int(1) +bool(false) +resource(16) of type (stream) +string(1) "e" +int(2) +bool(false) +resource(16) of type (stream) +string(1) "x" +int(3) +bool(false) +resource(16) of type (stream) +string(1) "t" +int(4) +bool(false) +resource(16) of type (stream) +string(1) " " +int(5) +bool(false) +resource(16) of type (stream) +string(1) "t" +int(6) +bool(false) +resource(16) of type (stream) +-- Innerloop iteration 2 of Outerloop Iteration 2 -- +-- Testing fgetc() : file opened using rb mode -- +string(1) "t" +int(1) +bool(false) +resource(17) of type (stream) +string(1) "e" +int(2) +bool(false) +resource(17) of type (stream) +string(1) "x" +int(3) +bool(false) +resource(17) of type (stream) +string(1) "t" +int(4) +bool(false) +resource(17) of type (stream) +string(1) " " +int(5) +bool(false) +resource(17) of type (stream) +string(1) "t" +int(6) +bool(false) +resource(17) of type (stream) +-- Innerloop iteration 3 of Outerloop Iteration 2 -- +-- Testing fgetc() : file opened using rt mode -- +string(1) "t" +int(1) +bool(false) +resource(18) of type (stream) +string(1) "e" +int(2) +bool(false) +resource(18) of type (stream) +string(1) "x" +int(3) +bool(false) +resource(18) of type (stream) +string(1) "t" +int(4) +bool(false) +resource(18) of type (stream) +string(1) " " +int(5) +bool(false) +resource(18) of type (stream) +string(1) "t" +int(6) +bool(false) +resource(18) of type (stream) +-- Innerloop iteration 4 of Outerloop Iteration 2 -- +-- Testing fgetc() : file opened using r+ mode -- +string(1) "t" +int(1) +bool(false) +resource(19) of type (stream) +string(1) "e" +int(2) +bool(false) +resource(19) of type (stream) +string(1) "x" +int(3) +bool(false) +resource(19) of type (stream) +string(1) "t" +int(4) +bool(false) +resource(19) of type (stream) +string(1) " " +int(5) +bool(false) +resource(19) of type (stream) +string(1) "t" +int(6) +bool(false) +resource(19) of type (stream) +-- Innerloop iteration 5 of Outerloop Iteration 2 -- +-- Testing fgetc() : file opened using r+b mode -- +string(1) "t" +int(1) +bool(false) +resource(20) of type (stream) +string(1) "e" +int(2) +bool(false) +resource(20) of type (stream) +string(1) "x" +int(3) +bool(false) +resource(20) of type (stream) +string(1) "t" +int(4) +bool(false) +resource(20) of type (stream) +string(1) " " +int(5) +bool(false) +resource(20) of type (stream) +string(1) "t" +int(6) +bool(false) +resource(20) of type (stream) +-- Innerloop iteration 6 of Outerloop Iteration 2 -- +-- Testing fgetc() : file opened using r+t mode -- +string(1) "t" +int(1) +bool(false) +resource(21) of type (stream) +string(1) "e" +int(2) +bool(false) +resource(21) of type (stream) +string(1) "x" +int(3) +bool(false) +resource(21) of type (stream) +string(1) "t" +int(4) +bool(false) +resource(21) of type (stream) +string(1) " " +int(5) +bool(false) +resource(21) of type (stream) +string(1) "t" +int(6) +bool(false) +resource(21) of type (stream) +--- Outerloop iteration 3 --- +-- Innerloop iteration 1 of Outerloop Iteration 3 -- +-- Testing fgetc() : file opened using r mode -- +string(1) "l" +int(1) +bool(false) +resource(24) of type (stream) +string(1) "i" +int(2) +bool(false) +resource(24) of type (stream) +string(1) "n" +int(3) +bool(false) +resource(24) of type (stream) +string(1) "e" +int(4) +bool(false) +resource(24) of type (stream) +string(1) " +" +int(5) +bool(false) +resource(24) of type (stream) +string(1) "l" +int(6) +bool(false) +resource(24) of type (stream) +-- Innerloop iteration 2 of Outerloop Iteration 3 -- +-- Testing fgetc() : file opened using rb mode -- +string(1) "l" +int(1) +bool(false) +resource(25) of type (stream) +string(1) "i" +int(2) +bool(false) +resource(25) of type (stream) +string(1) "n" +int(3) +bool(false) +resource(25) of type (stream) +string(1) "e" +int(4) +bool(false) +resource(25) of type (stream) +string(1) " +" +int(5) +bool(false) +resource(25) of type (stream) +string(1) "l" +int(6) +bool(false) +resource(25) of type (stream) +-- Innerloop iteration 3 of Outerloop Iteration 3 -- +-- Testing fgetc() : file opened using rt mode -- +string(1) "l" +int(1) +bool(false) +resource(26) of type (stream) +string(1) "i" +int(2) +bool(false) +resource(26) of type (stream) +string(1) "n" +int(3) +bool(false) +resource(26) of type (stream) +string(1) "e" +int(4) +bool(false) +resource(26) of type (stream) +string(1) " +" +int(5) +bool(false) +resource(26) of type (stream) +string(1) "l" +int(6) +bool(false) +resource(26) of type (stream) +-- Innerloop iteration 4 of Outerloop Iteration 3 -- +-- Testing fgetc() : file opened using r+ mode -- +string(1) "l" +int(1) +bool(false) +resource(27) of type (stream) +string(1) "i" +int(2) +bool(false) +resource(27) of type (stream) +string(1) "n" +int(3) +bool(false) +resource(27) of type (stream) +string(1) "e" +int(4) +bool(false) +resource(27) of type (stream) +string(1) " +" +int(5) +bool(false) +resource(27) of type (stream) +string(1) "l" +int(6) +bool(false) +resource(27) of type (stream) +-- Innerloop iteration 5 of Outerloop Iteration 3 -- +-- Testing fgetc() : file opened using r+b mode -- +string(1) "l" +int(1) +bool(false) +resource(28) of type (stream) +string(1) "i" +int(2) +bool(false) +resource(28) of type (stream) +string(1) "n" +int(3) +bool(false) +resource(28) of type (stream) +string(1) "e" +int(4) +bool(false) +resource(28) of type (stream) +string(1) " +" +int(5) +bool(false) +resource(28) of type (stream) +string(1) "l" +int(6) +bool(false) +resource(28) of type (stream) +-- Innerloop iteration 6 of Outerloop Iteration 3 -- +-- Testing fgetc() : file opened using r+t mode -- +string(1) "l" +int(1) +bool(false) +resource(29) of type (stream) +string(1) "i" +int(2) +bool(false) +resource(29) of type (stream) +string(1) "n" +int(3) +bool(false) +resource(29) of type (stream) +string(1) "e" +int(4) +bool(false) +resource(29) of type (stream) +string(1) " +" +int(5) +bool(false) +resource(29) of type (stream) +string(1) "l" +int(6) +bool(false) +resource(29) of type (stream) +Done \ No newline at end of file diff --git a/ext/standard/tests/file/fgetc_error.phpt b/ext/standard/tests/file/fgetc_error.phpt new file mode 100644 index 0000000000..b771c3a29d --- /dev/null +++ b/ext/standard/tests/file/fgetc_error.phpt @@ -0,0 +1,73 @@ +--TEST-- +Test fgetc() function : error conditions +--FILE-- + $chunk_size ) { + $loop_count = 1; + do { + $loop_count ++; + if ( $size <= $chunk_size ) { + $chunk_size = $size; + } + $num_values = str_repeat($data, ($chunk_size/$size_divider) + $add_value ); + $bytes_written = fwrite($file_handle, $num_values, $chunk_size); + if ( $bytes_written != $chunk_size ) { + return false; + } + $size -= $chunk_size; + } while ( $size > 0 ); + } else { + $num_values = str_repeat($data, ($chunk_size/$size_divider) + $add_value ); + $bytes_written = fwrite($file_handle, $num_values, $file_size); + if ( $bytes_written != $chunk_size ) { + return false; + } + } + + // successful, return true + return true; +} + +/* + Function: int change_file_perms(string $file_path, int $count = 1, int $perms = 0755, + string $name_prefix = "file", + string $name_suffix = 1, $file_extension = ".tmp"); + Description: changes file permission for given file(s). + $file_path = dir path where file exists + $count = no. of files, default is 1 + $perms = new permission of the file, similar to $mode args of chmod() call + $name_prefix = common name prefix, default is "file" + $name_suffix = suffix to end the common name given in name_prefix to create + a unique name. default is 1. + $file_extension = default is .tmp + Returns: + Integer, Count of total files permission changed. +*/ +function change_file_perms($file_path, + $count = 1, + $perms = 0755, + $name_prefix = "file", + $name_suffix = 1, + $file_extension = ".tmp" ) +{ + $changed = 0; + + if( $count <= 0 ) + return $changed; + + if ( $name_suffix <= 0) + $name_suffix = 1; + + for($loop_counter = 1; $loop_counter <= $count; $loop_counter++) { + $filename = $file_path."/".$name_prefix.$name_suffix.$file_extension; + if( chmod($filename, $perms) ) + $changed++; + $name_suffix++; + } + return $changed; +} + +/* + Function: array create_files( string $file_path, + int $count = 1, + string $content_type = "numeric", + int $permission = 0755, + int $size = 1, + string $mode = "w", + string $name_prefix = "file", + int $name_suffix = 1, + string $flag = "kilobytes" + string $file_extension = ".tmp" + ); + Description: Creates given number of files with specified mode and + permissions. File is filled with content of size specified. + $file_path = dir where files will be created + $name_prefix = prefix to be used for names, name is suffix with a + unqiue numeric value to make the file name unique, default = file + $name_suffix = suffix to be used for the name, default = 1 + $count = total no. of files to be created, default = 1 + $mode = file open mode as specified in fopen() call. Do not use + modes used for only reading the file. Default = "w" + $permission = An octal number, This should be similar to $mode + specified in chmod() call. + $content_type = Specify type of the content to fill in the file. + "numeric" = fill file with numeric vlaues + "text" = fill file with regular text + "empty" = empty file + "text_with_new_line" = similar to text fill type, but writes with new line char + "alphanumeric" = fill file with alpha numeric text + If imporper $content type is specified, file is created as empty + $size = size of the fill in terms of kilobyte, i.e size of the file. + if $flag is specified as "byte", then then given size is taken in bytes + $flag = specifiy if size has to be treated as no of total bytes or + multiple of KB. + "kilobytes" = take size in terms of multiple of KB + "byte" = take size in terms of bytes + $file_extension = default is .tmp + + Returns: + An array with following key value pair: + created => total file created + filled => total files filled + perms_changed => total files permission changed +*/ +function create_files( $file_path, + $count = 1, + $content_type = "numeric", + $permission = 0755, + $size = 1, + $mode = "w", + $name_prefix = "file", + $name_suffix = 1, + $flag = "kilobytes", + $file_extension = ".tmp" + ) +{ + $return_value = array('created' => 0, 'filled' => 0, 'perms_changed' => 0); + + //ensure that suffix is a +ve integer + if ($name_suffix <= 0) { + $name_suffix = 1; + } + + // check for proper size + if ( $size == 0 ) + return $return_value; + + // prepare the size based on flag + $file_size = $size; + if ( $flag == "kilobytes" ) { + $file_size = $file_size * 1024; + } + + $tmp_name_suffix = $name_suffix; + // create the files with specified mode and permission + for($file_created_count = 1; $file_created_count <= $count; $file_created_count ++) { + $filename = $file_path."/".$name_prefix.$tmp_name_suffix.$file_extension; + + $status = create_file($filename, $mode); + + $tmp_name_suffix++; + + if ($status == true) { + $return_value['created']++; + } + else { + return $return_value; + } + } + + if ( $content_type == "empty" ) { + $return_value['filled'] = $count; + return $return_value; + } + + // fill the file with specifiec type of data and size + $tmp_name_suffix = $name_suffix; + for($loop_counter = 1; $loop_counter <= $count; $loop_counter ++) { + $filename = $file_path."/".$name_prefix.$tmp_name_suffix.$file_extension; + $file_handle = fopen($filename, $mode); + if($file_handle == false) { + fclose($file_handle); + return $return_value; + } // end of if + + // call fill_file() to fill the file + if( fill_file($file_handle, $content_type, $file_size) ) + $return_value['filled']++; + + fclose($file_handle); + + $tmp_name_suffix++; + } // end of for + + // change all file's permissions + $return_value['perms_changed'] = change_file_perms($file_path, $count, $permission, $name_prefix, + $name_suffix, $file_extension); + + return $return_value; +} + + +/* + Function: function create_links( $file_path, + $filename, + $link_count = 1, + $link_type = "soft", + $link_size = 1024, + $link_name_prefix = "link", + $link_name_suffix = 1, + $link_file_content = "text", + $link_perms = 0755, + $link_file_extension = ".tmp" + ); + + Description: Creates given number of links with specified mode and + permissions.Link is filled with content of size specified. + $file_path = location of the file and where links need to be created + $link_name_prefix = prefix to be used for names, name is suffix with a + unique numeric value to make the file name unique, default = link + $link_name_suffix = suffix to be used for the name, default = 1 + $link_count = total no. of links to be created to given file, default = 1 + $link_perms = An octal number, This should be similar to $mode + specified in chmod() call. + $link_file_content = Type of the content to fill in the file. + numeric = fill file with numeric vlaues + text = fill file with regular text + text_with_new_line = same as text but new lines are written + alphanumeric = fill with alphanumeric text + If imporper $content type is specified, file is created as empty + $size = size of the fill in terms of kilobyte, i.e size of the file. + $link_type = type of the link to be created + "soft" = soft link + "hard" = hard link + $filename = file used to create a link on + + Returns: + An array with following key value pair: + created => total file created + filled => total files filled, always returned as 1 + perms_changed => total files permission changed +*/ +function create_links( $file_path, + $filename, + $link_count = 1, + $link_type = "soft", + $link_size = 1024, + $link_name_prefix = "link", + $link_name_suffix = 1, + $link_file_content = "text", + $link_perms = 0755, + $link_file_extension = ".tmp" + ) +{ + $return_value = array('created' => 0, 'filled' => 0, 'perms_changed' => 0); + $tmp_name_suffix = $link_name_suffix; + $src_filename = $file_path."/".$filename; + switch( $link_type ) { + default : + case "soft" : // create a soft link + for($link_created_count = 1; $link_created_count <= $link_count; $link_created_count++) { + $linkname = $file_path."/".$link_name_prefix.$tmp_name_suffix.$link_file_extension; + $status = symlink( $src_filename, $linkname); + $tmp_name_suffix++; + if ($status) { + $return_value['created']++; + } + else { + $return_value; + } + } + break; + + case "hard" : // create a hard link + for($link_created_count = 1; $link_created_count <= $link_count; $link_created_count++) { + $linkname = $file_path."/".$link_name_prefix.$tmp_name_suffix.$link_file_extension; + $status = link($src_filename, $linkname); + $tmp_name_suffix++; + if ($status) { + $return_value['created']++; + } + else { + $return_value; + } + } + break; + } + + if ( $link_file_content == "empty" ) { + $return_value['filled'] = 1; + return $return_value; + } + + // fill the file with specific type of data and size + $tmp_name_suffix = $link_name_suffix; + $linkname = $file_path."/".$link_name_prefix.$tmp_name_suffix.$link_file_extension; + $file_handle = fopen($linkname, "w"); + if($file_handle == false) { + return $return_value; + } // end of if + + // call fill_file() to fill the file + if( fill_file($file_handle, $link_file_content, $link_size) ) + $return_value['filled']++; + + // close the link + fclose($file_handle); + + // change the permission of the link file, only if hard link. + // this is not applicable to soft links + if( $link_type == "hard" ) { + $return_value['perms_changed'] = change_file_perms($file_path, + $link_count, + $link_perms, + $link_name_prefix, + $link_name_suffix, + $link_file_extension ); + } + + return $return_value; +} + +/* + Function: bool delete_file(string $filename); + Description: delete a given file if exists + Returns: true on success + false on failure + file_not_found if file doesn't exist +*/ +function delete_file($filename) { + // check if file exists + if ( file_exists($filename) ) { + if ( unlink($filename) ) + return true; + else + return false; + } + return file_not_found; +} + +/* + Function: array delete_files(string $file_path, int $count = 1, string $name_prefix = "file", + int name_suffix = 1, $file_extension = ".tmp" ); + Description: Deletes given number of files if exists. + $file_path = location of the files + $name_prefix = prefix for the filename, rest of the name is incremental(increment by 1 only) + numeric starting from suffix upto count + $count = number of files to be deleted + $name_suffix = first numeric suffix in the name + Returns: An array with following key/value pair + deleted = Number of files deleted. + notfound = Count of non existing file + failed = Count of failed to delete +*/ +function delete_files($file_path, + $count = 1, + $name_prefix = "file", + $name_suffix = 1, + $file_extension = ".tmp") +{ + $return_value = array ('deleted' => 0, 'notfound' => 0, 'failed' => 0); + + if ( $name_suffix < 1 ) + $name_suffix = 1; + for($loop_counter = 1; $loop_counter <= $count; $loop_counter++) { + $filename = $file_path."/".$name_prefix.$name_suffix.$file_extension; + $name_suffix++; + $status = delete_file($filename); + if($status == true) { + $return_value['deleted']++; + } else if($status == file_not_found) { + $return_value['notfound']++; + } else { + $return_value['failed']++; + } + + } // end of for + return $return_value; +} + +/* + Function: array delete_links( $file_path, + $link_file_count, + $link_name_prefix, + $link_name_suffix, + $link_file_extension ); + Description: Deletes given number of links if exists. Uses delete_files() function + $file_path = location of link files + $link_file_count = Number of link files + $link_name_prefix = prefix for the linkname, rest of the name is incremental(increment by 1 only) + numeric starting from $link_name_suffix upto count + $link_name_suffix = first numeric suffix in the name + + Returns: An array with following key/value pair + deleted = Number of links deleted. + notfound = Count of non existing link + failed = Count of failed to delete +*/ +function delete_links($file_path, + $link_file_count = 1, + $link_name_prefix = "link", + $link_name_suffix = 1, + $link_file_extension = ".tmp") +{ + // call the delete files to delete links + $return_value = delete_files( $file_path, + $link_file_count, + $link_name_prefix, + $link_name_suffix, + $link_file_extension ); + return $return_value; +} + + diff --git a/ext/standard/tests/file/fileinode_basic.phpt b/ext/standard/tests/file/fileinode_basic.phpt new file mode 100644 index 0000000000..27b7dbd799 --- /dev/null +++ b/ext/standard/tests/file/fileinode_basic.phpt @@ -0,0 +1,37 @@ +--TEST-- +Test fileinode() function: Basic functionality +--FILE-- + + +--EXPECTF-- +*** Testing fileinode() with file, directory *** +%d +%d +%d +%d + +*** Done *** diff --git a/ext/standard/tests/file/fileinode_error.phpt b/ext/standard/tests/file/fileinode_error.phpt new file mode 100644 index 0000000000..4730d060dd --- /dev/null +++ b/ext/standard/tests/file/fileinode_error.phpt @@ -0,0 +1,41 @@ +--TEST-- +Test fileinode() function: Error conditions +--FILE-- + +--EXPECTF-- +*** Testing filetype() with files and dirs *** +file +dir +*** Done *** diff --git a/ext/standard/tests/file/filetype_error.phpt b/ext/standard/tests/file/filetype_error.phpt new file mode 100644 index 0000000000..9b4d71fffe --- /dev/null +++ b/ext/standard/tests/file/filetype_error.phpt @@ -0,0 +1,39 @@ +--TEST-- +Test filetype() function: Error conditions +--FILE-- + +--EXPECTF-- +*** Testing error conditions *** +Warning: filetype(): Lstat failed for /no/such/file/dir in %s on line %d + +Warning: filetype(): Lstat failed for string in %s on line %d + +Warning: filetype(): Lstat failed for 100 in %s on line %d + +Warning: Wrong parameter count for filetype() in %s on line %d + +Warning: Wrong parameter count for filetype() in %s on line %d + +*** Done *** diff --git a/ext/standard/tests/file/filetype_variation.phpt b/ext/standard/tests/file/filetype_variation.phpt new file mode 100644 index 0000000000..bc9e1a1073 --- /dev/null +++ b/ext/standard/tests/file/filetype_variation.phpt @@ -0,0 +1,69 @@ +--TEST-- +Test filetype() function: Variations +--SKIPIF-- + +--EXPECTF-- +*** Testing filetype() with various types *** +-- Checking with files -- +file +file +-- Checking with links: hardlink -- +file +-- Checking with links: symlink -- +link +-- Checking with directory -- +dir +-- Checking with fifo -- +fifo + +*** Done *** diff --git a/ext/standard/tests/file/flock_basic.phpt b/ext/standard/tests/file/flock_basic.phpt new file mode 100644 index 0000000000..d218cee5ef --- /dev/null +++ b/ext/standard/tests/file/flock_basic.phpt @@ -0,0 +1,44 @@ +--TEST-- +Test flock() function: Basic functionality +--FILE-- + +--EXPECTF-- +*** Testing flock() fun with file and dir *** +bool(true) +bool(true) +bool(true) +bool(true) +bool(false) +bool(false) +bool(false) +bool(false) + +*** Done *** diff --git a/ext/standard/tests/file/flock_error.phpt b/ext/standard/tests/file/flock_error.phpt new file mode 100644 index 0000000000..077e5430ba --- /dev/null +++ b/ext/standard/tests/file/flock_error.phpt @@ -0,0 +1,112 @@ +--TEST-- +Test flock() function: Error conditions +--FILE-- + +--CLEAN-- + +--EXPECTF-- +*** Testing error conditions *** + +--- Iteration 0 --- +Warning: flock(): Illegal operation argument in %s on line %d +bool(false) + +--- Iteration 1 --- +Warning: flock(): Illegal operation argument in %s on line %d +bool(false) + +--- Iteration 2 --- +Warning: flock(): Illegal operation argument in %s on line %d +bool(false) + +--- Iteration 3 --- +Warning: flock(): Illegal operation argument in %s on line %d +bool(false) + +--- Iteration 4 --- +Warning: flock() expects parameter 2 to be long, array given in %s on line %d +NULL + +--- Iteration 5 --- +Warning: flock() expects parameter 2 to be long, array given in %s on line %d +NULL + +--- Iteration 6 --- +Warning: flock() expects parameter 2 to be long, string given in %s on line %d +NULL + +--- Iteration 7 --- +Warning: flock() expects parameter 2 to be long, string given in %s on line %d +NULL + +--- Iteration 8 --- +Warning: flock() expects parameter 2 to be long, string given in %s on line %d +NULL + +Warning: flock(): 6 is not a valid stream resource in %s on line %d +bool(false) + +Warning: flock() expects parameter 1 to be resource, string given in %s on line %d +NULL + +Warning: flock() expects at least 2 parameters, 0 given in %s on line %d +NULL + +Warning: flock() expects at least 2 parameters, 1 given in %s on line %d +NULL + +Warning: flock() expects at most 3 parameters, 4 given in %s on line %d +NULL + +*** Done *** diff --git a/ext/standard/tests/file/flock_variation.phpt b/ext/standard/tests/file/flock_variation.phpt new file mode 100644 index 0000000000..d34f78f7f2 --- /dev/null +++ b/ext/standard/tests/file/flock_variation.phpt @@ -0,0 +1,328 @@ +--TEST-- +Test flock() function: Variations +--FILE-- + +--EXPECTF-- +*** Testing flock() fun with the various operation and + wouldblock values *** +--- Outer iteration 0 --- +bool(true) +-- Inner iteration 0 in 0 -- +bool(true) +-- Inner iteration 1 in 0 -- +bool(true) +-- Inner iteration 2 in 0 -- +bool(true) +-- Inner iteration 3 in 0 -- +bool(true) +-- Inner iteration 4 in 0 -- +bool(true) +-- Inner iteration 5 in 0 -- +bool(true) +-- Inner iteration 6 in 0 -- +bool(true) +-- Inner iteration 7 in 0 -- +bool(true) +-- Inner iteration 8 in 0 -- +bool(true) +-- Inner iteration 9 in 0 -- +bool(true) +-- Inner iteration 10 in 0 -- +bool(true) +-- Inner iteration 11 in 0 -- +bool(true) +--- Outer iteration 1 --- +bool(true) +-- Inner iteration 0 in 1 -- +bool(true) +-- Inner iteration 1 in 1 -- +bool(true) +-- Inner iteration 2 in 1 -- +bool(true) +-- Inner iteration 3 in 1 -- +bool(true) +-- Inner iteration 4 in 1 -- +bool(true) +-- Inner iteration 5 in 1 -- +bool(true) +-- Inner iteration 6 in 1 -- +bool(true) +-- Inner iteration 7 in 1 -- +bool(true) +-- Inner iteration 8 in 1 -- +bool(true) +-- Inner iteration 9 in 1 -- +bool(true) +-- Inner iteration 10 in 1 -- +bool(true) +-- Inner iteration 11 in 1 -- +bool(true) +--- Outer iteration 2 --- +bool(true) +-- Inner iteration 0 in 2 -- +bool(true) +-- Inner iteration 1 in 2 -- +bool(true) +-- Inner iteration 2 in 2 -- +bool(true) +-- Inner iteration 3 in 2 -- +bool(true) +-- Inner iteration 4 in 2 -- +bool(true) +-- Inner iteration 5 in 2 -- +bool(true) +-- Inner iteration 6 in 2 -- +bool(true) +-- Inner iteration 7 in 2 -- +bool(true) +-- Inner iteration 8 in 2 -- +bool(true) +-- Inner iteration 9 in 2 -- +bool(true) +-- Inner iteration 10 in 2 -- +bool(true) +-- Inner iteration 11 in 2 -- +bool(true) +--- Outer iteration 3 --- +bool(true) +-- Inner iteration 0 in 3 -- +bool(true) +-- Inner iteration 1 in 3 -- +bool(true) +-- Inner iteration 2 in 3 -- +bool(true) +-- Inner iteration 3 in 3 -- +bool(true) +-- Inner iteration 4 in 3 -- +bool(true) +-- Inner iteration 5 in 3 -- +bool(true) +-- Inner iteration 6 in 3 -- +bool(true) +-- Inner iteration 7 in 3 -- +bool(true) +-- Inner iteration 8 in 3 -- +bool(true) +-- Inner iteration 9 in 3 -- +bool(true) +-- Inner iteration 10 in 3 -- +bool(true) +-- Inner iteration 11 in 3 -- +bool(true) +--- Outer iteration 4 --- +bool(true) +-- Inner iteration 0 in 4 -- +bool(true) +-- Inner iteration 1 in 4 -- +bool(true) +-- Inner iteration 2 in 4 -- +bool(true) +-- Inner iteration 3 in 4 -- +bool(true) +-- Inner iteration 4 in 4 -- +bool(true) +-- Inner iteration 5 in 4 -- +bool(true) +-- Inner iteration 6 in 4 -- +bool(true) +-- Inner iteration 7 in 4 -- +bool(true) +-- Inner iteration 8 in 4 -- +bool(true) +-- Inner iteration 9 in 4 -- +bool(true) +-- Inner iteration 10 in 4 -- +bool(true) +-- Inner iteration 11 in 4 -- +bool(true) +--- Outer iteration 5 --- +bool(true) +-- Inner iteration 0 in 5 -- +bool(true) +-- Inner iteration 1 in 5 -- +bool(true) +-- Inner iteration 2 in 5 -- +bool(true) +-- Inner iteration 3 in 5 -- +bool(true) +-- Inner iteration 4 in 5 -- +bool(true) +-- Inner iteration 5 in 5 -- +bool(true) +-- Inner iteration 6 in 5 -- +bool(true) +-- Inner iteration 7 in 5 -- +bool(true) +-- Inner iteration 8 in 5 -- +bool(true) +-- Inner iteration 9 in 5 -- +bool(true) +-- Inner iteration 10 in 5 -- +bool(true) +-- Inner iteration 11 in 5 -- +bool(true) +--- Outer iteration 6 --- +bool(true) +-- Inner iteration 0 in 6 -- +bool(true) +-- Inner iteration 1 in 6 -- +bool(true) +-- Inner iteration 2 in 6 -- +bool(true) +-- Inner iteration 3 in 6 -- +bool(true) +-- Inner iteration 4 in 6 -- +bool(true) +-- Inner iteration 5 in 6 -- +bool(true) +-- Inner iteration 6 in 6 -- +bool(true) +-- Inner iteration 7 in 6 -- +bool(true) +-- Inner iteration 8 in 6 -- +bool(true) +-- Inner iteration 9 in 6 -- +bool(true) +-- Inner iteration 10 in 6 -- +bool(true) +-- Inner iteration 11 in 6 -- +bool(true) +--- Outer iteration 7 --- +bool(true) +-- Inner iteration 0 in 7 -- +bool(true) +-- Inner iteration 1 in 7 -- +bool(true) +-- Inner iteration 2 in 7 -- +bool(true) +-- Inner iteration 3 in 7 -- +bool(true) +-- Inner iteration 4 in 7 -- +bool(true) +-- Inner iteration 5 in 7 -- +bool(true) +-- Inner iteration 6 in 7 -- +bool(true) +-- Inner iteration 7 in 7 -- +bool(true) +-- Inner iteration 8 in 7 -- +bool(true) +-- Inner iteration 9 in 7 -- +bool(true) +-- Inner iteration 10 in 7 -- +bool(true) +-- Inner iteration 11 in 7 -- +bool(true) +--- Outer iteration 8 --- +bool(true) +-- Inner iteration 0 in 8 -- +bool(true) +-- Inner iteration 1 in 8 -- +bool(true) +-- Inner iteration 2 in 8 -- +bool(true) +-- Inner iteration 3 in 8 -- +bool(true) +-- Inner iteration 4 in 8 -- +bool(true) +-- Inner iteration 5 in 8 -- +bool(true) +-- Inner iteration 6 in 8 -- +bool(true) +-- Inner iteration 7 in 8 -- +bool(true) +-- Inner iteration 8 in 8 -- +bool(true) +-- Inner iteration 9 in 8 -- +bool(true) +-- Inner iteration 10 in 8 -- +bool(true) +-- Inner iteration 11 in 8 -- +bool(true) +--- Outer iteration 9 --- +bool(true) +-- Inner iteration 0 in 9 -- +bool(true) +-- Inner iteration 1 in 9 -- +bool(true) +-- Inner iteration 2 in 9 -- +bool(true) +-- Inner iteration 3 in 9 -- +bool(true) +-- Inner iteration 4 in 9 -- +bool(true) +-- Inner iteration 5 in 9 -- +bool(true) +-- Inner iteration 6 in 9 -- +bool(true) +-- Inner iteration 7 in 9 -- +bool(true) +-- Inner iteration 8 in 9 -- +bool(true) +-- Inner iteration 9 in 9 -- +bool(true) +-- Inner iteration 10 in 9 -- +bool(true) +-- Inner iteration 11 in 9 -- +bool(true) + +*** Done *** diff --git a/ext/standard/tests/file/fnmatch_basic.phpt b/ext/standard/tests/file/fnmatch_basic.phpt new file mode 100644 index 0000000000..cc68924e49 --- /dev/null +++ b/ext/standard/tests/file/fnmatch_basic.phpt @@ -0,0 +1,49 @@ +--TEST-- +Test fnmatch() function: Basic functionality +--SKIPIF-- + +--EXPECTF-- +*** Testing fnmatch() with file *** +bool(true) +bool(true) +bool(true) +bool(true) +bool(true) +bool(false) +*** Testing fnmatch() with other than file *** +bool(true) +bool(true) +bool(true) +bool(true) +bool(true) + +*** Done *** diff --git a/ext/standard/tests/file/fnmatch_error.phpt b/ext/standard/tests/file/fnmatch_error.phpt new file mode 100644 index 0000000000..2bbff23713 --- /dev/null +++ b/ext/standard/tests/file/fnmatch_error.phpt @@ -0,0 +1,57 @@ +--TEST-- +Test fnmatch() function: Error conditions +--SKIPIF-- + +--EXPECTF-- +*** Testing error conditions for fnmatch() *** +Warning: fnmatch() expects parameter 1 to be string, array given in %s on line %d +NULL + +Warning: fnmatch() expects parameter 1 to be string, resource given in %s on line %d +NULL + +Warning: fnmatch() expects parameter 1 to be string, object given in %s on line %d +NULL + +Warning: fnmatch() expects at least 2 parameters, 1 given in %s on line %d +NULL + +Warning: fnmatch() expects at least 2 parameters, 1 given in %s on line %d +NULL + +Warning: fnmatch() expects at most 3 parameters, 4 given in %s on line %d +NULL + +*** Done *** diff --git a/ext/standard/tests/file/fnmatch_variation.phpt b/ext/standard/tests/file/fnmatch_variation.phpt new file mode 100644 index 0000000000..c3a3bdd2b1 --- /dev/null +++ b/ext/standard/tests/file/fnmatch_variation.phpt @@ -0,0 +1,402 @@ +--TEST-- +Test fnmatch() function: Variations +--SKIPIF-- + "*.tmp", +1 => "match*", +2 => "mat*", +3 => "mat*tmp", +4 => "m*t", +5 => "ma[pt]ch*", +6 => "*.t*", +7 => "***.tmp", +8 => "match**", +9 => "*.t*p", +10 => "", +11 => "match", +12 => ".tmp", +13 => "?match", +14 => "match?tmp", +15 => "?tmp", +16 => "match?", +17 => "?match?", +18 => "match.tmp", +19 => "/match.tmp", +20 => "/match.tmp/", +21 => 'match.tmp', +22 => 'match.tmp\0', +23 => "match.tmp\0", +24 => "match\0.tmp", +25 => chr(109).chr(97)."tch.tmp", +26 => chr(109).chr(97).chr(116).chr(99).chr(104).".tmp", +27 => chr(109).chr(97).chr(116).chr(99).chr(104).chr(46).chr(116).chr(120).chr(116), +28 => chr(109).chr(97).chr(116).chr(99).chr(104).".".chr(116).chr(120).chr(116), +29 => "MATCH.TMP", +30 => "MATCH*", +31 => $file_name +); + +for( $i = 0; $i +--EXPECTF-- +*** Testing fnmatch() with file and various patterns *** +-- Iteration 0 -- +bool(true) +-- Iteration 1 -- +bool(false) +-- Iteration 2 -- +bool(false) +-- Iteration 3 -- +bool(false) +-- Iteration 4 -- +bool(false) +-- Iteration 5 -- +bool(false) +-- Iteration 6 -- +bool(true) +-- Iteration 7 -- +bool(true) +-- Iteration 8 -- +bool(false) +-- Iteration 9 -- +bool(true) +-- Iteration 10 -- +bool(false) +-- Iteration 11 -- +bool(false) +-- Iteration 12 -- +bool(false) +-- Iteration 13 -- +bool(false) +-- Iteration 14 -- +bool(false) +-- Iteration 15 -- +bool(false) +-- Iteration 16 -- +bool(false) +-- Iteration 17 -- +bool(false) +-- Iteration 18 -- +bool(false) +-- Iteration 19 -- +bool(false) +-- Iteration 20 -- +bool(false) +-- Iteration 21 -- +bool(false) +-- Iteration 22 -- +bool(false) +-- Iteration 23 -- +bool(false) +-- Iteration 24 -- +bool(false) +-- Iteration 25 -- +bool(false) +-- Iteration 26 -- +bool(false) +-- Iteration 27 -- +bool(false) +-- Iteration 28 -- +bool(false) +-- Iteration 29 -- +bool(false) +-- Iteration 30 -- +bool(false) +-- Iteration 31 -- +bool(true) + +*** Testing fnmatch() with other types other than files *** +--- With Integers --- +-- Iteration 0 -- +bool(true) +bool(true) +bool(true) +bool(false) +bool(false) +bool(false) +-- Iteration 1 -- +bool(true) +bool(true) +bool(true) +bool(false) +bool(false) +bool(false) +-- Iteration 2 -- +bool(true) +bool(true) +bool(true) +bool(false) +bool(false) +bool(false) +-- Iteration 3 -- +bool(false) +bool(false) +bool(false) +bool(true) +bool(false) +bool(false) +-- Iteration 4 -- +bool(false) +bool(false) +bool(false) +bool(false) +bool(true) +bool(false) +-- Iteration 5 -- +bool(false) +bool(false) +bool(false) +bool(false) +bool(false) +bool(true) + +--- With Strings --- +-- Iteration 0 -- +bool(true) +bool(true) +bool(true) +bool(false) +bool(false) +-- Iteration 1 -- +bool(true) +bool(true) +bool(true) +bool(false) +bool(false) +-- Iteration 2 -- +bool(true) +bool(true) +bool(true) +bool(false) +bool(false) +-- Iteration 3 -- +bool(false) +bool(false) +bool(false) +bool(true) +bool(false) +-- Iteration 4 -- +bool(false) +bool(false) +bool(false) +bool(false) +bool(true) + +--- With booleans --- +-- Iteration 0 -- +bool(true) +bool(true) +bool(true) +bool(false) +bool(false) +bool(false) +bool(false) +bool(false) +bool(false) +-- Iteration 1 -- +bool(true) +bool(true) +bool(true) +bool(false) +bool(false) +bool(false) +bool(false) +bool(false) +bool(false) +-- Iteration 2 -- +bool(true) +bool(true) +bool(true) +bool(false) +bool(false) +bool(false) +bool(false) +bool(false) +bool(false) +-- Iteration 3 -- +bool(false) +bool(false) +bool(false) +bool(true) +bool(false) +bool(false) +bool(false) +bool(false) +bool(false) +-- Iteration 4 -- +bool(false) +bool(false) +bool(false) +bool(false) +bool(true) +bool(true) +bool(false) +bool(true) +bool(false) +-- Iteration 5 -- +bool(false) +bool(false) +bool(false) +bool(false) +bool(true) +bool(true) +bool(false) +bool(true) +bool(false) +-- Iteration 6 -- +bool(false) +bool(false) +bool(false) +bool(false) +bool(false) +bool(false) +bool(true) +bool(false) +bool(false) +-- Iteration 7 -- +bool(false) +bool(false) +bool(false) +bool(false) +bool(true) +bool(true) +bool(false) +bool(true) +bool(false) +-- Iteration 8 -- +bool(false) +bool(false) +bool(false) +bool(false) +bool(false) +bool(false) +bool(false) +bool(false) +bool(true) + +--- With NULL --- +-- Iteration 0 -- +bool(true) +bool(true) +bool(true) +bool(true) +bool(false) +bool(false) +-- Iteration 1 -- +bool(true) +bool(true) +bool(true) +bool(true) +bool(false) +bool(false) +-- Iteration 2 -- +bool(true) +bool(true) +bool(true) +bool(true) +bool(false) +bool(false) +-- Iteration 3 -- +bool(true) +bool(true) +bool(true) +bool(true) +bool(false) +bool(false) +-- Iteration 4 -- +bool(false) +bool(false) +bool(false) +bool(false) +bool(true) +bool(false) +-- Iteration 5 -- +bool(false) +bool(false) +bool(false) +bool(false) +bool(false) +bool(true) + +*** Done *** diff --git a/ext/standard/tests/file/fpassthru_basic.phpt b/ext/standard/tests/file/fpassthru_basic.phpt new file mode 100644 index 0000000000..a6e6612dd5 --- /dev/null +++ b/ext/standard/tests/file/fpassthru_basic.phpt @@ -0,0 +1,126 @@ +--TEST-- +Test fpassthru() function: Basic functionality +--FILE-- + +--CLEAN-- + +--EXPECTF-- +*** Test basic functionality of fpassthru() function *** + +-- Before seek operation -- +Hello, world +, abcdefg adsdsfdf +8u2394723947 $%$%#$%#$%#^#%^ + Hello, world +, abcdefg adsdsfdf +8u2394723947 $%$%#$%#$%#^#%^ +int(133) + +-- After seeking position to 0 -- +Hello, world +, abcdefg adsdsfdf +8u2394723947 $%$%#$%#$%#^#%^ + Hello, world +, abcdefg adsdsfdf +8u2394723947 $%$%#$%#$%#^#%^ +int(133) + +-- After seeking position to 3 -- +lo, world +, abcdefg adsdsfdf +8u2394723947 $%$%#$%#$%#^#%^ + Hello, world +, abcdefg adsdsfdf +8u2394723947 $%$%#$%#$%#^#%^ +int(130) + +-- After seeking position to 13 -- +, abcdefg adsdsfdf +8u2394723947 $%$%#$%#$%#^#%^ + Hello, world +, abcdefg adsdsfdf +8u2394723947 $%$%#$%#$%#^#%^ +int(120) + +-- After seeking position to 14 -- + abcdefg adsdsfdf +8u2394723947 $%$%#$%#$%#^#%^ + Hello, world +, abcdefg adsdsfdf +8u2394723947 $%$%#$%#$%#^#%^ +int(119) + +-- After seeking position to 23 -- +adsdsfdf +8u2394723947 $%$%#$%#$%#^#%^ + Hello, world +, abcdefg adsdsfdf +8u2394723947 $%$%#$%#$%#^#%^ +int(110) + +-- After seeking position to 34 -- +2394723947 $%$%#$%#$%#^#%^ + Hello, world +, abcdefg adsdsfdf +8u2394723947 $%$%#$%#$%#^#%^ +int(99) + +-- After seeking position to 1000 -- +int(0) +*** Done *** \ No newline at end of file diff --git a/ext/standard/tests/file/fpassthru_error.phpt b/ext/standard/tests/file/fpassthru_error.phpt new file mode 100644 index 0000000000..68e2e46cdc --- /dev/null +++ b/ext/standard/tests/file/fpassthru_error.phpt @@ -0,0 +1,40 @@ +--TEST-- +Test fpassthru() function: Error conditions +--FILE-- + +--EXPECTF-- +*** Test error conditions of fpassthru() function *** + +Warning: fread(): supplied argument is not a valid stream resource in %s on line %d + +Warning: fpassthru(): supplied argument is not a valid stream resource in %s on line %d +bool(false) + +Warning: Wrong parameter count for fpassthru() in %s on line %d +NULL + +Warning: Wrong parameter count for fpassthru() in %s on line %d +NULL + +*** Done *** diff --git a/ext/standard/tests/file/fpassthru_variation.phpt b/ext/standard/tests/file/fpassthru_variation.phpt new file mode 100644 index 0000000000..56a039e628 --- /dev/null +++ b/ext/standard/tests/file/fpassthru_variation.phpt @@ -0,0 +1,114 @@ +--TEST-- +Test fpassthru() function: Variations +--FILE-- += 0 ) { + fseek($file_read, $offset_arr[$i], SEEK_SET); + var_dump(fpassthru($file_read) ); + rewind( $file_read ); + }else + { + fseek($file_read, $offset_arr[$i], SEEK_END); + var_dump( fpassthru($file_read) ); + rewind( $file_read ); + } +} + +fclose($file_read); // closing the handle + +echo "\n--- Testing with binary mode file ---\n"; +/* Opening the file in binary read mode */ +$file_read = fopen($file_name, "rb"); + +fseek($file_read, 12, SEEK_SET); +var_dump(fpassthru($file_read) ); +rewind( $file_read ); +fclose($file_read); + +unlink($file_name); + +echo "\n*** Done ***\n"; + +?> +--EXPECTF-- +*** Testing fpassthru() function with files *** + +--- Testing with different offsets --- +-- Iteration 0 -- +1234567890abcdefghijklmnopqrstuvwxyzint(36) +-- Iteration 1 -- +234567890abcdefghijklmnopqrstuvwxyzint(35) +-- Iteration 2 -- +67890abcdefghijklmnopqrstuvwxyzint(31) +-- Iteration 3 -- +abcdefghijklmnopqrstuvwxyzint(26) +-- Iteration 4 -- +klmnopqrstuvwxyzint(16) +-- Iteration 5 -- +uvwxyzint(6) +-- Iteration 6 -- +zint(1) +-- Iteration 7 -- +int(0) +-- Iteration 8 -- +int(0) +-- Iteration 9 -- +zint(1) +-- Iteration 10 -- +vwxyzint(5) +-- Iteration 11 -- +qrstuvwxyzint(10) +-- Iteration 12 -- +ghijklmnopqrstuvwxyzint(20) +-- Iteration 13 -- +234567890abcdefghijklmnopqrstuvwxyzint(35) +-- Iteration 14 -- +1234567890abcdefghijklmnopqrstuvwxyzint(36) +-- Iteration 15 -- +1234567890abcdefghijklmnopqrstuvwxyzint(36) + +--- Testing with binary mode file --- +cdefghijklmnopqrstuvwxyzint(24) + +*** Done *** diff --git a/ext/standard/tests/general_functions/intval.phpt b/ext/standard/tests/general_functions/intval.phpt new file mode 100644 index 0000000000..74d3a70a71 --- /dev/null +++ b/ext/standard/tests/general_functions/intval.phpt @@ -0,0 +1,302 @@ +--TEST-- +Test intval() function. +--FILE-- + "One", "two" => 2), + + /* strings */ + "", + '', + "0", + '0', + "1", + '1', + "\x01", + '\x01', + "\01", + '\01', + 'string', + "string", + "true", + "FALSE", + 'false', + 'TRUE', + "NULL", + 'null', + + /* booleans */ + true, + false, + TRUE, + FALSE, + + /* undefined and unset vars */ + @$unset_var, + @$undefined_var +); + + +/* loop through the $not_int_types to see working of + intval() on non integer types, expected output: integer value in decimal notation for valid integers */ +foreach ($not_int_types as $type ) { + var_dump( intval($type) ); +} + +echo "\n*** Testing error conditions ***\n"; +//Zero argument +var_dump( intval() ); + +//arguments more than expected +var_dump( intval(TRUE, FALSE, TRUE) ); + +echo "\n--- Done ---\n"; + + +?> +--EXPECTF-- +*** Testing intval() with valid integer values *** + +***Output with default base value ie 10 *** +int(0) +int(1) +int(-1) +int(-2147483648) +int(-2147483647) +int(2147483647) +int(2147483640) +int(4667) +int(0) +int(0) +int(0) +int(-2147483648) +int(0) +int(2147483647) +int(123) +int(1) +int(-2147483648) +int(2147483647) + +***Output with base value of 10( explicitly passed as argument) *** +int(0) +int(1) +int(-1) +int(-2147483648) +int(-2147483647) +int(2147483647) +int(2147483640) +int(4667) +int(0) +int(0) +int(0) +int(-2147483648) +int(0) +int(2147483647) +int(123) +int(1) +int(-2147483648) +int(2147483647) + +***Output with base value of 16 *** +int(0) +int(1) +int(-1) +int(-2147483648) +int(-2147483648) +int(2147483647) +int(2147483640) +int(4667) +int(4779) +int(4095) +int(250) +int(-2147483648) +int(2147483647) +int(2147483647) +int(291) +int(1) +int(-2147483648) +int(2147483647) + +***Output with base value of 8 *** +int(0) +int(1) +int(-1) +int(-9020) +int(-9020) +int(2147483647) +int(2147483640) +int(4667) +int(0) +int(0) +int(0) +int(-2147483648) +int(0) +int(2147483647) +int(83) +int(1) +int(-2147483648) +int(2147483647) + +*** Testing intval() on non integer types *** +int(-2147483648) +int(2147483647) +int(0) +int(0) +int(2147483647) +int(-2147483648) +int(0) +int(0) +int(1) +int(100000) +int(-1000000) +int(100000000) +int(-1000000000) +int(10) +int(1050000) +int(5) +int(6) +int(0) +int(1) +int(1) +int(1) +int(1) +int(1) +int(1) +int(1) +int(1) +int(1) +int(1) +int(1) +int(0) +int(0) +int(0) +int(0) +int(1) +int(1) +int(0) +int(0) +int(0) +int(0) +int(0) +int(0) +int(0) +int(0) +int(0) +int(0) +int(0) +int(0) +int(1) +int(0) +int(1) +int(0) +int(0) +int(0) + +*** Testing error conditions *** + +Warning: Wrong parameter count for intval() in %s on line %d +NULL + +Warning: Wrong parameter count for intval() in %s on line %d +NULL + +--- Done --- diff --git a/ext/standard/tests/general_functions/var_export.phpt b/ext/standard/tests/general_functions/var_export.phpt new file mode 100644 index 0000000000..0f14657877 --- /dev/null +++ b/ext/standard/tests/general_functions/var_export.phpt @@ -0,0 +1,1052 @@ +--TEST-- +Test var_export() function +--FILE-- + 'One'), + array("test" => "is_array"), + array(0), + array(-1), + array(10.5, 5.6), + array("string", "test"), + array('string', 'test') + ); +$counter = 1; +/* Loop to check for above arrays with var_export() */ +echo "\n*** Output for arrays ***\n"; +foreach($valid_arrays as $arr) { +echo "\nIteration ".$counter."\n"; +var_export( $arr ); +echo "\n"; +var_export( $arr, FALSE); +echo "\n"; +var_dump( var_export( $arr, TRUE) ); +echo "\n"; +$counter++; +} + +echo "*** Testing var_export() with valid objects ***\n"; + +// class with no members +class foo +{ +// no members +} + +// abstract class +abstract class abstractClass +{ + abstract protected function getClassName(); + public function printClassName () { + echo $this->getClassName() . "\n"; + } +} +// implement abstract class +class concreteClass extends abstractClass +{ + protected function getClassName() { + return "concreteClass"; + } +} + +// interface class +interface iValue +{ + public function setVal ($name, $val); + public function dumpVal (); +} +// implement the interface +class Value implements iValue +{ + private $vars = array (); + + public function setVal ( $name, $val ) { + $this->vars[$name] = $val; + } + + public function dumpVal () { + var_export ( $vars ); + } +} + +// a gereral class +class myClass +{ + var $foo_object; + public $public_var; + public $public_var1; + private $private_var; + protected $protected_var; + + function myClass ( ) { + $this->foo_object = new foo(); + $this->public_var = 10; + $this->public_var1 = new foo(); + $this->private_var = new foo(); + $this->proected_var = new foo(); + } +} + +// create a object of each class defined above +$myClass_object = new myClass(); +$foo_object = new foo(); +$Value_object = new Value(); +$concreteClass_object = new concreteClass(); + +$valid_objects = array( + new stdclass, + new foo, + new concreteClass, + new Value, + new myClass, + $myClass_object, + $myClass_object->foo_object, + $myClass_object->public_var1, + $foo_object, + $Value_object, + $concreteClass_object + ); + $counter = 1; +/* Loop to check for above objects with var_export() */ +echo "\n*** Output for objects ***\n"; +foreach($valid_objects as $obj) { +echo "\nIteration ".$counter."\n"; +var_export( $obj ); +echo "\n"; +var_export( $obj, FALSE); +echo "\n"; +var_dump( var_export( $obj, TRUE) ); +echo "\n"; +$counter++; +} + +echo "*** Testing var_export() with valid null values ***\n"; +// different valid null vlaues +$unset_var = array(); +unset ($unset_var); // now a null +$null_var = NULL; + +$valid_nulls = array( + NULL, + null, + $null_var, + ); + $counter = 1; +/* Loop to check for above null values with var_export() */ +echo "\n*** Output for null values ***\n"; +foreach($valid_nulls as $null_value) { +echo "\nIteration ".$counter."\n"; +var_export( $null_value ); +echo "\n"; +var_export( $null_value, FALSE); +echo "\n"; +var_dump( var_export( $null_value, true) ); +echo "\n"; +$counter++; +} + +echo "\n*** Testing error conditions ***\n"; +//Zero argument +var_export( var_export() ); + +//arguments more than expected +var_export( var_export(TRUE, FALSE, TRUE) ); + +echo "\n\nDone"; + + +?> +--EXPECTF-- +*** Testing var_export() with integer values *** + +*** Output for integer values *** + +Iteration 1 +'0' +'0' +string(3) "'0'" + + +Iteration 2 +'1' +'1' +string(3) "'1'" + + +Iteration 3 +'-1' +'-1' +string(4) "'-1'" + + +Iteration 4 +'-2147483648' +'-2147483648' +string(13) "'-2147483648'" + + +Iteration 5 +'-2147483647' +'-2147483647' +string(13) "'-2147483647'" + + +Iteration 6 +2147483647 +2147483647 +string(10) "2147483647" + + +Iteration 7 +2147483640 +2147483640 +string(10) "2147483640" + + +Iteration 8 +4667 +4667 +string(4) "4667" + + +Iteration 9 +'0x12ab' +'0x12ab' +string(8) "'0x12ab'" + + +Iteration 10 +'0Xfff' +'0Xfff' +string(7) "'0Xfff'" + + +Iteration 11 +'0XFA' +'0XFA' +string(6) "'0XFA'" + + +Iteration 12 +-2147483648 +-2147483648 +string(11) "-2147483648" + + +Iteration 13 +'0x7fffffff' +'0x7fffffff' +string(12) "'0x7fffffff'" + + +Iteration 14 +2147483647 +2147483647 +string(10) "2147483647" + + +Iteration 15 +'0123' +'0123' +string(6) "'0123'" + + +Iteration 16 +1 +1 +string(1) "1" + + +Iteration 17 +-2147483648 +-2147483648 +string(11) "-2147483648" + + +Iteration 18 +2147483647 +2147483647 +string(10) "2147483647" + +*** Testing var_export() with valid boolean values *** + +*** Output for boolean values *** + +Iteration 1 +1 +1 +string(1) "1" + + +Iteration 2 +true +true +string(4) "true" + + +Iteration 3 +true +true +string(4) "true" + + +Iteration 4 +0 +0 +string(1) "0" + + +Iteration 5 +false +false +string(5) "false" + + +Iteration 6 +false +false +string(5) "false" + +*** Testing var_export() with valid float values *** + +*** Output for float values *** + +Iteration 1 +1 +1 +string(1) "1" + + +Iteration 2 +true +true +string(4) "true" + + +Iteration 3 +true +true +string(4) "true" + + +Iteration 4 +0 +0 +string(1) "0" + + +Iteration 5 +false +false +string(5) "false" + + +Iteration 6 +false +false +string(5) "false" + +*** Testing var_export() with valid strings *** + +*** Output for strings *** + +Iteration 1 +'' +'' +string(2) "''" + + +Iteration 2 +' ' +' ' +string(3) "' '" + + +Iteration 3 +'' +'' +string(2) "''" + + +Iteration 4 +' ' +' ' +string(3) "' '" + + +Iteration 5 +'string' +'string' +string(8) "'string'" + + +Iteration 6 +'string' +'string' +string(8) "'string'" + + +Iteration 7 +'NULL' +'NULL' +string(6) "'NULL'" + + +Iteration 8 +'null' +'null' +string(6) "'null'" + + +Iteration 9 +'FALSE' +'FALSE' +string(7) "'FALSE'" + + +Iteration 10 +'false' +'false' +string(7) "'false'" + + +Iteration 11 +' ' +' ' +string(3) "' '" + + +Iteration 12 +'\000' +'\000' +string(6) "'\000'" + + +Iteration 13 +'\\0' +'\\0' +string(5) "'\\0'" + + +Iteration 14 +'\\060' +'\\060' +string(7) "'\\060'" + + +Iteration 15 +'8' +'8' +string(3) "'8'" + +*** Testing var_export() with valid arrays *** + +*** Output for arrays *** + +Iteration 1 +array ( +) +array ( +) +string(9) "array ( +)" + + +Iteration 2 +array ( + 0 => NULL, +) +array ( + 0 => NULL, +) +string(22) "array ( + 0 => NULL, +)" + + +Iteration 3 +array ( + 0 => NULL, +) +array ( + 0 => NULL, +) +string(22) "array ( + 0 => NULL, +)" + + +Iteration 4 +array ( + 0 => true, +) +array ( + 0 => true, +) +string(22) "array ( + 0 => true, +)" + + +Iteration 5 +array ( + 0 => '', +) +array ( + 0 => '', +) +string(20) "array ( + 0 => '', +)" + + +Iteration 6 +array ( + 0 => '', +) +array ( + 0 => '', +) +string(20) "array ( + 0 => '', +)" + + +Iteration 7 +array ( + 0 => + array ( + ), + 1 => + array ( + ), +) +array ( + 0 => + array ( + ), + 1 => + array ( + ), +) +string(55) "array ( + 0 => + array ( + ), + 1 => + array ( + ), +)" + + +Iteration 8 +array ( + 0 => + array ( + 0 => 1, + 1 => 2, + ), + 1 => + array ( + 0 => 'a', + 1 => 'b', + ), +) +array ( + 0 => + array ( + 0 => 1, + 1 => 2, + ), + 1 => + array ( + 0 => 'a', + 1 => 'b', + ), +) +string(107) "array ( + 0 => + array ( + 0 => 1, + 1 => 2, + ), + 1 => + array ( + 0 => 'a', + 1 => 'b', + ), +)" + + +Iteration 9 +array ( + 1 => 'One', +) +array ( + 1 => 'One', +) +string(23) "array ( + 1 => 'One', +)" + + +Iteration 10 +array ( + 'test' => 'is_array', +) +array ( + 'test' => 'is_array', +) +string(33) "array ( + 'test' => 'is_array', +)" + + +Iteration 11 +array ( + 0 => 0, +) +array ( + 0 => 0, +) +string(19) "array ( + 0 => 0, +)" + + +Iteration 12 +array ( + 0 => -1, +) +array ( + 0 => -1, +) +string(20) "array ( + 0 => -1, +)" + + +Iteration 13 +array ( + 0 => 10.5, + 1 => 5.6, +) +array ( + 0 => 10.5, + 1 => 5.6, +) +string(34) "array ( + 0 => 10.5, + 1 => 5.6, +)" + + +Iteration 14 +array ( + 0 => 'string', + 1 => 'test', +) +array ( + 0 => 'string', + 1 => 'test', +) +string(41) "array ( + 0 => 'string', + 1 => 'test', +)" + + +Iteration 15 +array ( + 0 => 'string', + 1 => 'test', +) +array ( + 0 => 'string', + 1 => 'test', +) +string(41) "array ( + 0 => 'string', + 1 => 'test', +)" + +*** Testing var_export() with valid objects *** + +*** Output for objects *** + +Iteration 1 +stdClass::__set_state(array( +)) +stdClass::__set_state(array( +)) +string(31) "stdClass::__set_state(array( +))" + + +Iteration 2 +foo::__set_state(array( +)) +foo::__set_state(array( +)) +string(26) "foo::__set_state(array( +))" + + +Iteration 3 +concreteClass::__set_state(array( +)) +concreteClass::__set_state(array( +)) +string(36) "concreteClass::__set_state(array( +))" + + +Iteration 4 +Value::__set_state(array( + 'vars' => + array ( + ), +)) +Value::__set_state(array( + 'vars' => + array ( + ), +)) +string(57) "Value::__set_state(array( + 'vars' => + array ( + ), +))" + + +Iteration 5 +myClass::__set_state(array( + 'foo_object' => + foo::__set_state(array( + )), + 'public_var' => 10, + 'public_var1' => + foo::__set_state(array( + )), + 'private_var' => + foo::__set_state(array( + )), + 'protected_var' => NULL, + 'proected_var' => + foo::__set_state(array( + )), +)) +myClass::__set_state(array( + 'foo_object' => + foo::__set_state(array( + )), + 'public_var' => 10, + 'public_var1' => + foo::__set_state(array( + )), + 'private_var' => + foo::__set_state(array( + )), + 'protected_var' => NULL, + 'proected_var' => + foo::__set_state(array( + )), +)) +string(293) "myClass::__set_state(array( + 'foo_object' => + foo::__set_state(array( + )), + 'public_var' => 10, + 'public_var1' => + foo::__set_state(array( + )), + 'private_var' => + foo::__set_state(array( + )), + 'protected_var' => NULL, + 'proected_var' => + foo::__set_state(array( + )), +))" + + +Iteration 6 +myClass::__set_state(array( + 'foo_object' => + foo::__set_state(array( + )), + 'public_var' => 10, + 'public_var1' => + foo::__set_state(array( + )), + 'private_var' => + foo::__set_state(array( + )), + 'protected_var' => NULL, + 'proected_var' => + foo::__set_state(array( + )), +)) +myClass::__set_state(array( + 'foo_object' => + foo::__set_state(array( + )), + 'public_var' => 10, + 'public_var1' => + foo::__set_state(array( + )), + 'private_var' => + foo::__set_state(array( + )), + 'protected_var' => NULL, + 'proected_var' => + foo::__set_state(array( + )), +)) +string(293) "myClass::__set_state(array( + 'foo_object' => + foo::__set_state(array( + )), + 'public_var' => 10, + 'public_var1' => + foo::__set_state(array( + )), + 'private_var' => + foo::__set_state(array( + )), + 'protected_var' => NULL, + 'proected_var' => + foo::__set_state(array( + )), +))" + + +Iteration 7 +foo::__set_state(array( +)) +foo::__set_state(array( +)) +string(26) "foo::__set_state(array( +))" + + +Iteration 8 +foo::__set_state(array( +)) +foo::__set_state(array( +)) +string(26) "foo::__set_state(array( +))" + + +Iteration 9 +foo::__set_state(array( +)) +foo::__set_state(array( +)) +string(26) "foo::__set_state(array( +))" + + +Iteration 10 +Value::__set_state(array( + 'vars' => + array ( + ), +)) +Value::__set_state(array( + 'vars' => + array ( + ), +)) +string(57) "Value::__set_state(array( + 'vars' => + array ( + ), +))" + + +Iteration 11 +concreteClass::__set_state(array( +)) +concreteClass::__set_state(array( +)) +string(36) "concreteClass::__set_state(array( +))" + +*** Testing var_export() with valid null values *** + +*** Output for null values *** + +Iteration 1 +NULL +NULL +string(4) "NULL" + + +Iteration 2 +NULL +NULL +string(4) "NULL" + + +Iteration 3 +NULL +NULL +string(4) "NULL" + + +*** Testing error conditions *** + +Warning: var_export() expects at least 1 parameter, 0 given in %s on line %d +NULL +Warning: var_export() expects at most 2 parameters, 3 given in %s on line %d +NULL + +Done diff --git a/ext/standard/tests/strings/dirname_basic.phpt b/ext/standard/tests/strings/dirname_basic.phpt new file mode 100644 index 0000000000..2b5e4d43d9 --- /dev/null +++ b/ext/standard/tests/strings/dirname_basic.phpt @@ -0,0 +1,153 @@ +--TEST-- +Test dirname() function : basic funtionality +--FILE-- + + +--EXPECTREGEX-- +\*\*\* Testing basic operations \*\*\* + +--Iteration 1 -- +string\(1\) "." + +--Iteration 2 -- +string\(4\) "(\\|\/)foo" + +--Iteration 3 -- +string\(3\) "foo" + +--Iteration 4 -- +string\(1\) "(\\|\/)" + +--Iteration 5 -- +string\(1\) "." + +--Iteration 6 -- +string\(1\) "(\\|\/)" + +--Iteration 7 -- +string\(4\) "(\\|\/)foo" + +--Iteration 8 -- +string\(3\) "foo" + +--Iteration 9 -- +string\(1\) "(\\|\/)" + +--Iteration 10 -- +string\(4\) "(\\|\/)foo" + +--Iteration 11 -- +string\(3\) "foo" + +--Iteration 12 -- +string\(1\) "." + +--Iteration 13 -- +string\(1\) "." + +--Iteration 14 -- +string\(1\) "(\\|\/)" + +--Iteration 15 -- +string\(1\) "(\\|\/)" + +--Iteration 16 -- +string\(4\) "(\\|\/)foo" + +--Iteration 17 -- +string\(3\) "foo" + +--Iteration 18 -- +string\(1\) "(\\|\/)" + +--Iteration 19 -- +string\(1\) "(\\|\/)" + +--Iteration 20 -- +string\(1\) "." + +--Iteration 21 -- +string\(4\) "(\\|\/)foo" + +--Iteration 22 -- +string\(1\) "." + +--Iteration 23 -- +string\(4\) "(\\|\/)foo" + +--Iteration 24 -- +string\(3\) "foo" + +--Iteration 25 -- +string\(1\) "." + +--Iteration 26 -- +string\(1\) "(\\|\/)" + +--Iteration 27 -- +string\(1\) "(\\|\/)" + +--Iteration 28 -- +string\(1\) "." + +--Iteration 29 -- +string\(8\) "(\\|\/)foo\x00bar" +Done diff --git a/ext/standard/tests/strings/dirname_error.phpt b/ext/standard/tests/strings/dirname_error.phpt new file mode 100644 index 0000000000..3671695108 --- /dev/null +++ b/ext/standard/tests/strings/dirname_error.phpt @@ -0,0 +1,25 @@ +--TEST-- +Test dirname() function : error conditions +--FILE-- + +--EXPECTF-- +*** Testing error conditions *** + +Warning: Wrong parameter count for dirname() in %s on line %d +NULL + +Warning: Wrong parameter count for dirname() in %s on line %d +NULL +Done diff --git a/ext/standard/tests/strings/dirname_variation.phpt b/ext/standard/tests/strings/dirname_variation.phpt new file mode 100644 index 0000000000..da66f0fc55 --- /dev/null +++ b/ext/standard/tests/strings/dirname_variation.phpt @@ -0,0 +1,143 @@ +--TEST-- +Test dirname() function : usage variations +--FILE-- + +--EXPECTREGEX-- +\*\*\* Testing possible variations in path \*\*\* + +--Iteration 1 -- +string\(11\) "~(\\|\/)home(\\|\/)user" + +--Iteration 2 -- +string\(11\) "~(\\|\/)home(\\|\/)user" + +--Iteration 3 -- +string\(11\) "~(\\|\/)home(\\|\/)user" + +--Iteration 4 -- +string\(11\) "~(\\|\/)home(\\|\/)user" + +--Iteration 5 -- +string\(19\) "hostname:(\\|\/)home(\\|\/)user" + +--Iteration 6 -- +string\(19\) "hostname:(\\|\/)home(\\|\/)user" + +--Iteration 7 -- +string\(19\) "hostname:(\\|\/)home(\\|\/)user" + +--Iteration 8 -- +string\(19\) "hostname:(\\|\/)home(\\|\/)user" + +--Iteration 9 -- +string\(19\) "hostname:(\\|\/)home(\\|\/)user" + +--Iteration 10 -- +string\(19\) "hostname:(\\|\/)home(\\|\/)user" + +--Iteration 11 -- +string\(1\) "." + +--Iteration 12 -- +string\(1\) "(\\|\/)" + +--Iteration 13 -- +string\(1\) "(\\|\/)" + +--Iteration 14 -- +string\(1\) "." + +--Iteration 15 -- +string\(2\) "10" + +--Iteration 16 -- +string\(1\) "." + +--Iteration 17 -- +string\(1\) "." + +--Iteration 18 -- +string\(1\) "." + +--Iteration 19 -- +string\(1\) "." + +--Iteration 20 -- +string\(1\) "." + +--Iteration 21 -- +string\(0\) "" + +--Iteration 22 -- +string\(0\) "" + +--Iteration 23 -- +string\(0\) "" + +--Iteration 24 -- +string\(0\) "" +Done \ No newline at end of file diff --git a/ext/standard/tests/strings/explode1.phpt b/ext/standard/tests/strings/explode1.phpt new file mode 100644 index 0000000000..f5b71f4e45 --- /dev/null +++ b/ext/standard/tests/strings/explode1.phpt @@ -0,0 +1,508 @@ +--TEST-- +Test explode() function +--INI-- +error_reporting=2047 +--FILE-- +3 */ +var_dump( explode(":", "array1:array2:array3", -1, -33) ); +var_dump( explode(":") ); + +echo "Done\n"; +?> +--EXPECTF-- +*** Testing explode() for basic operations *** +-- Iteration 1 -- + +Warning: explode(): Empty delimiter. in %s on line %d +bool(false) + +Warning: explode(): Empty delimiter. in %s on line %d +bool(false) + +Warning: explode(): Empty delimiter. in %s on line %d +bool(false) + +Warning: explode(): Empty delimiter. in %s on line %d +bool(false) +-- Iteration 2 -- + +Warning: explode(): Empty delimiter. in %s on line %d +bool(false) + +Warning: explode(): Empty delimiter. in %s on line %d +bool(false) + +Warning: explode(): Empty delimiter. in %s on line %d +bool(false) + +Warning: explode(): Empty delimiter. in %s on line %d +bool(false) +-- Iteration 3 -- +array(1) { + [0]=> + string(10) "1234NULL23" +} +array(1) { + [0]=> + string(57) "1234NULL23abcd00000TRUEFALSE-11.234444true-11.24%PHP%ZEND" +} +array(1) { + [0]=> + string(57) "1234NULL23abcd00000TRUEFALSE-11.234444true-11.24%PHP%ZEND" +} +array(2) { + [0]=> + string(10) "1234NULL23" + [1]=> + string(43) "00000TRUEFALSE-11.234444true-11.24%PHP%ZEND" +} +-- Iteration 4 -- +array(5) { + [0]=> + string(14) "1234NULL23abcd" + [1]=> + string(0) "" + [2]=> + string(0) "" + [3]=> + string(0) "" + [4]=> + string(0) "" +} +array(1) { + [0]=> + string(57) "1234NULL23abcd00000TRUEFALSE-11.234444true-11.24%PHP%ZEND" +} +array(1) { + [0]=> + string(57) "1234NULL23abcd00000TRUEFALSE-11.234444true-11.24%PHP%ZEND" +} +array(2) { + [0]=> + string(14) "1234NULL23abcd" + [1]=> + string(42) "0000TRUEFALSE-11.234444true-11.24%PHP%ZEND" +} +-- Iteration 5 -- +array(5) { + [0]=> + string(14) "1234NULL23abcd" + [1]=> + string(0) "" + [2]=> + string(0) "" + [3]=> + string(0) "" + [4]=> + string(0) "" +} +array(1) { + [0]=> + string(57) "1234NULL23abcd00000TRUEFALSE-11.234444true-11.24%PHP%ZEND" +} +array(1) { + [0]=> + string(57) "1234NULL23abcd00000TRUEFALSE-11.234444true-11.24%PHP%ZEND" +} +array(2) { + [0]=> + string(14) "1234NULL23abcd" + [1]=> + string(42) "0000TRUEFALSE-11.234444true-11.24%PHP%ZEND" +} +-- Iteration 6 -- +array(5) { + [0]=> + string(0) "" + [1]=> + string(28) "234NULL23abcd00000TRUEFALSE-" + [2]=> + string(0) "" + [3]=> + string(12) ".234444true-" + [4]=> + string(0) "" +} +array(1) { + [0]=> + string(57) "1234NULL23abcd00000TRUEFALSE-11.234444true-11.24%PHP%ZEND" +} +array(1) { + [0]=> + string(57) "1234NULL23abcd00000TRUEFALSE-11.234444true-11.24%PHP%ZEND" +} +array(2) { + [0]=> + string(0) "" + [1]=> + string(56) "234NULL23abcd00000TRUEFALSE-11.234444true-11.24%PHP%ZEND" +} +-- Iteration 7 -- + +Warning: explode(): Empty delimiter. in %s on line %d +bool(false) + +Warning: explode(): Empty delimiter. in %s on line %d +bool(false) + +Warning: explode(): Empty delimiter. in %s on line %d +bool(false) + +Warning: explode(): Empty delimiter. in %s on line %d +bool(false) +-- Iteration 8 -- +array(2) { + [0]=> + string(28) "1234NULL23abcd00000TRUEFALSE" + [1]=> + string(12) "1.234444true" +} +array(1) { + [0]=> + string(57) "1234NULL23abcd00000TRUEFALSE-11.234444true-11.24%PHP%ZEND" +} +array(1) { + [0]=> + string(57) "1234NULL23abcd00000TRUEFALSE-11.234444true-11.24%PHP%ZEND" +} +array(2) { + [0]=> + string(28) "1234NULL23abcd00000TRUEFALSE" + [1]=> + string(27) "1.234444true-11.24%PHP%ZEND" +} +-- Iteration 9 -- +array(1) { + [0]=> + string(28) "1234NULL23abcd00000TRUEFALSE" +} +array(1) { + [0]=> + string(57) "1234NULL23abcd00000TRUEFALSE-11.234444true-11.24%PHP%ZEND" +} +array(1) { + [0]=> + string(57) "1234NULL23abcd00000TRUEFALSE-11.234444true-11.24%PHP%ZEND" +} +array(2) { + [0]=> + string(28) "1234NULL23abcd00000TRUEFALSE" + [1]=> + string(23) "4444true-11.24%PHP%ZEND" +} +-- Iteration 10 -- +array(6) { + [0]=> + string(3) "123" + [1]=> + string(30) "NULL23abcd00000TRUEFALSE-11.23" + [2]=> + string(0) "" + [3]=> + string(0) "" + [4]=> + string(0) "" + [5]=> + string(9) "true-11.2" +} +array(1) { + [0]=> + string(57) "1234NULL23abcd00000TRUEFALSE-11.234444true-11.24%PHP%ZEND" +} +array(1) { + [0]=> + string(57) "1234NULL23abcd00000TRUEFALSE-11.234444true-11.24%PHP%ZEND" +} +array(2) { + [0]=> + string(3) "123" + [1]=> + string(53) "NULL23abcd00000TRUEFALSE-11.234444true-11.24%PHP%ZEND" +} +-- Iteration 11 -- +array(2) { + [0]=> + string(48) "1234NULL23abcd00000TRUEFALSE-11.234444true-11.24" + [1]=> + string(3) "PHP" +} +array(1) { + [0]=> + string(57) "1234NULL23abcd00000TRUEFALSE-11.234444true-11.24%PHP%ZEND" +} +array(1) { + [0]=> + string(57) "1234NULL23abcd00000TRUEFALSE-11.234444true-11.24%PHP%ZEND" +} +array(2) { + [0]=> + string(48) "1234NULL23abcd00000TRUEFALSE-11.234444true-11.24" + [1]=> + string(8) "PHP%ZEND" +} + +*** Testing explode() with miscelleneous input arguments *** + +-- Passing positive values of Limit to explode() -- +array(2) { + [0]=> + string(3) "mon" + [1]=> + string(31) "tues::wed::thurs::fri::sat::sun" +} + +-- Passing limit values 0 and 1 to explode() -- +array(1) { + [0]=> + string(29) "Name:Phone:Address:City:State" +} +array(1) { + [0]=> + string(29) "Name:Phone:Address:City:State" +} + +*** Testing explode() for maximum limit of string with Limit = -1 *** +array(51) { + [0]=> + string(1) "1" + [1]=> + string(1) "2" + [2]=> + string(1) "3" + [3]=> + string(1) "4" + [4]=> + string(1) "5" + [5]=> + string(1) "6" + [6]=> + string(1) "7" + [7]=> + string(1) "7" + [8]=> + string(1) "5" + [9]=> + string(1) "6" + [10]=> + string(1) "7" + [11]=> + string(1) "3" + [12]=> + string(1) "4" + [13]=> + string(1) "5" + [14]=> + string(1) "2" + [15]=> + string(1) "8" + [16]=> + string(1) "9" + [17]=> + string(1) "0" + [18]=> + string(1) "5" + [19]=> + string(1) "5" + [20]=> + string(1) "5" + [21]=> + string(1) "5" + [22]=> + string(1) "5" + [23]=> + string(1) "5" + [24]=> + string(1) "5" + [25]=> + string(1) "5" + [26]=> + string(1) "5" + [27]=> + string(1) "5" + [28]=> + string(1) "5" + [29]=> + string(1) "5" + [30]=> + string(2) "55" + [31]=> + string(1) "5" + [32]=> + string(1) "5" + [33]=> + string(2) "5%" + [34]=> + string(1) "%" + [35]=> + string(1) "%" + [36]=> + string(1) "%" + [37]=> + string(1) "5" + [38]=> + string(1) "5" + [39]=> + string(1) "5" + [40]=> + string(1) "%" + [41]=> + string(1) "%" + [42]=> + string(1) "5" + [43]=> + string(1) "5" + [44]=> + string(1) "5" + [45]=> + string(1) "5" + [46]=> + string(2) "5%" + [47]=> + string(1) "%" + [48]=> + string(1) "%" + [49]=> + string(2) "55" + [50]=> + string(1) "1" +} + +*** Testing explode() with string variations as input argument *** + +-- Testing string with escape characters -- +array(2) { + [0]=> + string(4) "1234" + [1]=> + string(10) "5678 + 9100" +} +array(4) { + [0]=> + string(4) "1234" + [1]=> + string(4) "abcd" + [2]=> + string(4) "5678" + [3]=> + string(4) "rstu" +} + +-- Testing string with embedded NULL -- +array(4) { + [0]=> + string(4) "abcd" + [1]=> + string(5) "n1234" + [2]=> + string(5) "05678" + [3]=> + string(12) "00efgh\xijkl" +} +array(7) { + [0]=> + string(4) "abcd" + [1]=> + string(4) "efgh" + [2]=> + string(4) "ijkl" + [3]=> + string(4) "mnop" + [4]=> + string(5) "0qrst" + [5]=> + string(4) "uvwx" + [6]=> + string(2) "yz" +} + +*** Testing explode() with objects *** +array(2) { + [0]=> + string(1) "O" + [1]=> + string(4) "ject" +} + +*** Testing error conditions *** + +Warning: Wrong parameter count for explode() in %s on line %d +NULL + +Warning: Wrong parameter count for explode() in %s on line %d +NULL +Done -- 2.50.1