Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added some tests #2585

Closed
wants to merge 4 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 21 additions & 0 deletions TSRM/tests/strtok_basic_01.phpt
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
--TEST--
Test the basics to function strtok.
--CREDITS--
Rodrigo Prado de Jesus <royopa [at] gmail [dot] com>
--FILE--
<?php
$string = "This is\tan example\nstring";

$tok = strtok($string," \n\t");

while ($tok !== false) {
var_dump("Word=$tok<br/>");
$tok = strtok(" \n\t");
}
?>
--EXPECT--
string(14) "Word=This<br/>"
string(12) "Word=is<br/>"
string(12) "Word=an<br/>"
string(17) "Word=example<br/>"
string(16) "Word=string<br/>"
27 changes: 27 additions & 0 deletions ext/posix/tests/posix_getpwnam_basic_01.phpt
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
--TEST--
Test posix_getpwnam() function : basic functionality
--CREDITS--
Rodrigo Prado de Jesus <royopa [at] gmail [dot] com>
--SKIPIF--
<?php
if (!extension_loaded('posix')) die('skip - POSIX extension not loaded');
?>
--FILE--
<?php
$uid = posix_geteuid();
$user = posix_getpwuid($uid);
print_r(posix_getpwnam($user['name']));
?>
===DONE====
--EXPECTREGEX--
Array
\(
\[name\] => [^\r\n]+
\[passwd\] => [^\r\n]+
\[uid\] => [0-9]+
\[gid\] => [0-9]+
\[gecos\] => [^\r\n]*
\[dir\] => [^\r\n]+
\[shell\] => [^\r\n]+
\)
===DONE====
15 changes: 15 additions & 0 deletions ext/readline/tests/readline_info_wrongparam_001.phpt
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
--TEST--
Test readline_info function : wrong parameter (array)
- line 248 from readline.c
--CREDITS--
Rodrigo Prado de Jesus <royopa [at] gmail [dot] com>
--SKIPIF--
<?php if (!extension_loaded("readline")) die("skip");
if (READLINE_LIB == "libedit") die("skip readline only"); ?>
--FILE--
<?php
$wrong_parameter = array();
$info = readline_info($wrong_parameter);
?>
--EXPECTF--
Warning: readline_info() expects parameter 1 to be string, array given in %s on line %d
11 changes: 11 additions & 0 deletions ext/readline/tests/readline_nullparam.phpt
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
--TEST--
Test the function readline with null parameter (wrong because the function expects a string parameter).
--CREDITS--
Rodrigo Prado de Jesus <royopa [at] gmail [dot] com>
--SKIPIF--
<?php if (!extension_loaded("readline") die("skip"); ?>
--FILE--
<?php
$line = readline(null);
?>
--EXPECTF--
14 changes: 14 additions & 0 deletions ext/readline/tests/readline_read_history_wrongparam_001.phpt
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
--TEST--
Test readline_read_history function : wrong parameter (array)
- test line 412 from readline.c
--CREDITS--
Rodrigo Prado de Jesus <royopa [at] gmail [dot] com>
--SKIPIF--
<?php if (!extension_loaded("readline_info") || !function_exists('readline_read_history') die("skip"); ?>
--FILE--
<?php
$wrong_parameter = array();
$line = readline_read_history($wrong_parameter);
?>
--EXPECTF--
Warning: readline_read_history() expects parameter 1 to be a valid path, array given in %s on line %d
14 changes: 14 additions & 0 deletions ext/readline/tests/readline_wrongparam_001.phpt
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
--TEST--
Test readline function : wrong parameter (array)
- lines from 221 to 223 - readline.c
--CREDITS--
Rodrigo Prado de Jesus <royopa [at] gmail [dot] com>
--SKIPIF--
<?php if (!extension_loaded("readline") die("skip"); ?>
--FILE--
<?php
$wrong_parameter = array();
$line = readline($wrong_parameter);
?>
--EXPECTF--
Warning: readline() expects parameter 1 to be string, array given in %s on line %d
13 changes: 13 additions & 0 deletions ext/readline/tests/readline_wrongparam_002.phpt
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
--TEST--
Check the function readline with 2 parameters (wrong because the function expects only one parameter).
- lines from 221 to 223 - readline.c
--CREDITS--
Rodrigo Prado de Jesus <royopa [at] gmail [dot] com>
--SKIPIF--
<?php if (!extension_loaded("readline") die("skip"); ?>
--FILE--
<?php
$line = readline("Prompt", true);
?>
--EXPECTF--
Warning: readline() expects at most 1 parameter, 2 given in %s on line %d