diff --git a/tests/std/core/007_array_search.phpt b/tests/std/core/007_array_search.phpt new file mode 100644 index 00000000..818143aa --- /dev/null +++ b/tests/std/core/007_array_search.phpt @@ -0,0 +1,89 @@ +--TEST-- +Array functions - in_array, array_search, array_key_exists, array_keys, array_values +--FILE-- + 1, 'b' => 2, 'c' => null]; +var_dump(array_key_exists('a', $arr)); +var_dump(array_key_exists('c', $arr)); +var_dump(array_key_exists('d', $arr)); +var_dump(array_key_exists(0, [10, 20, 30])); + +echo "== array_keys ==\n"; +print_r(array_keys(['a' => 1, 'b' => 2, 'c' => 3])); +print_r(array_keys([10, 20, 30])); +print_r(array_keys(['a' => 1, 'b' => 2, 'c' => 2], 2)); +print_r(array_keys(['a' => 2, 'b' => '2', 'c' => 2], '2', true)); + +echo "== array_values ==\n"; +print_r(array_values(['a' => 1, 'b' => 2, 'c' => 3])); +print_r(array_values([10, 20, 30])); +print_r(array_values(['x' => 1, 'y' => 2, 'z' => 3])); + +?> +--EXPECT-- +== in_array == +bool(true) +bool(false) +bool(false) +== array_search == +int(1) +bool(false) +bool(false) +== array_key_exists == +bool(true) +bool(true) +bool(false) +bool(true) +== array_keys == +Array +( + [0] => a + [1] => b + [2] => c +) +Array +( + [0] => 0 + [1] => 1 + [2] => 2 +) +Array +( + [0] => b + [1] => c +) +Array +( + [0] => b +) +== array_values == +Array +( + [0] => 1 + [1] => 2 + [2] => 3 +) +Array +( + [0] => 10 + [1] => 20 + [2] => 30 +) +Array +( + [0] => 1 + [1] => 2 + [2] => 3 +) diff --git a/tests/std/core/008_datetime.phpt b/tests/std/core/008_datetime.phpt new file mode 100644 index 00000000..45b5835a --- /dev/null +++ b/tests/std/core/008_datetime.phpt @@ -0,0 +1,31 @@ +--TEST-- +Date/time functions - time, date, strtotime +--FILE-- + 1000000000); + +echo "== date() ==\n"; +$d = date("Y"); // current year, always works +echo "year: $d\n"; +var_dump(strlen(date("Y-m-d")) === 10); + +echo "== strtotime() ==\n"; +$ts = strtotime("2021-01-01 00:00:00 UTC"); +var_dump($ts > 0); +var_dump(strtotime("not a valid date")); +var_dump(is_int(strtotime("+1 day", 1609459200))); + +?> +--EXPECT-- +== time() == +bool(true) +== date() == +year: 2026 +bool(true) +== strtotime() == +bool(true) +bool(false) +bool(true) diff --git a/tests/std/core/009_string_extra.phpt b/tests/std/core/009_string_extra.phpt new file mode 100644 index 00000000..e293dfc1 --- /dev/null +++ b/tests/std/core/009_string_extra.phpt @@ -0,0 +1,36 @@ +--TEST-- +String functions - dirname, basename, strtr +--FILE-- + +--EXPECT-- +== dirname() == +/etc +/ +/ +relative/path +== basename() == +passwd +passwd +file +[] +== strtr() == +hellO WOrld +123def diff --git a/tests/std/core/010_fs_math.phpt b/tests/std/core/010_fs_math.phpt new file mode 100644 index 00000000..c9e9ee30 --- /dev/null +++ b/tests/std/core/010_fs_math.phpt @@ -0,0 +1,42 @@ +--TEST-- +Filesystem and math functions - is_dir, is_file, round +--FILE-- + +--EXPECT-- +== is_dir() == +bool(true) +bool(false) +bool(true) +== is_file() == +bool(false) +bool(true) +== round() == +float(3) +float(4) +float(3.14) +float(4) +float(5) +float(-2) +float(1234.57) +float(1200) diff --git a/tests/std/core/011_misc.phpt b/tests/std/core/011_misc.phpt new file mode 100644 index 00000000..6e0cadc9 --- /dev/null +++ b/tests/std/core/011_misc.phpt @@ -0,0 +1,41 @@ +--TEST-- +Misc functions - md5, version_compare, print_r +--FILE-- + +--EXPECT-- +== md5() == +5d41402abc4b2a76b9719d911017c592 +d41d8cd98f00b204e9800998ecf8427e +bool(true) +== version_compare() == +int(0) +int(-1) +int(1) +int(-1) +== print_r() == +Array +( + [0] => 1 + [1] => 2 + [2] => 3 +) +hello