diff options
Diffstat (limited to 'ext/session')
133 files changed, 11007 insertions, 136 deletions
diff --git a/ext/session/mod_files.c b/ext/session/mod_files.c index 3166b1577..290c0e286 100644 --- a/ext/session/mod_files.c +++ b/ext/session/mod_files.c @@ -2,7 +2,7 @@ +----------------------------------------------------------------------+ | PHP Version 5 | +----------------------------------------------------------------------+ - | Copyright (c) 1997-2007 The PHP Group | + | Copyright (c) 1997-2008 The PHP Group | +----------------------------------------------------------------------+ | This source file is subject to version 3.01 of the PHP license, | | that is bundled with this package in the file LICENSE, and is | @@ -16,7 +16,7 @@ +----------------------------------------------------------------------+ */ -/* $Id: mod_files.c,v 1.100.2.3.2.10 2007/09/10 23:42:54 iliaa Exp $ */ +/* $Id: mod_files.c,v 1.100.2.3.2.11 2007/12/31 07:20:10 sebastian Exp $ */ #include "php.h" diff --git a/ext/session/mod_files.h b/ext/session/mod_files.h index 99ade933e..3fc0a3a01 100644 --- a/ext/session/mod_files.h +++ b/ext/session/mod_files.h @@ -2,7 +2,7 @@ +----------------------------------------------------------------------+ | PHP Version 5 | +----------------------------------------------------------------------+ - | Copyright (c) 1997-2007 The PHP Group | + | Copyright (c) 1997-2008 The PHP Group | +----------------------------------------------------------------------+ | This source file is subject to version 3.01 of the PHP license, | | that is bundled with this package in the file LICENSE, and is | @@ -16,7 +16,7 @@ +----------------------------------------------------------------------+ */ -/* $Id: mod_files.h,v 1.11.2.1.2.1 2007/01/01 09:36:05 sebastian Exp $ */ +/* $Id: mod_files.h,v 1.11.2.1.2.2 2007/12/31 07:20:10 sebastian Exp $ */ #ifndef MOD_FILES_H #define MOD_FILES_H diff --git a/ext/session/mod_mm.c b/ext/session/mod_mm.c index a8859cad4..b3f593d7f 100644 --- a/ext/session/mod_mm.c +++ b/ext/session/mod_mm.c @@ -2,7 +2,7 @@ +----------------------------------------------------------------------+ | PHP Version 5 | +----------------------------------------------------------------------+ - | Copyright (c) 1997-2007 The PHP Group | + | Copyright (c) 1997-2008 The PHP Group | +----------------------------------------------------------------------+ | This source file is subject to version 3.01 of the PHP license, | | that is bundled with this package in the file LICENSE, and is | @@ -16,7 +16,7 @@ +----------------------------------------------------------------------+ */ -/* $Id: mod_mm.c,v 1.46.2.1.2.5 2007/02/27 03:28:16 iliaa Exp $ */ +/* $Id: mod_mm.c,v 1.46.2.1.2.6 2007/12/31 07:20:10 sebastian Exp $ */ #include "php.h" diff --git a/ext/session/mod_mm.h b/ext/session/mod_mm.h index 77ead68fb..98c44c18c 100644 --- a/ext/session/mod_mm.h +++ b/ext/session/mod_mm.h @@ -2,7 +2,7 @@ +----------------------------------------------------------------------+ | PHP Version 5 | +----------------------------------------------------------------------+ - | Copyright (c) 1997-2007 The PHP Group | + | Copyright (c) 1997-2008 The PHP Group | +----------------------------------------------------------------------+ | This source file is subject to version 3.01 of the PHP license, | | that is bundled with this package in the file LICENSE, and is | @@ -16,7 +16,7 @@ +----------------------------------------------------------------------+ */ -/* $Id: mod_mm.h,v 1.12.2.1.2.1 2007/01/01 09:36:05 sebastian Exp $ */ +/* $Id: mod_mm.h,v 1.12.2.1.2.2 2007/12/31 07:20:10 sebastian Exp $ */ #ifndef MOD_MM_H #define MOD_MM_H diff --git a/ext/session/mod_user.c b/ext/session/mod_user.c index 4c28a9cec..d344feef7 100644 --- a/ext/session/mod_user.c +++ b/ext/session/mod_user.c @@ -2,7 +2,7 @@ +----------------------------------------------------------------------+ | PHP Version 5 | +----------------------------------------------------------------------+ - | Copyright (c) 1997-2007 The PHP Group | + | Copyright (c) 1997-2008 The PHP Group | +----------------------------------------------------------------------+ | This source file is subject to version 3.01 of the PHP license, | | that is bundled with this package in the file LICENSE, and is | @@ -16,7 +16,7 @@ +----------------------------------------------------------------------+ */ -/* $Id: mod_user.c,v 1.29.2.1.2.1 2007/01/01 09:36:05 sebastian Exp $ */ +/* $Id: mod_user.c,v 1.29.2.1.2.2 2007/12/31 07:20:10 sebastian Exp $ */ #include "php.h" #include "php_session.h" diff --git a/ext/session/mod_user.h b/ext/session/mod_user.h index e535cc848..c7709c787 100644 --- a/ext/session/mod_user.h +++ b/ext/session/mod_user.h @@ -2,7 +2,7 @@ +----------------------------------------------------------------------+ | PHP Version 5 | +----------------------------------------------------------------------+ - | Copyright (c) 1997-2007 The PHP Group | + | Copyright (c) 1997-2008 The PHP Group | +----------------------------------------------------------------------+ | This source file is subject to version 3.01 of the PHP license, | | that is bundled with this package in the file LICENSE, and is | @@ -16,7 +16,7 @@ +----------------------------------------------------------------------+ */ -/* $Id: mod_user.h,v 1.14.2.1.2.1 2007/01/01 09:36:05 sebastian Exp $ */ +/* $Id: mod_user.h,v 1.14.2.1.2.2 2007/12/31 07:20:10 sebastian Exp $ */ #ifndef MOD_USER_H #define MOD_USER_H diff --git a/ext/session/php_session.h b/ext/session/php_session.h index 5ae237e74..8ff826036 100644 --- a/ext/session/php_session.h +++ b/ext/session/php_session.h @@ -2,7 +2,7 @@ +----------------------------------------------------------------------+ | PHP Version 5 | +----------------------------------------------------------------------+ - | Copyright (c) 1997-2007 The PHP Group | + | Copyright (c) 1997-2008 The PHP Group | +----------------------------------------------------------------------+ | This source file is subject to version 3.01 of the PHP license, | | that is bundled with this package in the file LICENSE, and is | @@ -16,7 +16,7 @@ +----------------------------------------------------------------------+ */ -/* $Id: php_session.h,v 1.101.2.2.2.5 2007/02/06 00:01:18 iliaa Exp $ */ +/* $Id: php_session.h,v 1.101.2.2.2.6 2007/12/31 07:20:10 sebastian Exp $ */ #ifndef PHP_SESSION_H #define PHP_SESSION_H diff --git a/ext/session/session.c b/ext/session/session.c index 9ec40f6e2..520c820f3 100644 --- a/ext/session/session.c +++ b/ext/session/session.c @@ -2,7 +2,7 @@ +----------------------------------------------------------------------+ | PHP Version 5 | +----------------------------------------------------------------------+ - | Copyright (c) 1997-2007 The PHP Group | + | Copyright (c) 1997-2008 The PHP Group | +----------------------------------------------------------------------+ | This source file is subject to version 3.01 of the PHP license, | | that is bundled with this package in the file LICENSE, and is | @@ -17,7 +17,7 @@ +----------------------------------------------------------------------+ */ -/* $Id: session.c,v 1.417.2.8.2.40 2007/08/03 01:16:40 stas Exp $ */ +/* $Id: session.c,v 1.417.2.8.2.42 2008/04/29 14:42:38 scottmac Exp $ */ #ifdef HAVE_CONFIG_H #include "config.h" @@ -78,7 +78,7 @@ zend_function_entry session_functions[] = { PHP_FE(session_get_cookie_params, NULL) PHP_FE(session_write_close, NULL) PHP_FALIAS(session_commit, session_write_close, NULL) - {NULL, NULL, NULL} + {NULL, NULL, NULL} }; /* }}} */ @@ -232,7 +232,7 @@ static ps_module *ps_modules[MAX_MODULES + 1] = { #define IF_SESSION_VARS() \ if (PS(http_session_vars) && PS(http_session_vars)->type == IS_ARRAY) -PHPAPI int php_session_register_serializer(const char *name, +PHPAPI int php_session_register_serializer(const char *name, int (*encode)(PS_SERIALIZER_ENCODE_ARGS), int (*decode)(PS_SERIALIZER_DECODE_ARGS)) { @@ -263,9 +263,9 @@ PHPAPI int php_session_register_module(ps_module *ptr) ps_modules[i] = ptr; ret = 0; break; - } + } } - + return ret; } @@ -316,7 +316,7 @@ PHPAPI void php_add_session_var(char *name, size_t namelen TSRMLS_DC) zval **sym_track = NULL; IF_SESSION_VARS() { - zend_hash_find(Z_ARRVAL_P(PS(http_session_vars)), name, namelen + 1, + zend_hash_find(Z_ARRVAL_P(PS(http_session_vars)), name, namelen + 1, (void *) &sym_track); } else { return; @@ -328,8 +328,8 @@ PHPAPI void php_add_session_var(char *name, size_t namelen TSRMLS_DC) if (PG(register_globals)) { zval **sym_global = NULL; - - if (zend_hash_find(&EG(symbol_table), name, namelen + 1, (void *) &sym_global) == SUCCESS) { + + if (zend_hash_find(&EG(symbol_table), name, namelen + 1, (void *) &sym_global) == SUCCESS) { if ((Z_TYPE_PP(sym_global) == IS_ARRAY && Z_ARRVAL_PP(sym_global) == &EG(symbol_table)) || *sym_global == PS(http_session_vars)) { return; } @@ -352,7 +352,7 @@ PHPAPI void php_add_session_var(char *name, size_t namelen TSRMLS_DC) } else { if (sym_track == NULL) { zval *empty_var; - + ALLOC_INIT_ZVAL(empty_var); ZEND_SET_SYMBOL_WITH_LENGTH(Z_ARRVAL_P(PS(http_session_vars)), name, namelen+1, empty_var, 1, 0); } @@ -363,12 +363,12 @@ PHPAPI void php_set_session_var(char *name, size_t namelen, zval *state_val, php { if (PG(register_globals)) { zval **old_symbol; - if (zend_hash_find(&EG(symbol_table),name,namelen+1,(void *)&old_symbol) == SUCCESS) { + if (zend_hash_find(&EG(symbol_table),name,namelen+1,(void *)&old_symbol) == SUCCESS) { if ((Z_TYPE_PP(old_symbol) == IS_ARRAY && Z_ARRVAL_PP(old_symbol) == &EG(symbol_table)) || *old_symbol == PS(http_session_vars)) { return; } - /* + /* * A global symbol with the same name exists already. That * symbol might have been created by other means (e.g. $_GET). * @@ -380,12 +380,12 @@ PHPAPI void php_set_session_var(char *name, size_t namelen, zval *state_val, php * session-vars won't work because of this very reason! */ - + REPLACE_ZVAL_VALUE(old_symbol,state_val,1); /* * The following line will update the reference table used for - * unserialization. It is optional, because some storage + * unserialization. It is optional, because some storage * formats may not be able to represent references. */ @@ -407,7 +407,7 @@ PHPAPI int php_get_session_var(char *name, size_t namelen, zval ***state_var TSR int ret = FAILURE; IF_SESSION_VARS() { - ret = zend_hash_find(Z_ARRVAL_P(PS(http_session_vars)), name, + ret = zend_hash_find(Z_ARRVAL_P(PS(http_session_vars)), name, namelen+1, (void **) state_var); /* @@ -417,8 +417,8 @@ PHPAPI int php_get_session_var(char *name, size_t namelen, zval ***state_var TSR * if the global var exists, then * we prefer the same key in the global sym table */ - - if (PG(register_globals) && ret == SUCCESS + + if (PG(register_globals) && ret == SUCCESS && Z_TYPE_PP(*state_var) == IS_NULL) { zval **tmp; @@ -428,7 +428,7 @@ PHPAPI int php_get_session_var(char *name, size_t namelen, zval ***state_var TSR } } } - + return ret; } @@ -448,14 +448,14 @@ PS_SERIALIZER_ENCODE_FUNC(php_binary) if (key_length > PS_BIN_MAX) continue; smart_str_appendc(&buf, (unsigned char) key_length); smart_str_appendl(&buf, key, key_length); - + php_var_serialize(&buf, struc, &var_hash TSRMLS_CC); } else { if (key_length > PS_BIN_MAX) continue; smart_str_appendc(&buf, (unsigned char) (key_length & PS_BIN_UNDEF)); smart_str_appendl(&buf, key, key_length); ); - + if (newlen) *newlen = buf.len; *newstr = buf.c; PHP_VAR_SERIALIZE_DESTROY(var_hash); @@ -527,18 +527,18 @@ PS_SERIALIZER_ENCODE_FUNC(php) smart_str_appendl(&buf, key, key_length); if (memchr(key, PS_DELIMITER, key_length)) { PHP_VAR_SERIALIZE_DESTROY(var_hash); - smart_str_free(&buf); + smart_str_free(&buf); return FAILURE; } smart_str_appendc(&buf, PS_DELIMITER); - + php_var_serialize(&buf, struc, &var_hash TSRMLS_CC); } else { smart_str_appendc(&buf, PS_UNDEF_MARKER); smart_str_appendl(&buf, key, key_length); smart_str_appendc(&buf, PS_DELIMITER); ); - + if (newlen) *newlen = buf.len; *newstr = buf.c; @@ -546,7 +546,7 @@ PS_SERIALIZER_ENCODE_FUNC(php) return SUCCESS; } -PS_SERIALIZER_DECODE_FUNC(php) +PS_SERIALIZER_DECODE_FUNC(php) { const char *p, *q; char *name; @@ -565,14 +565,14 @@ PS_SERIALIZER_DECODE_FUNC(php) q = p; while (*q != PS_DELIMITER) if (++q >= endptr) goto break_outer_loop; - + if (p[0] == PS_UNDEF_MARKER) { p++; has_value = 0; } else { has_value = 1; } - + namelen = q - p; name = estrndup(p, namelen); q++; @@ -596,7 +596,7 @@ skip: p = q; } break_outer_loop: - + PHP_VAR_UNSERIALIZE_DESTROY(var_hash); return SUCCESS; @@ -605,7 +605,7 @@ break_outer_loop: static void php_session_track_init(TSRMLS_D) { zval *session_vars = NULL; - + /* Unconditionally destroy existing arrays -- possible dirty data */ zend_delete_global_variable("HTTP_SESSION_VARS", sizeof("HTTP_SESSION_VARS")-1 TSRMLS_CC); zend_delete_global_variable("_SESSION", sizeof("_SESSION")-1 TSRMLS_CC); @@ -617,7 +617,7 @@ static void php_session_track_init(TSRMLS_D) MAKE_STD_ZVAL(session_vars); array_init(session_vars); PS(http_session_vars) = session_vars; - + if (PG(register_long_arrays)) { ZEND_SET_GLOBAL_VAR_WITH_LENGTH("HTTP_SESSION_VARS", sizeof("HTTP_SESSION_VARS"), PS(http_session_vars), 3, 1); ZEND_SET_GLOBAL_VAR_WITH_LENGTH("_SESSION", sizeof("_SESSION"), PS(http_session_vars), 3, 1); @@ -678,14 +678,14 @@ static char *bin_to_readable(char *in, size_t inlen, char *out, char nbits) unsigned short w; int mask; int have; - + p = (unsigned char *) in; q = (unsigned char *)in + inlen; w = 0; have = 0; mask = (1 << nbits) - 1; - + while (1) { if (have < nbits) { if (p < q) { @@ -704,7 +704,7 @@ static char *bin_to_readable(char *in, size_t inlen, char *out, char nbits) w >>= nbits; have -= nbits; } - + *out = '\0'; return out; } @@ -723,7 +723,7 @@ PHPAPI char *php_session_create_id(PS_CREATE_SID_ARGS) char *remote_addr = NULL; gettimeofday(&tv, NULL); - + if (zend_hash_find(&EG(symbol_table), "_SERVER", sizeof("_SERVER"), (void **) &array) == SUCCESS && Z_TYPE_PP(array) == IS_ARRAY && @@ -732,8 +732,8 @@ PHPAPI char *php_session_create_id(PS_CREATE_SID_ARGS) remote_addr = Z_STRVAL_PP(token); } - /* maximum 15+19+19+10 bytes */ - spprintf(&buf, 0, "%.15s%ld%ld%0.8F", remote_addr ? remote_addr : "", + /* maximum 15+19+19+10 bytes */ + spprintf(&buf, 0, "%.15s%ld%ld%0.8F", remote_addr ? remote_addr : "", tv.tv_sec, (long int)tv.tv_usec, php_combined_lcg(TSRMLS_C) * 10); switch (PS(hash_func)) { @@ -761,11 +761,11 @@ PHPAPI char *php_session_create_id(PS_CREATE_SID_ARGS) unsigned char rbuf[2048]; int n; int to_read = PS(entropy_length); - + while (to_read > 0) { n = read(fd, rbuf, MIN(to_read, sizeof(rbuf))); if (n <= 0) break; - + switch (PS(hash_func)) { case PS_HASH_FUNC_MD5: PHP_MD5Update(&md5_context, rbuf, n); @@ -796,8 +796,8 @@ PHPAPI char *php_session_create_id(PS_CREATE_SID_ARGS) php_error_docref(NULL TSRMLS_CC, E_WARNING, "The ini setting hash_bits_per_character is out of range (should be 4, 5, or 6) - using 4 for now"); } j = (int) (bin_to_readable((char *)digest, digest_len, buf, PS(hash_bits_per_character)) - buf); - - if (newlen) + + if (newlen) *newlen = j; return buf; } @@ -823,7 +823,7 @@ static void php_session_initialize(TSRMLS_D) php_error_docref(NULL TSRMLS_CC, E_ERROR, "Failed to initialize storage module: %s (path: %s)", PS(mod)->s_name, PS(save_path)); return; } - + /* If there is no ID, use session module to create one */ if (!PS(id)) { new_session: @@ -832,7 +832,7 @@ new_session: PS(send_cookie) = 1; } } - + /* Read data */ /* Question: if you create a SID here, should you also try to read data? * I'm not sure, but while not doing so will remove one session operation @@ -860,15 +860,15 @@ static int migrate_global(HashTable *ht, HashPosition *pos TSRMLS_DC) int n; zval **val; int ret = 0; - + n = zend_hash_get_current_key_ex(ht, &str, &str_len, &num_key, 0, pos); switch (n) { case HASH_KEY_IS_STRING: - if (zend_hash_find(&EG(symbol_table), str, str_len, - (void **) &val) == SUCCESS + if (zend_hash_find(&EG(symbol_table), str, str_len, + (void **) &val) == SUCCESS && val && Z_TYPE_PP(val) != IS_NULL) { - ZEND_SET_SYMBOL_WITH_LENGTH(ht, str, str_len, *val, + ZEND_SET_SYMBOL_WITH_LENGTH(ht, str, str_len, *val, (*val)->refcount + 1 , 1); ret = 1; } @@ -879,14 +879,14 @@ static int migrate_global(HashTable *ht, HashPosition *pos TSRMLS_DC) "numeric nature.", num_key); break; } - + return ret; } static void php_session_save_current_state(TSRMLS_D) { int ret = FAILURE; - + IF_SESSION_VARS() { if (PS(bug_compat) && !PG(register_globals)) { HashTable *ht = Z_ARRVAL_P(PS(http_session_vars)); @@ -896,7 +896,7 @@ static void php_session_save_current_state(TSRMLS_D) zend_hash_internal_pointer_reset_ex(ht, &pos); - while (zend_hash_get_current_data_ex(ht, + while (zend_hash_get_current_data_ex(ht, (void **) &val, &pos) != FAILURE) { if (Z_TYPE_PP(val) == IS_NULL) { if (migrate_global(ht, &pos TSRMLS_CC)) @@ -930,7 +930,7 @@ static void php_session_save_current_state(TSRMLS_D) PS(mod)->s_name, PS(save_path)); } - + if (PS(mod_data)) PS(mod)->s_close(&PS(mod_data) TSRMLS_CC); } @@ -949,18 +949,18 @@ static void strcpy_gmt(char *ubuf, time_t *when) char buf[MAX_STR]; struct tm tm, *res; int n; - + res = php_gmtime_r(when, &tm); if (!res) { buf[0] = '\0'; return; } - + n = slprintf(buf, sizeof(buf), "%s, %02d %s %d %02d:%02d:%02d GMT", /* SAFE */ - week_days[tm.tm_wday], tm.tm_mday, - month_names[tm.tm_mon], tm.tm_year + 1900, - tm.tm_hour, tm.tm_min, + week_days[tm.tm_wday], tm.tm_mday, + month_names[tm.tm_mon], tm.tm_year + 1900, + tm.tm_hour, tm.tm_min, tm.tm_sec); memcpy(ubuf, buf, n); ubuf[n] = '\0'; @@ -971,7 +971,7 @@ static void last_modified(TSRMLS_D) const char *path; struct stat sb; char buf[MAX_STR + 1]; - + path = SG(request_info).path_translated; if (path) { if (VCWD_STAT(path, &sb) == -1) { @@ -994,24 +994,24 @@ CACHE_LIMITER_FUNC(public) char buf[MAX_STR + 1]; struct timeval tv; time_t now; - + gettimeofday(&tv, NULL); now = tv.tv_sec + PS(cache_expire) * 60; #define EXPIRES "Expires: " memcpy(buf, EXPIRES, sizeof(EXPIRES) - 1); strcpy_gmt(buf + sizeof(EXPIRES) - 1, &now); ADD_HEADER(buf); - + snprintf(buf, sizeof(buf) , "Cache-Control: public, max-age=%ld", PS(cache_expire) * 60); /* SAFE */ ADD_HEADER(buf); - + last_modified(TSRMLS_C); } CACHE_LIMITER_FUNC(private_no_expire) { char buf[MAX_STR + 1]; - + snprintf(buf, sizeof(buf), "Cache-Control: private, max-age=%ld, pre-check=%ld", PS(cache_expire) * 60, PS(cache_expire) * 60); /* SAFE */ ADD_HEADER(buf); @@ -1046,7 +1046,7 @@ static int php_session_cache_limiter(TSRMLS_D) php_session_cache_limiter_t *lim; if (PS(cache_limiter)[0] == '\0') return 0; - + if (SG(headers_sent)) { char *output_start_filename = php_get_output_start_filename(TSRMLS_C); int output_start_lineno = php_get_output_start_lineno(TSRMLS_C); @@ -1056,10 +1056,10 @@ static int php_session_cache_limiter(TSRMLS_D) output_start_filename, output_start_lineno); } else { php_error_docref(NULL TSRMLS_CC, E_WARNING, "Cannot send session cache limiter - headers already sent"); - } + } return -2; } - + for (lim = php_session_cache_limiters; lim->name; lim++) { if (!strcasecmp(lim->name, PS(cache_limiter))) { lim->func(TSRMLS_C); @@ -1092,10 +1092,10 @@ static void php_session_send_cookie(TSRMLS_D) output_start_filename, output_start_lineno); } else { php_error_docref(NULL TSRMLS_CC, E_WARNING, "Cannot send session cookie - headers already sent"); - } + } return; } - + /* URL encode session_name and id because they might be user supplied */ e_session_name = php_url_encode(PS(session_name), strlen(PS(session_name)), NULL); e_id = php_url_encode(PS(id), strlen(PS(id)), NULL); @@ -1104,17 +1104,17 @@ static void php_session_send_cookie(TSRMLS_D) smart_str_appends(&ncookie, e_session_name); smart_str_appendc(&ncookie, '='); smart_str_appends(&ncookie, e_id); - + efree(e_session_name); efree(e_id); - + if (PS(cookie_lifetime) > 0) { struct timeval tv; time_t t; - + gettimeofday(&tv, NULL); t = tv.tv_sec + PS(cookie_lifetime); - + if (t > 0) { date_fmt = php_std_date(t TSRMLS_CC); smart_str_appends(&ncookie, COOKIE_EXPIRES); @@ -1127,7 +1127,7 @@ static void php_session_send_cookie(TSRMLS_D) smart_str_appends(&ncookie, COOKIE_PATH); smart_str_appends(&ncookie, PS(cookie_path)); } - + if (PS(cookie_domain)[0]) { smart_str_appends(&ncookie, COOKIE_DOMAIN); smart_str_appends(&ncookie, PS(cookie_domain)); @@ -1142,7 +1142,7 @@ static void php_session_send_cookie(TSRMLS_D) } smart_str_0(&ncookie); - + /* 'replace' must be 0 here, else a previous Set-Cookie header, probably sent with setcookie() will be replaced! */ sapi_add_header_ex(ncookie.c, ncookie.len, 0, 0 TSRMLS_CC); @@ -1159,7 +1159,7 @@ PHPAPI ps_module *_php_find_ps_module(char *name TSRMLS_DC) ret = *mod; break; } - + return ret; } @@ -1184,7 +1184,7 @@ PHPAPI const ps_serializer *_php_find_ps_serializer(char *name TSRMLS_DC) static void php_session_reset_id(TSRMLS_D) { int module_number = PS(module_number); - + if (PS(use_cookies) && PS(send_cookie)) { php_session_send_cookie(TSRMLS_C); PS(send_cookie) = 0; @@ -1192,7 +1192,7 @@ static void php_session_reset_id(TSRMLS_D) /* if the SID constant exists, destroy it. */ zend_hash_del(EG(zend_constants), "sid", sizeof("sid")); - + if (PS(define_sid)) { smart_str var = {0}; @@ -1210,7 +1210,7 @@ static void php_session_reset_id(TSRMLS_D) php_url_scanner_add_var(PS(session_name), strlen(PS(session_name)), PS(id), strlen(PS(id)), 1 TSRMLS_CC); } } - + PHPAPI void php_session_start(TSRMLS_D) { zval **ppid; @@ -1226,8 +1226,8 @@ PHPAPI void php_session_start(TSRMLS_D) char *value; value = zend_ini_string("session.save_handler", sizeof("session.save_handler"), 0); - - if (value) { + + if (value) { php_error_docref(NULL TSRMLS_CC, E_WARNING, "Cannot find save handler %s", value); } else { @@ -1235,7 +1235,7 @@ PHPAPI void php_session_start(TSRMLS_D) } return; } - + php_error(E_NOTICE, "A session had already been started - ignoring session_start()"); return; } else { @@ -1244,11 +1244,11 @@ PHPAPI void php_session_start(TSRMLS_D) } lensess = strlen(PS(session_name)); - + /* * Cookies are preferred, because initially - * cookie and get variables will be available. + * cookie and get variables will be available. */ if (!PS(id)) { @@ -1306,7 +1306,7 @@ PHPAPI void php_session_start(TSRMLS_D) /* check whether the current request was referred to by an external site which invalidates the previously found id */ - + if (PS(id) && PS(extern_referer_chk)[0] != '\0' && PG(http_globals)[TRACK_VARS_SERVER] && @@ -1321,9 +1321,9 @@ PHPAPI void php_session_start(TSRMLS_D) if (PS(use_trans_sid)) PS(apply_trans_sid) = 1; } - + php_session_initialize(TSRMLS_C); - + if (!PS(use_cookies) && PS(send_cookie)) { if (PS(use_trans_sid)) PS(apply_trans_sid) = 1; @@ -1331,7 +1331,7 @@ PHPAPI void php_session_start(TSRMLS_D) } php_session_reset_id(TSRMLS_C); - + PS(session_status) = php_session_active; php_session_cache_limiter(TSRMLS_C); @@ -1363,7 +1363,7 @@ static int php_session_destroy(TSRMLS_D) retval = FAILURE; php_error_docref(NULL TSRMLS_CC, E_WARNING, "Session object destruction failed"); } - + php_rshutdown_session_globals(TSRMLS_C); php_rinit_session_globals(TSRMLS_C); @@ -1408,7 +1408,7 @@ PHP_FUNCTION(session_set_cookie_params) /* }}} */ /* {{{ proto array session_get_cookie_params(void) - Return the session cookie parameters */ + Return the session cookie parameters */ PHP_FUNCTION(session_get_cookie_params) { if (ZEND_NUM_ARGS() != 0) { @@ -1435,14 +1435,14 @@ PHP_FUNCTION(session_name) if (ac < 0 || ac > 1 || zend_get_parameters_ex(ac, &p_name) == FAILURE) WRONG_PARAM_COUNT; - + old = estrdup(PS(session_name)); if (ac == 1) { convert_to_string_ex(p_name); zend_alter_ini_entry("session.name", sizeof("session.name"), Z_STRVAL_PP(p_name), Z_STRLEN_PP(p_name), PHP_INI_USER, PHP_INI_STAGE_RUNTIME); } - + RETVAL_STRING(old, 0); } /* }}} */ @@ -1464,7 +1464,7 @@ PHP_FUNCTION(session_module_name) } else { RETVAL_EMPTY_STRING(); } - + if (ac == 1) { convert_to_string_ex(p_name); if (!_php_find_ps_module(Z_STRVAL_PP(p_name) TSRMLS_CC)) { @@ -1494,10 +1494,10 @@ PHP_FUNCTION(session_set_save_handler) if (ZEND_NUM_ARGS() != 6 || zend_get_parameters_array_ex(6, args) == FAILURE) WRONG_PARAM_COUNT; - - if (PS(session_status) != php_session_none) + + if (PS(session_status) != php_session_none) RETURN_FALSE; - + for (i = 0; i < 6; i++) { if (!zend_is_callable(*args[i], 0, &name)) { php_error_docref(NULL TSRMLS_CC, E_WARNING, "Argument %d is not a valid callback", i+1); @@ -1506,18 +1506,18 @@ PHP_FUNCTION(session_set_save_handler) } efree(name); } - + zend_alter_ini_entry("session.save_handler", sizeof("session.save_handler"), "user", sizeof("user")-1, PHP_INI_USER, PHP_INI_STAGE_RUNTIME); mdata = emalloc(sizeof(*mdata)); - + for (i = 0; i < 6; i++) { ZVAL_ADDREF(*args[i]); mdata->names[i] = *args[i]; } PS(mod_data) = (void *) mdata; - + RETURN_TRUE; } /* }}} */ @@ -1532,14 +1532,14 @@ PHP_FUNCTION(session_save_path) if (ac < 0 || ac > 1 || zend_get_parameters_ex(ac, &p_name) == FAILURE) WRONG_PARAM_COUNT; - + old = estrdup(PS(save_path)); if (ac == 1) { convert_to_string_ex(p_name); zend_alter_ini_entry("session.save_path", sizeof("session.save_path"), Z_STRVAL_PP(p_name), Z_STRLEN_PP(p_name), PHP_INI_USER, PHP_INI_STAGE_RUNTIME); } - + RETVAL_STRING(old, 0); } /* }}} */ @@ -1566,7 +1566,7 @@ PHP_FUNCTION(session_id) if (PS(id)) efree(PS(id)); PS(id) = estrndup(Z_STRVAL_PP(p_name), Z_STRLEN_PP(p_name)); } - + RETVAL_STRING(old, 0); } /* }}} */ @@ -1595,12 +1595,12 @@ PHP_FUNCTION(session_regenerate_id) efree(PS(id)); PS(id) = NULL; } - + PS(id) = PS(mod)->s_create_sid(&PS(mod_data), NULL TSRMLS_CC); PS(send_cookie) = 1; php_session_reset_id(TSRMLS_C); - + RETURN_TRUE; } RETURN_FALSE; @@ -1617,14 +1617,14 @@ PHP_FUNCTION(session_cache_limiter) if (ac < 0 || ac > 1 || zend_get_parameters_ex(ac, &p_cache_limiter) == FAILURE) WRONG_PARAM_COUNT; - + old = estrdup(PS(cache_limiter)); if (ac == 1) { convert_to_string_ex(p_cache_limiter); zend_alter_ini_entry("session.cache_limiter", sizeof("session.cache_limiter"), Z_STRVAL_PP(p_cache_limiter), Z_STRLEN_PP(p_cache_limiter), PHP_INI_USER, PHP_INI_STAGE_RUNTIME); } - + RETVAL_STRING(old, 0); } /* }}} */ @@ -1655,14 +1655,21 @@ PHP_FUNCTION(session_cache_expire) static void php_register_var(zval** entry TSRMLS_DC) { zval **value; - + if (Z_TYPE_PP(entry) == IS_ARRAY) { + if (Z_ARRVAL_PP(entry)->nApplyCount > 1) { + return; + } + zend_hash_internal_pointer_reset(Z_ARRVAL_PP(entry)); + Z_ARRVAL_PP(entry)->nApplyCount++; while (zend_hash_get_current_data(Z_ARRVAL_PP(entry), (void**)&value) == SUCCESS) { php_register_var(value TSRMLS_CC); zend_hash_move_forward(Z_ARRVAL_PP(entry)); } + + Z_ARRVAL_PP(entry)->nApplyCount--; } else { convert_to_string_ex(entry); @@ -1686,7 +1693,7 @@ PHP_FUNCTION(session_register) RETURN_FALSE else args = (zval ***)safe_emalloc(argc, sizeof(zval **), 0); - + if (zend_get_parameters_array_ex(argc, args) == FAILURE) { efree(args); WRONG_PARAM_COUNT; @@ -1695,20 +1702,20 @@ PHP_FUNCTION(session_register) if (PS(session_status) == php_session_none || PS(session_status) == php_session_disabled) { php_session_start(TSRMLS_C); } - + if (PS(session_status) == php_session_disabled) { efree(args); RETURN_FALSE; } - + for (i = 0; i < argc; i++) { if (Z_TYPE_PP(args[i]) == IS_ARRAY) SEPARATE_ZVAL(args[i]); php_register_var(args[i] TSRMLS_CC); - } - + } + efree(args); - + RETURN_TRUE; } /* }}} */ @@ -1722,9 +1729,9 @@ PHP_FUNCTION(session_unregister) if (ac != 1 || zend_get_parameters_ex(ac, &p_name) == FAILURE) WRONG_PARAM_COUNT; - + convert_to_string_ex(p_name); - + PS_DEL_VARL(Z_STRVAL_PP(p_name), Z_STRLEN_PP(p_name)); RETURN_TRUE; @@ -1741,15 +1748,15 @@ PHP_FUNCTION(session_is_registered) if (ac != 1 || zend_get_parameters_ex(ac, &p_name) == FAILURE) WRONG_PARAM_COUNT; - + convert_to_string_ex(p_name); - + if (PS(session_status) == php_session_none) RETURN_FALSE; IF_SESSION_VARS() { - if (zend_hash_find(Z_ARRVAL_P(PS(http_session_vars)), - Z_STRVAL_PP(p_name), Z_STRLEN_PP(p_name)+1, + if (zend_hash_find(Z_ARRVAL_P(PS(http_session_vars)), + Z_STRVAL_PP(p_name), Z_STRLEN_PP(p_name)+1, (void **)&p_var) == SUCCESS) { RETURN_TRUE; } @@ -1773,7 +1780,7 @@ PHP_FUNCTION(session_encode) if (enc == NULL) { RETURN_FALSE; } - + RETVAL_STRINGL(enc, len, 0); } /* }}} */ @@ -1795,7 +1802,7 @@ PHP_FUNCTION(session_decode) convert_to_string_ex(str); php_session_decode(Z_STRVAL_PP(str), Z_STRLEN_PP(str) TSRMLS_CC); - + RETURN_TRUE; } /* }}} */ @@ -1842,16 +1849,16 @@ PHP_FUNCTION(session_unset) char *str; ulong num_key; HashPosition pos; - + zend_hash_internal_pointer_reset_ex(ht, &pos); - while (zend_hash_get_current_key_ex(ht, &str, &str_len, &num_key, + while (zend_hash_get_current_key_ex(ht, &str, &str_len, &num_key, 0, &pos) == HASH_KEY_IS_STRING) { zend_delete_global_variable(str, str_len-1 TSRMLS_CC); zend_hash_move_forward_ex(ht, &pos); } } - + /* Clean $_SESSION. */ zend_hash_clean(ht); } @@ -1866,7 +1873,7 @@ PHPAPI void session_adapt_url(const char *url, size_t urllen, char **new, size_t } static void php_rinit_session_globals(TSRMLS_D) -{ +{ PS(id) = NULL; PS(session_status) = php_session_none; PS(mod_data) = NULL; @@ -1990,7 +1997,7 @@ PHP_MINFO_FUNCTION(session) smart_str save_handlers = {0}; smart_str ser_handlers = {0}; int i; - + /* Get save handlers */ for (i = 0, mod = ps_modules; i < MAX_MODULES; i++, mod++) { if (*mod && (*mod)->s_name) { @@ -2006,7 +2013,7 @@ PHP_MINFO_FUNCTION(session) smart_str_appendc(&ser_handlers, ' '); } } - + php_info_print_table_start(); php_info_print_table_row(2, "Session Support", "enabled" ); diff --git a/ext/session/tests/023.phpt b/ext/session/tests/023.phpt new file mode 100644 index 000000000..42b1e5b1b --- /dev/null +++ b/ext/session/tests/023.phpt @@ -0,0 +1,46 @@ +--TEST-- +session object deserialization +--SKIPIF-- +<?php include('skipif.inc'); ?> +--INI-- +session.use_cookies=0 +session.cache_limiter= +session.serialize_handler=php +session.save_handler=files +--FILE-- +<?php +error_reporting(E_ALL); + +class foo { + public $bar = "ok"; + function method() { $this->yes++; } +} + +session_id("abtest"); +session_start(); +session_decode('baz|O:3:"foo":2:{s:3:"bar";s:2:"ok";s:3:"yes";i:1;}arr|a:1:{i:3;O:3:"foo":2:{s:3:"bar";s:2:"ok";s:3:"yes";i:1;}}'); +$baz = $_SESSION['baz']; +$arr = $_SESSION['arr']; + +$baz->method(); +$arr[3]->method(); + +var_dump($baz); +var_dump($arr); +session_destroy(); +--EXPECT-- +object(foo)#1 (2) { + ["bar"]=> + string(2) "ok" + ["yes"]=> + int(2) +} +array(1) { + [3]=> + object(foo)#2 (2) { + ["bar"]=> + string(2) "ok" + ["yes"]=> + int(2) + } +} diff --git a/ext/session/tests/024.phpt b/ext/session/tests/024.phpt new file mode 100644 index 000000000..2ad26067a --- /dev/null +++ b/ext/session/tests/024.phpt @@ -0,0 +1,114 @@ +--TEST-- +session_set_save_handler test +--SKIPIF-- +<?php include('skipif.inc'); ?> +--INI-- +session.use_cookies=0 +session.cache_limiter= +session.name=PHPSESSID +session.serialize_handler=php +--FILE-- +<?php +error_reporting(E_ALL); + +class handler { + public $data = 'baz|O:3:"foo":2:{s:3:"bar";s:2:"ok";s:3:"yes";i:1;}arr|a:1:{i:3;O:3:"foo":2:{s:3:"bar";s:2:"ok";s:3:"yes";i:1;}}'; + + function open($save_path, $session_name) + { + print "OPEN: $session_name\n"; + return true; + } + function close() + { + return true; + } + function read($key) + { + print "READ: $key\n"; + return $GLOBALS["hnd"]->data; + } + + function write($key, $val) + { + print "WRITE: $key, $val\n"; + $GLOBALS["hnd"]->data = $val; + return true; + } + + function destroy($key) + { + print "DESTROY: $key\n"; + return true; + } + + function gc() { return true; } +} + +$hnd = new handler; + +class foo { + public $bar = "ok"; + function method() { $this->yes++; } +} + +session_set_save_handler(array($hnd, "open"), array($hnd, "close"), array($hnd, "read"), array($hnd, "write"), array($hnd, "destroy"), array($hnd, "gc")); + +session_id("abtest"); +session_start(); + +$baz = $_SESSION['baz']; +$arr = $_SESSION['arr']; +$baz->method(); +$arr[3]->method(); + +var_dump($baz); +var_dump($arr); + +session_write_close(); + +session_set_save_handler(array($hnd, "open"), array($hnd, "close"), array($hnd, "read"), array($hnd, "write"), array($hnd, "destroy"), array($hnd, "gc")); +session_start(); + +var_dump($baz); +var_dump($arr); + +session_destroy(); +?> +--EXPECTF-- +OPEN: PHPSESSID +READ: abtest +object(foo)#%d (2) { + ["bar"]=> + string(2) "ok" + ["yes"]=> + int(2) +} +array(1) { + [3]=> + object(foo)#%d (2) { + ["bar"]=> + string(2) "ok" + ["yes"]=> + int(2) + } +} +WRITE: abtest, baz|O:3:"foo":2:{s:3:"bar";s:2:"ok";s:3:"yes";i:2;}arr|a:1:{i:3;O:3:"foo":2:{s:3:"bar";s:2:"ok";s:3:"yes";i:2;}} +OPEN: PHPSESSID +READ: abtest +object(foo)#%d (2) { + ["bar"]=> + string(2) "ok" + ["yes"]=> + int(2) +} +array(1) { + [3]=> + object(foo)#%d (2) { + ["bar"]=> + string(2) "ok" + ["yes"]=> + int(2) + } +} +DESTROY: abtest diff --git a/ext/session/tests/025.phpt b/ext/session/tests/025.phpt new file mode 100644 index 000000000..4fd095f81 --- /dev/null +++ b/ext/session/tests/025.phpt @@ -0,0 +1,159 @@ +--TEST-- +custom save handler, multiple session_start()s, complex data structure test. +--SKIPIF-- +<?php include('skipif.inc'); ?> +--INI-- +session.use_cookies=0 +session.cache_limiter= +session.name=PHPSESSID +session.serialize_handler=php +--FILE-- +<?php + +error_reporting(E_ALL); + +class handler { + public $data = 'baz|O:3:"foo":2:{s:3:"bar";s:2:"ok";s:3:"yes";i:1;}arr|a:1:{i:3;O:3:"foo":2:{s:3:"bar";s:2:"ok";s:3:"yes";i:1;}}'; + + function open($save_path, $session_name) + { + print "OPEN: $session_name\n"; + return true; + } + function close() + { + print "CLOSE\n"; + return true; + } + function read($key) + { + print "READ: $key\n"; + return $GLOBALS["hnd"]->data; + } + + function write($key, $val) + { + print "WRITE: $key, $val\n"; + $GLOBALS["hnd"]->data = $val; + return true; + } + + function destroy($key) + { + print "DESTROY: $key\n"; + return true; + } + + function gc() { return true; } + + function __construct() + { + if (ini_get("unicode.semantics")) { + $this->data = str_replace('s:', 'U:', $this->data); + } + } +} + +$hnd = new handler; + +class foo { + public $bar = "ok"; + function method() { $this->yes++; } +} + +session_set_save_handler(array($hnd, "open"), array($hnd, "close"), array($hnd, "read"), array($hnd, "write"), array($hnd, "destroy"), array($hnd, "gc")); + +session_id("abtest"); +session_start(); +$baz = $_SESSION['baz']; +$arr = $_SESSION['arr']; +$baz->method(); +$arr[3]->method(); + +var_dump($baz); +var_dump($arr); + +session_write_close(); + +session_set_save_handler(array($hnd, "open"), array($hnd, "close"), array($hnd, "read"), array($hnd, "write"), array($hnd, "destroy"), array($hnd, "gc")); +session_start(); +$baz = $_SESSION['baz']; +$arr = $_SESSION['arr']; + + +$baz->method(); +$arr[3]->method(); + + +$c = 123; +$_SESSION['c'] = $c; +var_dump($baz); var_dump($arr); var_dump($c); + +session_write_close(); + +session_set_save_handler(array($hnd, "open"), array($hnd, "close"), array($hnd, "read"), array($hnd, "write"), array($hnd, "destroy"), array($hnd, "gc")); +session_start(); +var_dump($baz); var_dump($arr); var_dump($c); + +session_destroy(); +?> +--EXPECTF-- +OPEN: PHPSESSID +READ: abtest +object(foo)#%d (2) { + ["bar"]=> + string(2) "ok" + ["yes"]=> + int(2) +} +array(1) { + [3]=> + object(foo)#%d (2) { + ["bar"]=> + string(2) "ok" + ["yes"]=> + int(2) + } +} +WRITE: abtest, baz|O:3:"foo":2:{s:3:"bar";s:2:"ok";s:3:"yes";i:2;}arr|a:1:{i:3;O:3:"foo":2:{s:3:"bar";s:2:"ok";s:3:"yes";i:2;}} +CLOSE +OPEN: PHPSESSID +READ: abtest +object(foo)#%d (2) { + ["bar"]=> + string(2) "ok" + ["yes"]=> + int(3) +} +array(1) { + [3]=> + object(foo)#%d (2) { + ["bar"]=> + string(2) "ok" + ["yes"]=> + int(3) + } +} +int(123) +WRITE: abtest, baz|O:3:"foo":2:{s:3:"bar";s:2:"ok";s:3:"yes";i:3;}arr|a:1:{i:3;O:3:"foo":2:{s:3:"bar";s:2:"ok";s:3:"yes";i:3;}}c|i:123; +CLOSE +OPEN: PHPSESSID +READ: abtest +object(foo)#%d (2) { + ["bar"]=> + string(2) "ok" + ["yes"]=> + int(3) +} +array(1) { + [3]=> + object(foo)#%d (2) { + ["bar"]=> + string(2) "ok" + ["yes"]=> + int(3) + } +} +int(123) +DESTROY: abtest +CLOSE diff --git a/ext/session/tests/026.phpt b/ext/session/tests/026.phpt new file mode 100644 index 000000000..06c135d04 --- /dev/null +++ b/ext/session/tests/026.phpt @@ -0,0 +1,71 @@ +--TEST-- +correct instantiation of references between variables in sessions +--SKIPIF-- +<?php include('skipif.inc'); ?> +--INI-- +session.use_cookies=0 +session.cache_limiter= +session.serialize_handler=php +session.save_handler=files +--FILE-- +<?php +error_reporting(E_ALL); + +session_id("abtest"); +session_start(); + +class a { + public $test = "hallo"; +} + +class b { + public $a; + function b(&$a) { + $this->a = &$a; + } +} + +$a = new a(); +$b = new b($a); + +echo "original values:\n"; +var_dump($a,$b); + +$_SESSION['a'] = $a; +$_SESSION['b'] = $b; + +session_write_close(); +unset($_SESSION['a']); +unset($_SESSION['b']); + +session_start(); +$a = $_SESSION['a']; +$b = $_SESSION['b']; +echo "values after session:\n"; +var_dump($a,$b); +?> +--EXPECTF-- +original values: +object(a)#%d (1) { + ["test"]=> + string(5) "hallo" +} +object(b)#%d (1) { + ["a"]=> + &object(a)#%d (1) { + ["test"]=> + string(5) "hallo" + } +} +values after session: +object(a)#%d (1) { + ["test"]=> + string(5) "hallo" +} +object(b)#%d (1) { + ["a"]=> + &object(a)#%d (1) { + ["test"]=> + string(5) "hallo" + } +} diff --git a/ext/session/tests/027.phpt b/ext/session/tests/027.phpt new file mode 100644 index 000000000..600a992f7 --- /dev/null +++ b/ext/session/tests/027.phpt @@ -0,0 +1,55 @@ +--TEST-- +unset($_SESSION["name"]); should work +--SKIPIF-- +<?php include('skipif.inc'); ?> +--INI-- +session.use_cookies=0 +session.cache_limiter= +session.serialize_handler=php +session.save_handler=files +--FILE-- +<?php +error_reporting(E_ALL); + +session_id("abtest"); + +### Phase 1 cleanup +session_start(); +session_destroy(); + +### Phase 2 $_SESSION["c"] does not contain any value +session_id("abtest"); +session_start(); +var_dump($_SESSION); +$_SESSION["name"] = "foo"; +var_dump($_SESSION); +session_write_close(); + +### Phase 3 $_SESSION["c"] is set +session_start(); +var_dump($_SESSION); +unset($_SESSION["name"]); +var_dump($_SESSION); +session_write_close(); + +### Phase 4 final + +session_start(); +var_dump($_SESSION); +session_destroy(); +?> +--EXPECT-- +array(0) { +} +array(1) { + ["name"]=> + string(3) "foo" +} +array(1) { + ["name"]=> + string(3) "foo" +} +array(0) { +} +array(0) { +} diff --git a/ext/session/tests/028.phpt b/ext/session/tests/028.phpt new file mode 100644 index 000000000..79638d283 --- /dev/null +++ b/ext/session/tests/028.phpt @@ -0,0 +1,16 @@ +--TEST-- +$session_array = explode(";", session_encode()); should not segfault +--SKIPIF-- +<?php include('skipif.inc'); ?> +--INI-- +session.use_cookies=0 +session.cache_limiter= +--FILE-- +<?php +error_reporting(E_ALL); + +$session_array = explode(";", @session_encode()); +print "I live\n"; +?> +--EXPECT-- +I live diff --git a/ext/session/tests/029.phpt b/ext/session/tests/029.phpt new file mode 100644 index 000000000..ff1adbaec --- /dev/null +++ b/ext/session/tests/029.phpt @@ -0,0 +1,17 @@ +--TEST-- +session_decode(); should not segfault +--SKIPIF-- +<?php include('skipif.inc'); ?> +--INI-- +session.use_cookies=0 +session.cache_limiter= +--FILE-- +<?php +error_reporting(E_ALL); + +@session_decode("garbage data and no session started"); +@session_decode("userid|s:5:\"mazen\";chatRoom|s:1:\"1\";"); +print "I live\n"; +?> +--EXPECT-- +I live diff --git a/ext/session/tests/030.phpt b/ext/session/tests/030.phpt new file mode 100644 index 000000000..8d0f284b1 --- /dev/null +++ b/ext/session/tests/030.phpt @@ -0,0 +1,24 @@ +--TEST-- +redefining SID should not cause warnings +--SKIPIF-- +<?php include('skipif.inc'); ?> +--INI-- +session.use_cookies=0 +session.cache_limiter= +session.serialize_handler=php +session.save_handler=files +--FILE-- +<?php +error_reporting(E_ALL); + +session_id("abtest"); +session_start(); +session_destroy(); +session_id("abtest2"); +session_start(); +session_destroy(); + +print "I live\n"; +?> +--EXPECT-- +I live diff --git a/ext/session/tests/save_handler.inc b/ext/session/tests/save_handler.inc new file mode 100644 index 000000000..ebe9cac56 --- /dev/null +++ b/ext/session/tests/save_handler.inc @@ -0,0 +1,63 @@ +<?php + +DEFINE("SESSION_FILE_PREFIX" ,"session_test_"); +function open($save_path, $session_name) { + global $session_save_path, $name; + $session_save_path = $save_path; + $name = $session_name; + echo "Open [${session_save_path},${session_name}]\n"; + return true; +} + +function close() { + global $session_save_path, $name; + echo "Close [${session_save_path},${name}]\n"; + return true; +} + +function read($id) { + global $session_save_path, $name, $session_id; + $session_id = $id; + echo "Read [${session_save_path},${id}]\n"; + $session_file = "$session_save_path/".SESSION_FILE_PREFIX.$id; + return (string) @file_get_contents($session_file); +} + +function write($id, $session_data) { + global $session_save_path, $name, $session_id; + $session_id = $id; + echo "Write [${session_save_path},${id},${session_data}]\n"; + $session_file = "$session_save_path/".SESSION_FILE_PREFIX.$id; + if ($fp = fopen($session_file, "w")) { + $return = fwrite($fp, $session_data); + fclose($fp); + return $return; + } + return false; +} + +function destroy($id) { + global $session_save_path, $name; + echo "Destroy [${session_save_path},${id}]\n"; + $session_file = "$session_save_path/".SESSION_FILE_PREFIX.$id; + return unlink($session_file); +} + +function gc($maxlifetime) { + global $session_save_path, $name; + $directory = opendir($session_save_path."/"); + $length = strlen(SESSION_FILE_PREFIX); + while (($file = readdir($directory)) !== FALSE) { + $qualified = ($session_save_path."/".$file); + if (is_file($qualified) === TRUE) { + if (substr($file, 0, $length) === SESSION_FILE_PREFIX) { + unlink($qualified); + } + } + } + closedir($directory); + return true; +} + +?> + diff --git a/ext/session/tests/session_cache_expire_basic.phpt b/ext/session/tests/session_cache_expire_basic.phpt new file mode 100644 index 000000000..716648593 --- /dev/null +++ b/ext/session/tests/session_cache_expire_basic.phpt @@ -0,0 +1,39 @@ +--TEST-- +Test session_cache_expire() function : basic functionality +--SKIPIF-- +<?php include('skipif.inc'); ?> +--FILE-- +<?php + +ob_start(); + +/* + * Prototype : int session_cache_expire([int $new_cache_expire]) + * Description : Return current cache expire + * Source code : ext/session/session.c + */ + +echo "*** Testing session_cache_expire() : basic functionality ***\n"; + +var_dump(session_cache_expire()); +var_dump(session_cache_expire(1234567890)); +var_dump(session_cache_expire(180)); +var_dump(session_start()); +var_dump(session_cache_expire()); +var_dump(session_destroy()); +var_dump(session_cache_expire()); + +echo "Done"; +ob_end_flush(); +?> +--EXPECTF-- +*** Testing session_cache_expire() : basic functionality *** +int(180) +int(180) +int(1234567890) +bool(true) +int(180) +bool(true) +int(180) +Done + diff --git a/ext/session/tests/session_cache_expire_error.phpt b/ext/session/tests/session_cache_expire_error.phpt new file mode 100644 index 000000000..486ba787e --- /dev/null +++ b/ext/session/tests/session_cache_expire_error.phpt @@ -0,0 +1,170 @@ +--TEST-- +Test session_cache_expire() function : error functionality +--SKIPIF-- +<?php include('skipif.inc'); ?> +--FILE-- +<?php + +ob_start(); + +/* + * Prototype : int session_cache_expire([int $new_cache_expire]) + * Description : Return current cache expire + * Source code : ext/session/session.c + */ + +echo "*** Testing session_cache_expire() : error functionality ***\n"; + +// Get an unset variable +$unset_var = 10; +unset($unset_var); + +class classA +{ + public function __toString() { + return "Hello World!"; + } +} + +$heredoc = <<<EOT +Hello World! +EOT; + +$fp = fopen(__FILE__, "r"); + +// Unexpected values to be passed as arguments +$inputs = array( + + // Integer data +/*1*/ 0, + 1, + 12345, + -2345, + + // Float data +/*5*/ 10.5, + -10.5, + 12.3456789000e10, + 12.3456789000E-10, + .5, + + // Null data +/*10*/ NULL, + null, + + // Boolean data +/*12*/ true, + false, + TRUE, + FALSE, + + // Empty strings +/*16*/ "", + '', + + // Invalid string data +/*18*/ "Nothing", + 'Nothing', + $heredoc, + + // Object data +/*21*/ new classA(), + + // Undefined data +/*22*/ @$undefined_var, + + // Unset data +/*23*/ @$unset_var, + + // Resource variable +/*24*/ $fp +); + + +$iterator = 1; +foreach($inputs as $input) { + echo "\n-- Iteration $iterator --\n"; + var_dump(session_cache_expire($input)); + $iterator++; +}; + +fclose($fp); +echo "Done"; +ob_end_flush(); +?> +--EXPECTF-- +*** Testing session_cache_expire() : error functionality *** + +-- Iteration 1 -- +int(180) + +-- Iteration 2 -- +int(0) + +-- Iteration 3 -- +int(1) + +-- Iteration 4 -- +int(12345) + +-- Iteration 5 -- +int(-2345) + +-- Iteration 6 -- +int(10) + +-- Iteration 7 -- +int(-10) + +-- Iteration 8 -- +int(%s) + +-- Iteration 9 -- +int(1) + +-- Iteration 10 -- +int(0) + +-- Iteration 11 -- +int(0) + +-- Iteration 12 -- +int(0) + +-- Iteration 13 -- +int(1) + +-- Iteration 14 -- +int(0) + +-- Iteration 15 -- +int(1) + +-- Iteration 16 -- +int(0) + +-- Iteration 17 -- +int(0) + +-- Iteration 18 -- +int(0) + +-- Iteration 19 -- +int(0) + +-- Iteration 20 -- +int(0) + +-- Iteration 21 -- +int(0) + +-- Iteration 22 -- +int(0) + +-- Iteration 23 -- +int(0) + +-- Iteration 24 -- +int(0) +Done + diff --git a/ext/session/tests/session_cache_expire_variation1.phpt b/ext/session/tests/session_cache_expire_variation1.phpt new file mode 100644 index 000000000..9d0ba27fe --- /dev/null +++ b/ext/session/tests/session_cache_expire_variation1.phpt @@ -0,0 +1,41 @@ +--TEST-- +Test session_cache_expire() function : variation +--SKIPIF-- +<?php include('skipif.inc'); ?> +--INI-- +session.cache_expire=360 +--FILE-- +<?php + +ob_start(); + +/* + * Prototype : int session_cache_expire([int $new_cache_expire]) + * Description : Return current cache expire + * Source code : ext/session/session.c + */ + +echo "*** Testing session_cache_expire() : variation ***\n"; + +var_dump(session_cache_expire()); +var_dump(session_cache_expire(1234567890)); +var_dump(session_cache_expire(180)); +var_dump(session_start()); +var_dump(session_cache_expire()); +var_dump(session_destroy()); +var_dump(session_cache_expire()); + +echo "Done"; +ob_end_flush(); +?> +--EXPECTF-- +*** Testing session_cache_expire() : variation *** +int(360) +int(360) +int(1234567890) +bool(true) +int(180) +bool(true) +int(180) +Done + diff --git a/ext/session/tests/session_cache_expire_variation2.phpt b/ext/session/tests/session_cache_expire_variation2.phpt new file mode 100644 index 000000000..f17f4711a --- /dev/null +++ b/ext/session/tests/session_cache_expire_variation2.phpt @@ -0,0 +1,41 @@ +--TEST-- +Test session_cache_expire() function : variation +--SKIPIF-- +<?php include('skipif.inc'); ?> +--FILE-- +<?php + +ob_start(); + +/* + * Prototype : int session_cache_expire([int $new_cache_expire]) + * Description : Return current cache expire + * Source code : ext/session/session.c + */ + +echo "*** Testing session_cache_expire() : variation ***\n"; + +ini_set("session.cache_expire", 360); +var_dump(session_cache_expire()); +var_dump(session_cache_expire(1234567890)); +var_dump(session_cache_expire(180)); +var_dump(session_start()); +var_dump(session_cache_expire()); +var_dump(session_destroy()); +var_dump(session_cache_expire()); + +echo "Done"; +ob_end_flush(); +?> +--EXPECTF-- +*** Testing session_cache_expire() : variation *** +int(360) +int(360) +int(1234567890) +bool(true) +int(180) +bool(true) +int(180) +Done + + diff --git a/ext/session/tests/session_cache_expire_variation3.phpt b/ext/session/tests/session_cache_expire_variation3.phpt new file mode 100644 index 000000000..c243c1f11 --- /dev/null +++ b/ext/session/tests/session_cache_expire_variation3.phpt @@ -0,0 +1,47 @@ +--TEST-- +Test session_cache_expire() function : variation +--SKIPIF-- +<?php include('skipif.inc'); ?> +--FILE-- +<?php + +ob_start(); + +/* + * Prototype : int session_cache_expire([int $new_cache_expire]) + * Description : Return current cache expire + * Source code : ext/session/session.c + */ + +echo "*** Testing session_cache_expire() : variation ***\n"; + +var_dump(ini_get("session.cache_expire")); +var_dump(session_cache_expire()); +var_dump(ini_get("session.cache_expire")); +var_dump(session_cache_expire(1234567890)); +var_dump(ini_get("session.cache_expire")); +var_dump(session_start()); +var_dump(session_cache_expire()); +var_dump(ini_get("session.cache_expire")); +var_dump(session_destroy()); +var_dump(session_cache_expire()); +var_dump(ini_get("session.cache_expire")); + +echo "Done"; +ob_end_flush(); +?> +--EXPECTF-- +*** Testing session_cache_expire() : variation *** +string(3) "180" +int(180) +string(3) "180" +int(180) +string(10) "1234567890" +bool(true) +int(1234567890) +string(10) "1234567890" +bool(true) +int(1234567890) +string(10) "1234567890" +Done + diff --git a/ext/session/tests/session_cache_limiter_basic.phpt b/ext/session/tests/session_cache_limiter_basic.phpt new file mode 100644 index 000000000..d0531878f --- /dev/null +++ b/ext/session/tests/session_cache_limiter_basic.phpt @@ -0,0 +1,68 @@ +--TEST-- +Test session_cache_limiter() function : basic functionality +--SKIPIF-- +<?php include('skipif.inc'); ?> +--FILE-- +<?php + +ob_start(); + +/* + * Prototype : string session_cache_limiter([string $cache_limiter]) + * Description : Get and/or set the current cache limiter + * Source code : ext/session/session.c + */ + +echo "*** Testing session_cache_limiter() : basic functionality ***\n"; + +var_dump(session_start()); +var_dump(session_cache_limiter()); +var_dump(session_cache_limiter("public")); +var_dump(session_cache_limiter()); +var_dump(session_destroy()); + +var_dump(session_start()); +var_dump(session_cache_limiter()); +var_dump(session_cache_limiter("private")); +var_dump(session_cache_limiter()); +var_dump(session_destroy()); + +var_dump(session_start()); +var_dump(session_cache_limiter()); +var_dump(session_cache_limiter("nocache")); +var_dump(session_cache_limiter()); +var_dump(session_destroy()); + +var_dump(session_start()); +var_dump(session_cache_limiter()); +var_dump(session_cache_limiter("private_no_expire")); +var_dump(session_cache_limiter()); +var_dump(session_destroy()); + +echo "Done"; +ob_end_flush(); +?> +--EXPECTF-- +*** Testing session_cache_limiter() : basic functionality *** +bool(true) +string(7) "nocache" +string(7) "nocache" +string(6) "public" +bool(true) +bool(true) +string(6) "public" +string(6) "public" +string(7) "private" +bool(true) +bool(true) +string(7) "private" +string(7) "private" +string(7) "nocache" +bool(true) +bool(true) +string(7) "nocache" +string(7) "nocache" +string(17) "private_no_expire" +bool(true) +Done + diff --git a/ext/session/tests/session_cache_limiter_error.phpt b/ext/session/tests/session_cache_limiter_error.phpt new file mode 100644 index 000000000..98bbbac6d --- /dev/null +++ b/ext/session/tests/session_cache_limiter_error.phpt @@ -0,0 +1,170 @@ +--TEST-- +Test session_cache_limiter() function : error functionality +--SKIPIF-- +<?php include('skipif.inc'); ?> +--FILE-- +<?php + +ob_start(); + +/* + * Prototype : string session_cache_limiter([string $cache_limiter]) + * Description : Get and/or set the current cache limiter + * Source code : ext/session/session.c + */ + +echo "*** Testing session_cache_limiter() : error functionality ***\n"; + +// Get an unset variable +$unset_var = 10; +unset($unset_var); + +class classA +{ + public function __toString() { + return "Hello World!"; + } +} + +$heredoc = <<<EOT +Hello World! +EOT; + +$fp = fopen(__FILE__, "r"); + +// Unexpected values to be passed as arguments +$inputs = array( + + // Integer data +/*1*/ 0, + 1, + 12345, + -2345, + + // Float data +/*5*/ 10.5, + -10.5, + 12.3456789000e10, + 12.3456789000E-10, + .5, + + // Null data +/*10*/ NULL, + null, + + // Boolean data +/*12*/ true, + false, + TRUE, + FALSE, + + // Empty strings +/*16*/ "", + '', + + // Invalid string data +/*18*/ "Nothing", + 'Nothing', + $heredoc, + + // Object data +/*21*/ new classA(), + + // Undefined data +/*22*/ @$undefined_var, + + // Unset data +/*23*/ @$unset_var, + + // Resource variable +/*24*/ $fp +); + + +$iterator = 1; +foreach($inputs as $input) { + echo "\n-- Iteration $iterator --\n"; + var_dump(session_cache_limiter($input)); + $iterator++; +}; + +fclose($fp); +echo "Done"; +ob_end_flush(); +?> +--EXPECTF-- +*** Testing session_cache_limiter() : error functionality *** + +-- Iteration 1 -- +string(7) "nocache" + +-- Iteration 2 -- +string(1) "0" + +-- Iteration 3 -- +string(1) "1" + +-- Iteration 4 -- +string(5) "12345" + +-- Iteration 5 -- +string(5) "-2345" + +-- Iteration 6 -- +string(4) "10.5" + +-- Iteration 7 -- +string(5) "-10.5" + +-- Iteration 8 -- +string(12) "123456789000" + +-- Iteration 9 -- +string(13) "1.23456789E-9" + +-- Iteration 10 -- +string(3) "0.5" + +-- Iteration 11 -- +string(0) "" + +-- Iteration 12 -- +string(0) "" + +-- Iteration 13 -- +string(1) "1" + +-- Iteration 14 -- +string(0) "" + +-- Iteration 15 -- +string(1) "1" + +-- Iteration 16 -- +string(0) "" + +-- Iteration 17 -- +string(0) "" + +-- Iteration 18 -- +string(0) "" + +-- Iteration 19 -- +string(7) "Nothing" + +-- Iteration 20 -- +string(7) "Nothing" + +-- Iteration 21 -- +string(12) "Hello World!" + +-- Iteration 22 -- +string(12) "Hello World!" + +-- Iteration 23 -- +string(0) "" + +-- Iteration 24 -- +string(0) "" +Done + diff --git a/ext/session/tests/session_cache_limiter_variation1.phpt b/ext/session/tests/session_cache_limiter_variation1.phpt new file mode 100644 index 000000000..7c6e71eb8 --- /dev/null +++ b/ext/session/tests/session_cache_limiter_variation1.phpt @@ -0,0 +1,41 @@ +--TEST-- +Test session_cache_limiter() function : variation +--SKIPIF-- +<?php include('skipif.inc'); ?> +--INI-- +session.cache_limiter=nocache +--FILE-- +<?php + +ob_start(); + +/* + * Prototype : string session_cache_limiter([string $cache_limiter]) + * Description : Get and/or set the current cache limiter + * Source code : ext/session/session.c + */ + +echo "*** Testing session_cache_limiter() : variation ***\n"; + +var_dump(session_cache_limiter()); +var_dump(session_start()); +var_dump(session_cache_limiter()); +var_dump(session_cache_limiter("public")); +var_dump(session_cache_limiter()); +var_dump(session_destroy()); +var_dump(session_cache_limiter()); + +echo "Done"; +ob_end_flush(); +?> +--EXPECTF-- +*** Testing session_cache_limiter() : variation *** +string(7) "nocache" +bool(true) +string(7) "nocache" +string(7) "nocache" +string(6) "public" +bool(true) +string(6) "public" +Done + diff --git a/ext/session/tests/session_cache_limiter_variation2.phpt b/ext/session/tests/session_cache_limiter_variation2.phpt new file mode 100644 index 000000000..b6d97a3dd --- /dev/null +++ b/ext/session/tests/session_cache_limiter_variation2.phpt @@ -0,0 +1,40 @@ +--TEST-- +Test session_cache_limiter() function : variation +--SKIPIF-- +<?php include('skipif.inc'); ?> +--FILE-- +<?php + +ob_start(); + +/* + * Prototype : string session_cache_limiter([string $cache_limiter]) + * Description : Get and/or set the current cache limiter + * Source code : ext/session/session.c + */ + +echo "*** Testing session_cache_limiter() : variation ***\n"; + +ini_set("session.cache_limiter", "nocache"); +var_dump(session_cache_limiter()); +var_dump(session_start()); +var_dump(session_cache_limiter()); +var_dump(session_cache_limiter("public")); +var_dump(session_cache_limiter()); +var_dump(session_destroy()); +var_dump(session_cache_limiter()); + +echo "Done"; +ob_end_flush(); +?> +--EXPECTF-- +*** Testing session_cache_limiter() : variation *** +string(7) "nocache" +bool(true) +string(7) "nocache" +string(7) "nocache" +string(6) "public" +bool(true) +string(6) "public" +Done + diff --git a/ext/session/tests/session_cache_limiter_variation3.phpt b/ext/session/tests/session_cache_limiter_variation3.phpt new file mode 100644 index 000000000..7aab95b24 --- /dev/null +++ b/ext/session/tests/session_cache_limiter_variation3.phpt @@ -0,0 +1,39 @@ +--TEST-- +Test session_cache_limiter() function : variation +--SKIPIF-- +<?php include('skipif.inc'); ?> +--FILE-- +<?php + +ob_start(); + +/* + * Prototype : string session_cache_limiter([string $cache_limiter]) + * Description : Get and/or set the current cache limiter + * Source code : ext/session/session.c + */ + +echo "*** Testing session_cache_limiter() : variation ***\n"; + +var_dump(ini_get("session.cache_limiter")); +var_dump(session_start()); +var_dump(ini_get("session.cache_limiter")); +var_dump(session_cache_limiter("public")); +var_dump(ini_get("session.cache_limiter")); +var_dump(session_destroy()); +var_dump(ini_get("session.cache_limiter")); + +echo "Done"; +ob_end_flush(); +?> +--EXPECTF-- +*** Testing session_cache_limiter() : variation *** +string(7) "nocache" +bool(true) +string(7) "nocache" +string(7) "nocache" +string(6) "public" +bool(true) +string(6) "public" +Done + diff --git a/ext/session/tests/session_commit_basic.phpt b/ext/session/tests/session_commit_basic.phpt new file mode 100644 index 000000000..c20db1093 --- /dev/null +++ b/ext/session/tests/session_commit_basic.phpt @@ -0,0 +1,45 @@ +--TEST-- +Test session_commit() function : basic functionality +--SKIPIF-- +<?php include('skipif.inc'); ?> +--FILE-- +<?php + +ob_start(); + +/* + * Prototype : bool session_commit(void) + * Description : Write session data and end session + * Source code : ext/session/session.c + */ + +echo "*** Testing session_commit() : basic functionality ***\n"; + +var_dump(session_start()); +var_dump($_SESSION); +var_dump(session_commit()); +var_dump($_SESSION); +var_dump(session_start()); +var_dump($_SESSION); +var_dump(session_destroy()); +var_dump($_SESSION); + +echo "Done"; +ob_end_flush(); +?> +--EXPECTF-- +*** Testing session_commit() : basic functionality *** +bool(true) +array(0) { +} +NULL +array(0) { +} +bool(true) +array(0) { +} +bool(true) +array(0) { +} +Done + diff --git a/ext/session/tests/session_commit_error.phpt b/ext/session/tests/session_commit_error.phpt new file mode 100644 index 000000000..b867572eb --- /dev/null +++ b/ext/session/tests/session_commit_error.phpt @@ -0,0 +1,170 @@ +--TEST-- +Test session_commit() function : error functionality +--SKIPIF-- +<?php include('skipif.inc'); ?> +--FILE-- +<?php + +ob_start(); + +/* + * Prototype : bool session_commit(void) + * Description : Write session data and end session + * Source code : ext/session/session.c + */ + +echo "*** Testing session_commit() : error functionality ***\n"; + +// Get an unset variable +$unset_var = 10; +unset($unset_var); + +class classA +{ + public function __toString() { + return "Hello World!"; + } +} + +$heredoc = <<<EOT +Hello World! +EOT; + +$fp = fopen(__FILE__, "r"); + +// Unexpected values to be passed as arguments +$inputs = array( + + // Integer data +/*1*/ 0, + 1, + 12345, + -2345, + + // Float data +/*5*/ 10.5, + -10.5, + 12.3456789000e10, + 12.3456789000E-10, + .5, + + // Null data +/*10*/ NULL, + null, + + // Boolean data +/*12*/ true, + false, + TRUE, + FALSE, + + // Empty strings +/*16*/ "", + '', + + // Invalid string data +/*18*/ "Nothing", + 'Nothing', + $heredoc, + + // Object data +/*21*/ new classA(), + + // Undefined data +/*22*/ @$undefined_var, + + // Unset data +/*23*/ @$unset_var, + + // Resource variable +/*24*/ $fp +); + + +$iterator = 1; +foreach($inputs as $input) { + echo "\n-- Iteration $iterator --\n"; + var_dump(session_commit($input)); + $iterator++; +}; + +fclose($fp); +echo "Done"; +ob_end_flush(); +?> +--EXPECTF-- +*** Testing session_commit() : error functionality *** + +-- Iteration 1 -- +NULL + +-- Iteration 2 -- +NULL + +-- Iteration 3 -- +NULL + +-- Iteration 4 -- +NULL + +-- Iteration 5 -- +NULL + +-- Iteration 6 -- +NULL + +-- Iteration 7 -- +NULL + +-- Iteration 8 -- +NULL + +-- Iteration 9 -- +NULL + +-- Iteration 10 -- +NULL + +-- Iteration 11 -- +NULL + +-- Iteration 12 -- +NULL + +-- Iteration 13 -- +NULL + +-- Iteration 14 -- +NULL + +-- Iteration 15 -- +NULL + +-- Iteration 16 -- +NULL + +-- Iteration 17 -- +NULL + +-- Iteration 18 -- +NULL + +-- Iteration 19 -- +NULL + +-- Iteration 20 -- +NULL + +-- Iteration 21 -- +NULL + +-- Iteration 22 -- +NULL + +-- Iteration 23 -- +NULL + +-- Iteration 24 -- +NULL +Done + diff --git a/ext/session/tests/session_commit_variation1.phpt b/ext/session/tests/session_commit_variation1.phpt new file mode 100644 index 000000000..81240dac8 --- /dev/null +++ b/ext/session/tests/session_commit_variation1.phpt @@ -0,0 +1,41 @@ +--TEST-- +Test session_commit() function : variation +--SKIPIF-- +<?php include('skipif.inc'); ?> +--FILE-- +<?php + +ob_start(); + +/* + * Prototype : bool session_commit(void) + * Description : Write session data and end session + * Source code : ext/session/session.c + */ + +echo "*** Testing session_commit() : variation ***\n"; + +var_dump(session_start()); +var_dump(session_commit()); +var_dump(session_commit()); +var_dump(session_commit()); +var_dump(session_commit()); +var_dump(session_commit()); +var_dump(session_start()); +var_dump(session_destroy()); + +echo "Done"; +ob_end_flush(); +?> +--EXPECTF-- +*** Testing session_commit() : variation *** +bool(true) +NULL +NULL +NULL +NULL +NULL +bool(true) +bool(true) +Done + diff --git a/ext/session/tests/session_commit_variation2.phpt b/ext/session/tests/session_commit_variation2.phpt new file mode 100644 index 000000000..b38885a8d --- /dev/null +++ b/ext/session/tests/session_commit_variation2.phpt @@ -0,0 +1,59 @@ +--TEST-- +Test session_commit() function : variation +--SKIPIF-- +<?php include('skipif.inc'); ?> +--FILE-- +<?php + +ob_start(); + +/* + * Prototype : bool session_commit(void) + * Description : Write session data and end session + * Source code : ext/session/session.c + */ + +echo "*** Testing session_commit() : variation ***\n"; + +var_dump(session_start()); +var_dump($_SESSION); +var_dump(session_commit()); +var_dump($_SESSION); +var_dump(session_start()); +var_dump($_SESSION); +var_dump(session_commit()); +var_dump($_SESSION); +var_dump(session_start()); +var_dump($_SESSION); +var_dump(session_commit()); +var_dump($_SESSION); +var_dump(session_start()); +var_dump(session_destroy()); + +echo "Done"; +ob_end_flush(); +?> +--EXPECTF-- +*** Testing session_commit() : variation *** +bool(true) +array(0) { +} +NULL +array(0) { +} +bool(true) +array(0) { +} +NULL +array(0) { +} +bool(true) +array(0) { +} +NULL +array(0) { +} +bool(true) +bool(true) +Done + diff --git a/ext/session/tests/session_commit_variation3.phpt b/ext/session/tests/session_commit_variation3.phpt new file mode 100644 index 000000000..4cee2f4d5 --- /dev/null +++ b/ext/session/tests/session_commit_variation3.phpt @@ -0,0 +1,39 @@ +--TEST-- +Test session_start() function : variation +--SKIPIF-- +<?php include('skipif.inc'); ?> +--INI-- +session.auto_start=1 +--FILE-- +<?php + +ob_start(); + +/* + * Prototype : bool session_commit(void) + * Description : Write session data and end session + * Source code : ext/session/session.c + */ + +echo "*** Testing session_commit() : variation ***\n"; + +var_dump($_SESSION); +var_dump(session_commit()); +var_dump($_SESSION); +var_dump(session_start()); +var_dump(session_destroy()); + +echo "Done"; +ob_end_flush(); +?> +--EXPECTF-- +*** Testing session_commit() : variation *** +array(0) { +} +NULL +array(0) { +} +bool(true) +bool(true) +Done + diff --git a/ext/session/tests/session_commit_variation4.phpt b/ext/session/tests/session_commit_variation4.phpt new file mode 100644 index 000000000..57f42539d --- /dev/null +++ b/ext/session/tests/session_commit_variation4.phpt @@ -0,0 +1,55 @@ +--TEST-- +Test session_commit() function : variation +--SKIPIF-- +<?php include('skipif.inc'); ?> +--FILE-- +<?php + +ob_start(); + +/* + * Prototype : bool session_commit(void) + * Description : Write session data and end session + * Source code : ext/session/session.c + */ + +echo "*** Testing session_commit() : variation ***\n"; + +var_dump(session_id("test")); +var_dump(session_start()); +var_dump(session_id()); +var_dump(session_commit()); +var_dump(session_id()); +var_dump(session_start()); +var_dump(session_id()); +var_dump(session_commit()); +var_dump(session_id()); +var_dump(session_start()); +var_dump(session_id()); +var_dump(session_commit()); +var_dump(session_id()); +var_dump(session_start()); +var_dump(session_destroy()); + +echo "Done"; +ob_end_flush(); +?> +--EXPECTF-- +*** Testing session_commit() : variation *** +string(0) "" +bool(true) +string(4) "test" +NULL +string(4) "test" +bool(true) +string(4) "test" +NULL +string(4) "test" +bool(true) +string(4) "test" +NULL +string(4) "test" +bool(true) +bool(true) +Done + diff --git a/ext/session/tests/session_decode_basic.phpt b/ext/session/tests/session_decode_basic.phpt new file mode 100644 index 000000000..f8aa24305 --- /dev/null +++ b/ext/session/tests/session_decode_basic.phpt @@ -0,0 +1,273 @@ +--TEST-- +Test session_decode() function : basic functionality +--SKIPIF-- +<?php include('skipif.inc'); ?> +--FILE-- +<?php + +ob_start(); + +/* + * Prototype : string session_decode(void) + * Description : Decodes session data from a string + * Source code : ext/session/session.c + */ + +echo "*** Testing session_decode() : basic functionality ***\n"; + +// Get an unset variable +$unset_var = 10; +unset($unset_var); + +class classA +{ + public function __toString() { + return "Hello World!"; + } +} + +$heredoc = <<<EOT +Hello World! +EOT; + +$fp = fopen(__FILE__, "r"); + +// Unexpected values to be passed as arguments +$inputs = array( + + // Integer data +/*1*/ 0, + 1, + 12345, + -2345, + + // Float data +/*5*/ 10.5, + -10.5, + 12.3456789000e10, + 12.3456789000E-10, + .5, + + // Null data +/*10*/ NULL, + null, + + // Boolean data +/*12*/ true, + false, + TRUE, + FALSE, + + // Empty strings +/*16*/ "", + '', + + // Invalid string data +/*18*/ "Nothing", + 'Nothing', + $heredoc, + + // Object data +/*21*/ new classA(), + + // Undefined data +/*22*/ @$undefined_var, + + // Unset data +/*23*/ @$unset_var, + + // Resource variable +/*24*/ $fp +); + +var_dump(session_start()); +$iterator = 1; +foreach($inputs as $input) { + echo "\n-- Iteration $iterator --\n"; + $_SESSION["data"] = $input; + $encoded = session_encode(); + var_dump(session_decode($encoded)); + var_dump($_SESSION); + $iterator++; +}; + +var_dump(session_destroy()); +fclose($fp); +echo "Done"; +ob_end_flush(); +?> +--EXPECTF-- +*** Testing session_decode() : basic functionality *** +bool(true) + +-- Iteration 1 -- +bool(true) +array(1) { + ["data"]=> + int(0) +} + +-- Iteration 2 -- +bool(true) +array(1) { + ["data"]=> + int(1) +} + +-- Iteration 3 -- +bool(true) +array(1) { + ["data"]=> + int(12345) +} + +-- Iteration 4 -- +bool(true) +array(1) { + ["data"]=> + int(-2345) +} + +-- Iteration 5 -- +bool(true) +array(1) { + ["data"]=> + float(10.5) +} + +-- Iteration 6 -- +bool(true) +array(1) { + ["data"]=> + float(-10.5) +} + +-- Iteration 7 -- +bool(true) +array(1) { + ["data"]=> + float(123456789000) +} + +-- Iteration 8 -- +bool(true) +array(1) { + ["data"]=> + float(1.23456789E-9) +} + +-- Iteration 9 -- +bool(true) +array(1) { + ["data"]=> + float(0.5) +} + +-- Iteration 10 -- +bool(true) +array(1) { + ["data"]=> + NULL +} + +-- Iteration 11 -- +bool(true) +array(1) { + ["data"]=> + NULL +} + +-- Iteration 12 -- +bool(true) +array(1) { + ["data"]=> + bool(true) +} + +-- Iteration 13 -- +bool(true) +array(1) { + ["data"]=> + bool(false) +} + +-- Iteration 14 -- +bool(true) +array(1) { + ["data"]=> + bool(true) +} + +-- Iteration 15 -- +bool(true) +array(1) { + ["data"]=> + bool(false) +} + +-- Iteration 16 -- +bool(true) +array(1) { + ["data"]=> + string(0) "" +} + +-- Iteration 17 -- +bool(true) +array(1) { + ["data"]=> + string(0) "" +} + +-- Iteration 18 -- +bool(true) +array(1) { + ["data"]=> + string(7) "Nothing" +} + +-- Iteration 19 -- +bool(true) +array(1) { + ["data"]=> + string(7) "Nothing" +} + +-- Iteration 20 -- +bool(true) +array(1) { + ["data"]=> + string(12) "Hello World!" +} + +-- Iteration 21 -- +bool(true) +array(1) { + ["data"]=> + object(classA)#2 (0) { + } +} + +-- Iteration 22 -- +bool(true) +array(1) { + ["data"]=> + NULL +} + +-- Iteration 23 -- +bool(true) +array(1) { + ["data"]=> + NULL +} + +-- Iteration 24 -- +bool(true) +array(1) { + ["data"]=> + int(0) +} +bool(true) +Done + diff --git a/ext/session/tests/session_decode_error.phpt b/ext/session/tests/session_decode_error.phpt new file mode 100644 index 000000000..416d74116 --- /dev/null +++ b/ext/session/tests/session_decode_error.phpt @@ -0,0 +1,222 @@ +--TEST-- +Test session_decode() function : error functionality +--SKIPIF-- +<?php include('skipif.inc'); ?> +--FILE-- +<?php + +ob_start(); + +/* + * Prototype : string session_decode(void) + * Description : Decodes session data from a string + * Source code : ext/session/session.c + */ + +echo "*** Testing session_decode() : error functionality ***\n"; + +// Get an unset variable +$unset_var = 10; +unset($unset_var); + +class classA +{ + public function __toString() { + return "Hello World!"; + } +} + +$heredoc = <<<EOT +Hello World! +EOT; + +$fp = fopen(__FILE__, "r"); + +// Unexpected values to be passed as arguments +$inputs = array( + + // Integer data +/*1*/ 0, + 1, + 12345, + -2345, + + // Float data +/*5*/ 10.5, + -10.5, + 12.3456789000e10, + 12.3456789000E-10, + .5, + + // Null data +/*10*/ NULL, + null, + + // Boolean data +/*12*/ true, + false, + TRUE, + FALSE, + + // Empty strings +/*16*/ "", + '', + + // Invalid string data +/*18*/ "Nothing", + 'Nothing', + $heredoc, + + // Object data +/*21*/ new classA(), + + // Undefined data +/*22*/ @$undefined_var, + + // Unset data +/*23*/ @$unset_var, + + // Resource variable +/*24*/ $fp +); + +var_dump(session_start()); +$iterator = 1; +foreach($inputs as $input) { + echo "\n-- Iteration $iterator --\n"; + var_dump(session_decode($input)); + var_dump($_SESSION); + $iterator++; +}; + +var_dump(session_destroy()); +fclose($fp); +echo "Done"; +ob_end_flush(); +?> +--EXPECTF-- +*** Testing session_decode() : error functionality *** +bool(true) + +-- Iteration 1 -- +bool(true) +array(0) { +} + +-- Iteration 2 -- +bool(true) +array(0) { +} + +-- Iteration 3 -- +bool(true) +array(0) { +} + +-- Iteration 4 -- +bool(true) +array(0) { +} + +-- Iteration 5 -- +bool(true) +array(0) { +} + +-- Iteration 6 -- +bool(true) +array(0) { +} + +-- Iteration 7 -- +bool(true) +array(0) { +} + +-- Iteration 8 -- +bool(true) +array(0) { +} + +-- Iteration 9 -- +bool(true) +array(0) { +} + +-- Iteration 10 -- +bool(true) +array(0) { +} + +-- Iteration 11 -- +bool(true) +array(0) { +} + +-- Iteration 12 -- +bool(true) +array(0) { +} + +-- Iteration 13 -- +bool(true) +array(0) { +} + +-- Iteration 14 -- +bool(true) +array(0) { +} + +-- Iteration 15 -- +bool(true) +array(0) { +} + +-- Iteration 16 -- +bool(true) +array(0) { +} + +-- Iteration 17 -- +bool(true) +array(0) { +} + +-- Iteration 18 -- +bool(true) +array(0) { +} + +-- Iteration 19 -- +bool(true) +array(0) { +} + +-- Iteration 20 -- +bool(true) +array(0) { +} + +-- Iteration 21 -- +bool(true) +array(0) { +} + +-- Iteration 22 -- +bool(true) +array(0) { +} + +-- Iteration 23 -- +bool(true) +array(0) { +} + +-- Iteration 24 -- +bool(true) +array(0) { +} +bool(true) +Done + diff --git a/ext/session/tests/session_decode_error2.phpt b/ext/session/tests/session_decode_error2.phpt new file mode 100644 index 000000000..4160f8785 --- /dev/null +++ b/ext/session/tests/session_decode_error2.phpt @@ -0,0 +1,615 @@ +--TEST-- +Test session_decode() function : error functionality +--SKIPIF-- +<?php include('skipif.inc'); ?> +--FILE-- +<?php + +ob_start(); + +/* + * Prototype : string session_decode(void) + * Description : Decodes session data from a string + * Source code : ext/session/session.c + */ + +echo "*** Testing session_decode() : error functionality ***\n"; +$data = "foo|a:3:{i:0;i:1;i:1;i:2;i:2;i:3;}guff|R:1;blah|R:1;"; + +var_dump(session_start()); +for($index = 0; $index < strlen($data); $index++) { + echo "\n-- Iteration $index --\n"; + $encoded = substr($data, 0, $index); + var_dump(session_decode($encoded)); + var_dump($_SESSION); +}; + +var_dump(session_destroy()); +echo "Done"; +ob_end_flush(); +?> +--EXPECTF-- +*** Testing session_decode() : error functionality *** +bool(true) + +-- Iteration 0 -- +bool(true) +array(0) { +} + +-- Iteration 1 -- +bool(true) +array(0) { +} + +-- Iteration 2 -- +bool(true) +array(0) { +} + +-- Iteration 3 -- +bool(true) +array(0) { +} + +-- Iteration 4 -- +bool(true) +array(1) { + ["foo"]=> + NULL +} + +-- Iteration 5 -- +bool(true) +array(1) { + ["foo"]=> + NULL +} + +-- Iteration 6 -- +bool(true) +array(1) { + ["foo"]=> + NULL +} + +-- Iteration 7 -- +bool(true) +array(1) { + ["foo"]=> + NULL +} + +-- Iteration 8 -- +bool(true) +array(1) { + ["foo"]=> + NULL +} + +-- Iteration 9 -- +bool(true) +array(1) { + ["foo"]=> + NULL +} + +-- Iteration 10 -- +bool(true) +array(1) { + ["foo"]=> + NULL +} + +-- Iteration 11 -- +bool(true) +array(1) { + ["foo"]=> + NULL +} + +-- Iteration 12 -- +bool(true) +array(1) { + ["foo"]=> + NULL +} + +-- Iteration 13 -- +bool(true) +array(1) { + ["foo"]=> + NULL +} + +-- Iteration 14 -- +bool(true) +array(1) { + ["foo"]=> + NULL +} + +-- Iteration 15 -- +bool(true) +array(1) { + ["foo"]=> + NULL +} + +-- Iteration 16 -- +bool(true) +array(1) { + ["foo"]=> + NULL +} + +-- Iteration 17 -- +bool(true) +array(1) { + ["foo"]=> + NULL +} + +-- Iteration 18 -- +bool(true) +array(1) { + ["foo"]=> + NULL +} + +-- Iteration 19 -- +bool(true) +array(1) { + ["foo"]=> + NULL +} + +-- Iteration 20 -- +bool(true) +array(1) { + ["foo"]=> + NULL +} + +-- Iteration 21 -- +bool(true) +array(1) { + ["foo"]=> + NULL +} + +-- Iteration 22 -- +bool(true) +array(1) { + ["foo"]=> + NULL +} + +-- Iteration 23 -- +bool(true) +array(1) { + ["foo"]=> + NULL +} + +-- Iteration 24 -- +bool(true) +array(1) { + ["foo"]=> + NULL +} + +-- Iteration 25 -- +bool(true) +array(1) { + ["foo"]=> + NULL +} + +-- Iteration 26 -- +bool(true) +array(1) { + ["foo"]=> + NULL +} + +-- Iteration 27 -- +bool(true) +array(1) { + ["foo"]=> + NULL +} + +-- Iteration 28 -- +bool(true) +array(1) { + ["foo"]=> + NULL +} + +-- Iteration 29 -- +bool(true) +array(1) { + ["foo"]=> + NULL +} + +-- Iteration 30 -- +bool(true) +array(1) { + ["foo"]=> + NULL +} + +-- Iteration 31 -- +bool(true) +array(1) { + ["foo"]=> + NULL +} + +-- Iteration 32 -- +bool(true) +array(1) { + ["foo"]=> + NULL +} + +-- Iteration 33 -- +bool(true) +array(1) { + ["foo"]=> + NULL +} + +-- Iteration 34 -- +bool(true) +array(1) { + ["foo"]=> + array(3) { + [0]=> + int(1) + [1]=> + int(2) + [2]=> + int(3) + } +} + +-- Iteration 35 -- +bool(true) +array(1) { + ["foo"]=> + array(3) { + [0]=> + int(1) + [1]=> + int(2) + [2]=> + int(3) + } +} + +-- Iteration 36 -- +bool(true) +array(1) { + ["foo"]=> + array(3) { + [0]=> + int(1) + [1]=> + int(2) + [2]=> + int(3) + } +} + +-- Iteration 37 -- +bool(true) +array(1) { + ["foo"]=> + array(3) { + [0]=> + int(1) + [1]=> + int(2) + [2]=> + int(3) + } +} + +-- Iteration 38 -- +bool(true) +array(1) { + ["foo"]=> + array(3) { + [0]=> + int(1) + [1]=> + int(2) + [2]=> + int(3) + } +} + +-- Iteration 39 -- +bool(true) +array(2) { + ["foo"]=> + array(3) { + [0]=> + int(1) + [1]=> + int(2) + [2]=> + int(3) + } + ["guff"]=> + NULL +} + +-- Iteration 40 -- +bool(true) +array(2) { + ["foo"]=> + array(3) { + [0]=> + int(1) + [1]=> + int(2) + [2]=> + int(3) + } + ["guff"]=> + NULL +} + +-- Iteration 41 -- +bool(true) +array(2) { + ["foo"]=> + array(3) { + [0]=> + int(1) + [1]=> + int(2) + [2]=> + int(3) + } + ["guff"]=> + NULL +} + +-- Iteration 42 -- +bool(true) +array(2) { + ["foo"]=> + array(3) { + [0]=> + int(1) + [1]=> + int(2) + [2]=> + int(3) + } + ["guff"]=> + NULL +} + +-- Iteration 43 -- +bool(true) +array(2) { + ["foo"]=> + &array(3) { + [0]=> + int(1) + [1]=> + int(2) + [2]=> + int(3) + } + ["guff"]=> + &array(3) { + [0]=> + int(1) + [1]=> + int(2) + [2]=> + int(3) + } +} + +-- Iteration 44 -- +bool(true) +array(2) { + ["foo"]=> + &array(3) { + [0]=> + int(1) + [1]=> + int(2) + [2]=> + int(3) + } + ["guff"]=> + &array(3) { + [0]=> + int(1) + [1]=> + int(2) + [2]=> + int(3) + } +} + +-- Iteration 45 -- +bool(true) +array(2) { + ["foo"]=> + &array(3) { + [0]=> + int(1) + [1]=> + int(2) + [2]=> + int(3) + } + ["guff"]=> + &array(3) { + [0]=> + int(1) + [1]=> + int(2) + [2]=> + int(3) + } +} + +-- Iteration 46 -- +bool(true) +array(2) { + ["foo"]=> + &array(3) { + [0]=> + int(1) + [1]=> + int(2) + [2]=> + int(3) + } + ["guff"]=> + &array(3) { + [0]=> + int(1) + [1]=> + int(2) + [2]=> + int(3) + } +} + +-- Iteration 47 -- +bool(true) +array(2) { + ["foo"]=> + &array(3) { + [0]=> + int(1) + [1]=> + int(2) + [2]=> + int(3) + } + ["guff"]=> + &array(3) { + [0]=> + int(1) + [1]=> + int(2) + [2]=> + int(3) + } +} + +-- Iteration 48 -- +bool(true) +array(3) { + ["foo"]=> + &array(3) { + [0]=> + int(1) + [1]=> + int(2) + [2]=> + int(3) + } + ["guff"]=> + &array(3) { + [0]=> + int(1) + [1]=> + int(2) + [2]=> + int(3) + } + ["blah"]=> + NULL +} + +-- Iteration 49 -- +bool(true) +array(3) { + ["foo"]=> + &array(3) { + [0]=> + int(1) + [1]=> + int(2) + [2]=> + int(3) + } + ["guff"]=> + &array(3) { + [0]=> + int(1) + [1]=> + int(2) + [2]=> + int(3) + } + ["blah"]=> + NULL +} + +-- Iteration 50 -- +bool(true) +array(3) { + ["foo"]=> + &array(3) { + [0]=> + int(1) + [1]=> + int(2) + [2]=> + int(3) + } + ["guff"]=> + &array(3) { + [0]=> + int(1) + [1]=> + int(2) + [2]=> + int(3) + } + ["blah"]=> + NULL +} + +-- Iteration 51 -- +bool(true) +array(3) { + ["foo"]=> + &array(3) { + [0]=> + int(1) + [1]=> + int(2) + [2]=> + int(3) + } + ["guff"]=> + &array(3) { + [0]=> + int(1) + [1]=> + int(2) + [2]=> + int(3) + } + ["blah"]=> + NULL +} +bool(true) +Done + diff --git a/ext/session/tests/session_decode_variation1.phpt b/ext/session/tests/session_decode_variation1.phpt new file mode 100644 index 000000000..b2d06b1ab --- /dev/null +++ b/ext/session/tests/session_decode_variation1.phpt @@ -0,0 +1,189 @@ +--TEST-- +Test session_decode() function : variation +--SKIPIF-- +<?php include('skipif.inc'); ?> +--FILE-- +<?php + +ob_start(); + +/* + * Prototype : string session_decode(void) + * Description : Decodes session data from a string + * Source code : ext/session/session.c + */ + +echo "*** Testing session_decode() : variation ***\n"; + +var_dump(session_start()); +var_dump(session_decode("foo|a:3:{i:0;i:1;i:1;i:2;i:2;i:3;}guff|R:1;blah|R:1;")); +var_dump($_SESSION); +var_dump(session_decode("foo|a:3:{i:0;i:1;i:1;i:2;i:2;i:3;}guff|R:1;blah|R:1;")); +var_dump($_SESSION); +var_dump(session_decode("foo|a:3:{i:0;i:1;i:1;i:2;i:2;i:3;}guff|R:1;blah|R:1;")); +var_dump($_SESSION); +var_dump(session_decode("foo|a:3:{i:0;i:1;i:1;i:2;i:2;i:3;}guff|R:1;blah|R:1;")); +var_dump($_SESSION); +var_dump(session_decode("foo|a:3:{i:0;i:1;i:1;i:2;i:2;i:3;}guff|R:1;blah|R:1;")); +var_dump($_SESSION); +var_dump(session_destroy()); + +echo "Done"; +ob_end_flush(); +?> +--EXPECTF-- +*** Testing session_decode() : variation *** +bool(true) +bool(true) +array(3) { + ["foo"]=> + &array(3) { + [0]=> + int(1) + [1]=> + int(2) + [2]=> + int(3) + } + ["guff"]=> + &array(3) { + [0]=> + int(1) + [1]=> + int(2) + [2]=> + int(3) + } + ["blah"]=> + &array(3) { + [0]=> + int(1) + [1]=> + int(2) + [2]=> + int(3) + } +} +bool(true) +array(3) { + ["foo"]=> + &array(3) { + [0]=> + int(1) + [1]=> + int(2) + [2]=> + int(3) + } + ["guff"]=> + &array(3) { + [0]=> + int(1) + [1]=> + int(2) + [2]=> + int(3) + } + ["blah"]=> + &array(3) { + [0]=> + int(1) + [1]=> + int(2) + [2]=> + int(3) + } +} +bool(true) +array(3) { + ["foo"]=> + &array(3) { + [0]=> + int(1) + [1]=> + int(2) + [2]=> + int(3) + } + ["guff"]=> + &array(3) { + [0]=> + int(1) + [1]=> + int(2) + [2]=> + int(3) + } + ["blah"]=> + &array(3) { + [0]=> + int(1) + [1]=> + int(2) + [2]=> + int(3) + } +} +bool(true) +array(3) { + ["foo"]=> + &array(3) { + [0]=> + int(1) + [1]=> + int(2) + [2]=> + int(3) + } + ["guff"]=> + &array(3) { + [0]=> + int(1) + [1]=> + int(2) + [2]=> + int(3) + } + ["blah"]=> + &array(3) { + [0]=> + int(1) + [1]=> + int(2) + [2]=> + int(3) + } +} +bool(true) +array(3) { + ["foo"]=> + &array(3) { + [0]=> + int(1) + [1]=> + int(2) + [2]=> + int(3) + } + ["guff"]=> + &array(3) { + [0]=> + int(1) + [1]=> + int(2) + [2]=> + int(3) + } + ["blah"]=> + &array(3) { + [0]=> + int(1) + [1]=> + int(2) + [2]=> + int(3) + } +} +bool(true) +Done + diff --git a/ext/session/tests/session_decode_variation2.phpt b/ext/session/tests/session_decode_variation2.phpt new file mode 100644 index 000000000..1a9b68790 --- /dev/null +++ b/ext/session/tests/session_decode_variation2.phpt @@ -0,0 +1,78 @@ +--TEST-- +Test session_decode() function : basic functionality +--SKIPIF-- +<?php include('skipif.inc'); ?> +--FILE-- +<?php + +ob_start(); + +/* + * Prototype : string session_decode(void) + * Description : Decodes session data from a string + * Source code : ext/session/session.c + */ + +echo "*** Testing session_decode() : variation ***\n"; + +var_dump(session_start()); +var_dump($_SESSION); +$_SESSION["foo"] = 1234567890; +$_SESSION["bar"] = "Hello World!"; +$_SESSION["guff"] = 123.456; +var_dump($_SESSION); +var_dump(session_decode("foo|a:3:{i:0;i:1;i:1;i:2;i:2;i:3;}guff|R:1;blah|R:1;")); +var_dump($_SESSION); +var_dump(session_destroy()); + +echo "Done"; +ob_end_flush(); +?> +--EXPECTF-- +*** Testing session_decode() : variation *** +bool(true) +array(0) { +} +array(3) { + ["foo"]=> + int(1234567890) + ["bar"]=> + string(12) "Hello World!" + ["guff"]=> + float(123.456) +} +bool(true) +array(4) { + ["foo"]=> + &array(3) { + [0]=> + int(1) + [1]=> + int(2) + [2]=> + int(3) + } + ["bar"]=> + string(12) "Hello World!" + ["guff"]=> + &array(3) { + [0]=> + int(1) + [1]=> + int(2) + [2]=> + int(3) + } + ["blah"]=> + &array(3) { + [0]=> + int(1) + [1]=> + int(2) + [2]=> + int(3) + } +} +bool(true) +Done + diff --git a/ext/session/tests/session_decode_variation3.phpt b/ext/session/tests/session_decode_variation3.phpt new file mode 100644 index 000000000..b7e13cc40 --- /dev/null +++ b/ext/session/tests/session_decode_variation3.phpt @@ -0,0 +1,62 @@ +--TEST-- +Test session_decode() function : variation +--SKIPIF-- +<?php include('skipif.inc'); ?> +--INI-- +session.serialize_handler=blah +--FILE-- +<?php + +ob_start(); + +/* + * Prototype : string session_decode(void) + * Description : Decodes session data from a string + * Source code : ext/session/session.c + */ + +echo "*** Testing session_decode() : variation ***\n"; + +var_dump(session_start()); +var_dump($_SESSION); +$_SESSION["foo"] = 1234567890; +$_SESSION["bar"] = "Blah!"; +$_SESSION["guff"] = 123.456; +var_dump($_SESSION); +$encoded = "A2Zvb2k6MTIzNDU2Nzg5MDs="; +var_dump(session_decode(base64_decode($encoded))); +var_dump($_SESSION); +var_dump(session_destroy()); + +echo "Done"; +ob_end_flush(); +?> +--EXPECTF-- +*** Testing session_decode() : variation *** + +Warning: session_start(): Unknown session.serialize_handler. Failed to decode session object. in %s on line %d +bool(true) +array(0) { +} +array(3) { + ["foo"]=> + int(1234567890) + ["bar"]=> + string(5) "Blah!" + ["guff"]=> + float(123.456) +} + +Warning: session_decode(): Unknown session.serialize_handler. Failed to decode session object. in %s on line %d +bool(true) +array(3) { + ["foo"]=> + int(1234567890) + ["bar"]=> + string(5) "Blah!" + ["guff"]=> + float(123.456) +} +bool(true) +Done + diff --git a/ext/session/tests/session_decode_variation4.phpt b/ext/session/tests/session_decode_variation4.phpt new file mode 100644 index 000000000..81642754f --- /dev/null +++ b/ext/session/tests/session_decode_variation4.phpt @@ -0,0 +1,56 @@ +--TEST-- +Test session_decode() function : variation +--SKIPIF-- +<?php include('skipif.inc'); ?> +--FILE-- +<?php + +ob_start(); + +/* + * Prototype : string session_decode(void) + * Description : Decodes session data from a string + * Source code : ext/session/session.c + */ + +echo "*** Testing session_decode() : variation ***\n"; + +var_dump(session_start()); +var_dump($_SESSION); +$_SESSION["foo"] = 1234567890; +$_SESSION["bar"] = "Blah!"; +$_SESSION["guff"] = 123.456; +var_dump($_SESSION); +$encoded = "A2Zvb2k6MTIzNDU2Nzg5MDs="; +var_dump(session_decode(base64_decode($encoded))); +var_dump($_SESSION); +var_dump(session_destroy()); + +echo "Done"; +ob_end_flush(); +?> +--EXPECTF-- +*** Testing session_decode() : variation *** +bool(true) +array(0) { +} +array(3) { + ["foo"]=> + int(1234567890) + ["bar"]=> + string(5) "Blah!" + ["guff"]=> + float(123.456) +} +bool(true) +array(3) { + ["foo"]=> + int(1234567890) + ["bar"]=> + string(5) "Blah!" + ["guff"]=> + float(123.456) +} +bool(true) +Done + diff --git a/ext/session/tests/session_destroy_error.phpt b/ext/session/tests/session_destroy_error.phpt new file mode 100644 index 000000000..c68d33ebd --- /dev/null +++ b/ext/session/tests/session_destroy_error.phpt @@ -0,0 +1,218 @@ +--TEST-- +Test session_destroy() function : error functionality +--SKIPIF-- +<?php include('skipif.inc'); ?> +--FILE-- +<?php + +ob_start(); + +/* + * Prototype : bool session_destroy(void) + * Description : Destroys all data registered to a session + * Source code : ext/session/session.c + */ + +echo "*** Testing session_destroy() : error functionality ***\n"; + +// Get an unset variable +$unset_var = 10; +unset($unset_var); + +class classA +{ + public function __toString() { + return "Hello World!"; + } +} + +$heredoc = <<<EOT +Hello World! +EOT; + +$fp = fopen(__FILE__, "r"); + +// Unexpected values to be passed as arguments +$inputs = array( + + // Integer data +/*1*/ 0, + 1, + 12345, + -2345, + + // Float data +/*5*/ 10.5, + -10.5, + 12.3456789000e10, + 12.3456789000E-10, + .5, + + // Null data +/*10*/ NULL, + null, + + // Boolean data +/*12*/ true, + false, + TRUE, + FALSE, + + // Empty strings +/*16*/ "", + '', + + // Invalid string data +/*18*/ "Nothing", + 'Nothing', + $heredoc, + + // Object data +/*21*/ new classA(), + + // Undefined data +/*22*/ @$undefined_var, + + // Unset data +/*23*/ @$unset_var, + + // Resource variable +/*24*/ $fp +); + + +$iterator = 1; +foreach($inputs as $input) { + echo "\n-- Iteration $iterator --\n"; + var_dump(session_destroy($input)); + $iterator++; +}; + +fclose($fp); +echo "Done"; +ob_end_flush(); +?> +--EXPECTF-- +*** Testing session_destroy() : error functionality *** + +-- Iteration 1 -- + +Warning: Wrong parameter count for session_destroy() in %s on line %d +NULL + +-- Iteration 2 -- + +Warning: Wrong parameter count for session_destroy() in %s on line %d +NULL + +-- Iteration 3 -- + +Warning: Wrong parameter count for session_destroy() in %s on line %d +NULL + +-- Iteration 4 -- + +Warning: Wrong parameter count for session_destroy() in %s on line %d +NULL + +-- Iteration 5 -- + +Warning: Wrong parameter count for session_destroy() in %s on line %d +NULL + +-- Iteration 6 -- + +Warning: Wrong parameter count for session_destroy() in %s on line %d +NULL + +-- Iteration 7 -- + +Warning: Wrong parameter count for session_destroy() in %s on line %d +NULL + +-- Iteration 8 -- + +Warning: Wrong parameter count for session_destroy() in %s on line %d +NULL + +-- Iteration 9 -- + +Warning: Wrong parameter count for session_destroy() in %s on line %d +NULL + +-- Iteration 10 -- + +Warning: Wrong parameter count for session_destroy() in %s on line %d +NULL + +-- Iteration 11 -- + +Warning: Wrong parameter count for session_destroy() in %s on line %d +NULL + +-- Iteration 12 -- + +Warning: Wrong parameter count for session_destroy() in %s on line %d +NULL + +-- Iteration 13 -- + +Warning: Wrong parameter count for session_destroy() in %s on line %d +NULL + +-- Iteration 14 -- + +Warning: Wrong parameter count for session_destroy() in %s on line %d +NULL + +-- Iteration 15 -- + +Warning: Wrong parameter count for session_destroy() in %s on line %d +NULL + +-- Iteration 16 -- + +Warning: Wrong parameter count for session_destroy() in %s on line %d +NULL + +-- Iteration 17 -- + +Warning: Wrong parameter count for session_destroy() in %s on line %d +NULL + +-- Iteration 18 -- + +Warning: Wrong parameter count for session_destroy() in %s on line %d +NULL + +-- Iteration 19 -- + +Warning: Wrong parameter count for session_destroy() in %s on line %d +NULL + +-- Iteration 20 -- + +Warning: Wrong parameter count for session_destroy() in %s on line %d +NULL + +-- Iteration 21 -- + +Warning: Wrong parameter count for session_destroy() in %s on line %d +NULL + +-- Iteration 22 -- + +Warning: Wrong parameter count for session_destroy() in %s on line %d +NULL + +-- Iteration 23 -- + +Warning: Wrong parameter count for session_destroy() in %s on line %d +NULL + +-- Iteration 24 -- + +Warning: Wrong parameter count for session_destroy() in %s on line %d +NULL +Done + diff --git a/ext/session/tests/session_destroy_variation1.phpt b/ext/session/tests/session_destroy_variation1.phpt new file mode 100644 index 000000000..fdbdf08c5 --- /dev/null +++ b/ext/session/tests/session_destroy_variation1.phpt @@ -0,0 +1,45 @@ +--TEST-- +Test session_destroy() function : variation +--SKIPIF-- +<?php include('skipif.inc'); ?> +--FILE-- +<?php + +ob_start(); + +/* + * Prototype : bool session_destroy(void) + * Description : Destroys all data registered to a session + * Source code : ext/session/session.c + */ + +echo "*** Testing session_destroy() : variation ***\n"; + +var_dump(session_start()); +var_dump(session_destroy()); +var_dump(session_destroy()); +var_dump(session_destroy()); +var_dump(session_destroy()); +var_dump(session_destroy()); + +echo "Done"; +ob_end_flush(); +?> +--EXPECTF-- +*** Testing session_destroy() : variation *** +bool(true) +bool(true) + +Warning: session_destroy(): Trying to destroy uninitialized session in %s on line %d +bool(false) + +Warning: session_destroy(): Trying to destroy uninitialized session in %s on line %d +bool(false) + +Warning: session_destroy(): Trying to destroy uninitialized session in %s on line %d +bool(false) + +Warning: session_destroy(): Trying to destroy uninitialized session in %s on line %d +bool(false) +Done + diff --git a/ext/session/tests/session_destroy_variation2.phpt b/ext/session/tests/session_destroy_variation2.phpt new file mode 100644 index 000000000..c72c65bac --- /dev/null +++ b/ext/session/tests/session_destroy_variation2.phpt @@ -0,0 +1,45 @@ +--TEST-- +Test session_destroy() function : variation +--SKIPIF-- +<?php include('skipif.inc'); ?> +--FILE-- +<?php + +ob_start(); + +/* + * Prototype : bool session_destroy(void) + * Description : Destroys all data registered to a session + * Source code : ext/session/session.c + */ + +echo "*** Testing session_destroy() : variation ***\n"; + +var_dump(session_start()); +var_dump(session_destroy()); +var_dump(session_start()); +var_dump(session_destroy()); +var_dump(session_start()); +var_dump(session_destroy()); +var_dump(session_start()); +var_dump(session_destroy()); +var_dump(session_start()); +var_dump(session_destroy()); + +echo "Done"; +ob_end_flush(); +?> +--EXPECTF-- +*** Testing session_destroy() : variation *** +bool(true) +bool(true) +bool(true) +bool(true) +bool(true) +bool(true) +bool(true) +bool(true) +bool(true) +bool(true) +Done + diff --git a/ext/session/tests/session_destroy_variation3.phpt b/ext/session/tests/session_destroy_variation3.phpt new file mode 100644 index 000000000..b63c17e39 --- /dev/null +++ b/ext/session/tests/session_destroy_variation3.phpt @@ -0,0 +1,41 @@ +--TEST-- +Test session_destroy() function : variation +--SKIPIF-- +<?php include('skipif.inc'); ?> +--FILE-- +<?php + +ob_start(); + +/* + * Prototype : bool session_destroy(void) + * Description : Destroys all data registered to a session + * Source code : ext/session/session.c + */ + +echo "*** Testing session_destroy() : variation ***\n"; + +var_dump(session_start()); +var_dump(session_id()); +var_dump(session_destroy()); +var_dump(session_id()); +var_dump(session_start()); +var_dump(session_id()); +var_dump(session_destroy()); +var_dump(session_id()); + +echo "Done"; +ob_end_flush(); +?> +--EXPECTF-- +*** Testing session_destroy() : variation *** +bool(true) +string(%d) "%s" +bool(true) +string(0) "" +bool(true) +string(%d) "%s" +bool(true) +string(0) "" +Done + diff --git a/ext/session/tests/session_encode_basic.phpt b/ext/session/tests/session_encode_basic.phpt new file mode 100644 index 000000000..f74bddd9c --- /dev/null +++ b/ext/session/tests/session_encode_basic.phpt @@ -0,0 +1,174 @@ +--TEST-- +Test session_encode() function : basic functionality +--SKIPIF-- +<?php include('skipif.inc'); ?> +--FILE-- +<?php + +ob_start(); + +/* + * Prototype : string session_encode(void) + * Description : Encodes the current session data as a string + * Source code : ext/session/session.c + */ + +echo "*** Testing session_encode() : basic functionality ***\n"; + +// Get an unset variable +$unset_var = 10; +unset($unset_var); + +class classA +{ + public function __toString() { + return "Hello World!"; + } +} + +$heredoc = <<<EOT +Hello World! +EOT; + +$fp = fopen(__FILE__, "r"); + +// Unexpected values to be passed as arguments +$inputs = array( + + // Integer data +/*1*/ 0, + 1, + 12345, + -2345, + + // Float data +/*5*/ 10.5, + -10.5, + 12.3456789000e10, + 12.3456789000E-10, + .5, + + // Null data +/*10*/ NULL, + null, + + // Boolean data +/*12*/ true, + false, + TRUE, + FALSE, + + // Empty strings +/*16*/ "", + '', + + // Invalid string data +/*18*/ "Nothing", + 'Nothing', + $heredoc, + + // Object data +/*21*/ new classA(), + + // Undefined data +/*22*/ @$undefined_var, + + // Unset data +/*23*/ @$unset_var, + + // Resource variable +/*24*/ $fp +); + +var_dump(session_start()); +$iterator = 1; +foreach($inputs as $input) { + echo "\n-- Iteration $iterator --\n"; + $_SESSION["data"] = $input; + var_dump(session_encode()); + $iterator++; +}; + +var_dump(session_destroy()); +fclose($fp); +echo "Done"; +ob_end_flush(); +?> +--EXPECTF-- +*** Testing session_encode() : basic functionality *** +bool(true) + +-- Iteration 1 -- +string(9) "data|i:0;" + +-- Iteration 2 -- +string(9) "data|i:1;" + +-- Iteration 3 -- +string(13) "data|i:12345;" + +-- Iteration 4 -- +string(13) "data|i:-2345;" + +-- Iteration 5 -- +string(12) "data|d:10.5;" + +-- Iteration 6 -- +string(13) "data|d:-10.5;" + +-- Iteration 7 -- +string(20) "data|d:123456789000;" + +-- Iteration 8 -- +string(86) "data|d:1.2345678899999999145113427164344339914681114578343112953007221221923828125E-9;" + +-- Iteration 9 -- +string(11) "data|d:0.5;" + +-- Iteration 10 -- +string(7) "data|N;" + +-- Iteration 11 -- +string(7) "data|N;" + +-- Iteration 12 -- +string(9) "data|b:1;" + +-- Iteration 13 -- +string(9) "data|b:0;" + +-- Iteration 14 -- +string(9) "data|b:1;" + +-- Iteration 15 -- +string(9) "data|b:0;" + +-- Iteration 16 -- +string(12) "data|s:0:"";" + +-- Iteration 17 -- +string(12) "data|s:0:"";" + +-- Iteration 18 -- +string(19) "data|s:7:"Nothing";" + +-- Iteration 19 -- +string(19) "data|s:7:"Nothing";" + +-- Iteration 20 -- +string(25) "data|s:12:"Hello World!";" + +-- Iteration 21 -- +string(22) "data|O:6:"classA":0:{}" + +-- Iteration 22 -- +string(7) "data|N;" + +-- Iteration 23 -- +string(7) "data|N;" + +-- Iteration 24 -- +string(9) "data|i:0;" +bool(true) +Done + diff --git a/ext/session/tests/session_encode_error.phpt b/ext/session/tests/session_encode_error.phpt new file mode 100644 index 000000000..ce4fd383b --- /dev/null +++ b/ext/session/tests/session_encode_error.phpt @@ -0,0 +1,220 @@ +--TEST-- +Test session_encode() function : basic functionality +--SKIPIF-- +<?php include('skipif.inc'); ?> +--FILE-- +<?php + +ob_start(); + +/* + * Prototype : string session_encode(void) + * Description : Encodes the current session data as a string + * Source code : ext/session/session.c + */ + +echo "*** Testing session_encode() : basic functionality ***\n"; + +// Get an unset variable +$unset_var = 10; +unset($unset_var); + +class classA +{ + public function __toString() { + return "Hello World!"; + } +} + +$heredoc = <<<EOT +Hello World! +EOT; + +$fp = fopen(__FILE__, "r"); + +// Unexpected values to be passed as arguments +$inputs = array( + + // Integer data +/*1*/ 0, + 1, + 12345, + -2345, + + // Float data +/*5*/ 10.5, + -10.5, + 12.3456789000e10, + 12.3456789000E-10, + .5, + + // Null data +/*10*/ NULL, + null, + + // Boolean data +/*12*/ true, + false, + TRUE, + FALSE, + + // Empty strings +/*16*/ "", + '', + + // Invalid string data +/*18*/ "Nothing", + 'Nothing', + $heredoc, + + // Object data +/*21*/ new classA(), + + // Undefined data +/*22*/ @$undefined_var, + + // Unset data +/*23*/ @$unset_var, + + // Resource variable +/*24*/ $fp +); + +session_start(); + +$iterator = 1; +foreach($inputs as $input) { + echo "\n-- Iteration $iterator --\n"; + var_dump(session_encode($input)); + $iterator++; +}; + +session_destroy(); +fclose($fp); +echo "Done"; +ob_end_flush(); +?> +--EXPECTF-- +*** Testing session_encode() : basic functionality *** + +-- Iteration 1 -- + +Warning: Wrong parameter count for session_encode() in %s on line %d +NULL + +-- Iteration 2 -- + +Warning: Wrong parameter count for session_encode() in %s on line %d +NULL + +-- Iteration 3 -- + +Warning: Wrong parameter count for session_encode() in %s on line %d +NULL + +-- Iteration 4 -- + +Warning: Wrong parameter count for session_encode() in %s on line %d +NULL + +-- Iteration 5 -- + +Warning: Wrong parameter count for session_encode() in %s on line %d +NULL + +-- Iteration 6 -- + +Warning: Wrong parameter count for session_encode() in %s on line %d +NULL + +-- Iteration 7 -- + +Warning: Wrong parameter count for session_encode() in %s on line %d +NULL + +-- Iteration 8 -- + +Warning: Wrong parameter count for session_encode() in %s on line %d +NULL + +-- Iteration 9 -- + +Warning: Wrong parameter count for session_encode() in %s on line %d +NULL + +-- Iteration 10 -- + +Warning: Wrong parameter count for session_encode() in %s on line %d +NULL + +-- Iteration 11 -- + +Warning: Wrong parameter count for session_encode() in %s on line %d +NULL + +-- Iteration 12 -- + +Warning: Wrong parameter count for session_encode() in %s on line %d +NULL + +-- Iteration 13 -- + +Warning: Wrong parameter count for session_encode() in %s on line %d +NULL + +-- Iteration 14 -- + +Warning: Wrong parameter count for session_encode() in %s on line %d +NULL + +-- Iteration 15 -- + +Warning: Wrong parameter count for session_encode() in %s on line %d +NULL + +-- Iteration 16 -- + +Warning: Wrong parameter count for session_encode() in %s on line %d +NULL + +-- Iteration 17 -- + +Warning: Wrong parameter count for session_encode() in %s on line %d +NULL + +-- Iteration 18 -- + +Warning: Wrong parameter count for session_encode() in %s on line %d +NULL + +-- Iteration 19 -- + +Warning: Wrong parameter count for session_encode() in %s on line %d +NULL + +-- Iteration 20 -- + +Warning: Wrong parameter count for session_encode() in %s on line %d +NULL + +-- Iteration 21 -- + +Warning: Wrong parameter count for session_encode() in %s on line %d +NULL + +-- Iteration 22 -- + +Warning: Wrong parameter count for session_encode() in %s on line %d +NULL + +-- Iteration 23 -- + +Warning: Wrong parameter count for session_encode() in %s on line %d +NULL + +-- Iteration 24 -- + +Warning: Wrong parameter count for session_encode() in %s on line %d +NULL +Done + diff --git a/ext/session/tests/session_encode_error2.phpt b/ext/session/tests/session_encode_error2.phpt new file mode 100644 index 000000000..6a019b203 --- /dev/null +++ b/ext/session/tests/session_encode_error2.phpt @@ -0,0 +1,251 @@ +--TEST-- +Test session_encode() function : error functionality +--SKIPIF-- +<?php include('skipif.inc'); ?> +--FILE-- +<?php + +ob_start(); + +/* + * Prototype : string session_encode(void) + * Description : Encodes the current session data as a string + * Source code : ext/session/session.c + */ + +echo "*** Testing session_encode() : error functionality ***\n"; + +// Get an unset variable +$unset_var = 10; +unset($unset_var); + +class classA +{ + public function __toString() { + return "Hello World!"; + } +} + +$heredoc = <<<EOT +Hello World! +EOT; + +$fp = fopen(__FILE__, "r"); + +// Unexpected values to be passed as arguments +$inputs = array( + + // Integer data +/*1*/ 0, + 1, + 12345, + -2345, + + // Float data +/*5*/ 10.5, + -10.5, + 12.3456789000e10, + 12.3456789000E-10, + .5, + + // Null data +/*10*/ NULL, + null, + + // Boolean data +/*12*/ true, + false, + TRUE, + FALSE, + + // Empty strings +/*16*/ "", + '', + + // Invalid string data +/*18*/ "Nothing", + 'Nothing', + $heredoc, + + // Object data +/*21*/ new classA(), + + // Undefined data +/*22*/ @$undefined_var, + + // Unset data +/*23*/ @$unset_var, + + // Resource variable +/*24*/ $fp +); + +$iterator = 1; +foreach($inputs as $input) { + echo "\n-- Iteration $iterator --\n"; + var_dump(session_start()); + $_SESSION[$input] = "Hello World!"; + var_dump(session_encode()); + var_dump(session_destroy()); + $iterator++; +}; + +fclose($fp); +echo "Done"; +ob_end_flush(); +?> +--EXPECTF-- +*** Testing session_encode() : error functionality *** + +-- Iteration 1 -- +bool(true) + +Notice: session_encode(): Skipping numeric key 0. in %s on line %d +bool(false) +bool(true) + +-- Iteration 2 -- +bool(true) + +Notice: session_encode(): Skipping numeric key 1. in %s on line %d +bool(false) +bool(true) + +-- Iteration 3 -- +bool(true) + +Notice: session_encode(): Skipping numeric key 12345. in %s on line %d +bool(false) +bool(true) + +-- Iteration 4 -- +bool(true) + +Notice: session_encode(): Skipping numeric key -2345. in %s on line %d +bool(false) +bool(true) + +-- Iteration 5 -- +bool(true) + +Notice: session_encode(): Skipping numeric key 10. in %s on line %d +bool(false) +bool(true) + +-- Iteration 6 -- +bool(true) + +Notice: session_encode(): Skipping numeric key -10. in %s on line %d +bool(false) +bool(true) + +-- Iteration 7 -- +bool(true) + +Notice: session_encode(): Skipping numeric key %s. in %s on line %d +bool(false) +bool(true) + +-- Iteration 8 -- +bool(true) + +Notice: session_encode(): Skipping numeric key 0. in %s on line %d +bool(false) +bool(true) + +-- Iteration 9 -- +bool(true) + +Notice: session_encode(): Skipping numeric key 0. in %s on line %d +bool(false) +bool(true) + +-- Iteration 10 -- +bool(true) +string(21) "|s:12:"Hello World!";" +bool(true) + +-- Iteration 11 -- +bool(true) +string(21) "|s:12:"Hello World!";" +bool(true) + +-- Iteration 12 -- +bool(true) + +Notice: session_encode(): Skipping numeric key 1. in %s on line %d +bool(false) +bool(true) + +-- Iteration 13 -- +bool(true) + +Notice: session_encode(): Skipping numeric key 0. in %s on line %d +bool(false) +bool(true) + +-- Iteration 14 -- +bool(true) + +Notice: session_encode(): Skipping numeric key 1. in %s on line %d +bool(false) +bool(true) + +-- Iteration 15 -- +bool(true) + +Notice: session_encode(): Skipping numeric key 0. in %s on line %d +bool(false) +bool(true) + +-- Iteration 16 -- +bool(true) +string(21) "|s:12:"Hello World!";" +bool(true) + +-- Iteration 17 -- +bool(true) +string(21) "|s:12:"Hello World!";" +bool(true) + +-- Iteration 18 -- +bool(true) +string(28) "Nothing|s:12:"Hello World!";" +bool(true) + +-- Iteration 19 -- +bool(true) +string(28) "Nothing|s:12:"Hello World!";" +bool(true) + +-- Iteration 20 -- +bool(true) +string(33) "Hello World!|s:12:"Hello World!";" +bool(true) + +-- Iteration 21 -- +bool(true) + +Warning: Illegal offset type in %s on line 82 +bool(false) +bool(true) + +-- Iteration 22 -- +bool(true) +string(21) "|s:12:"Hello World!";" +bool(true) + +-- Iteration 23 -- +bool(true) +string(21) "|s:12:"Hello World!";" +bool(true) + +-- Iteration 24 -- +bool(true) + +Strict Standards: Resource ID#%d used as offset, casting to integer (%d) in %s on line %d + +Notice: session_encode(): Skipping numeric key %d. in %s on line %d +bool(false) +bool(true) +Done diff --git a/ext/session/tests/session_encode_variation1.phpt b/ext/session/tests/session_encode_variation1.phpt new file mode 100644 index 000000000..9c9f64b43 --- /dev/null +++ b/ext/session/tests/session_encode_variation1.phpt @@ -0,0 +1,47 @@ +--TEST-- +Test session_encode() function : variation +--SKIPIF-- +<?php include('skipif.inc'); ?> +--FILE-- +<?php + +ob_start(); + +/* + * Prototype : string session_encode(void) + * Description : Encodes the current session data as a string + * Source code : ext/session/session.c + */ + +echo "*** Testing session_encode() : variation ***\n"; + +var_dump(session_encode()); +var_dump(session_start()); +var_dump(session_encode()); +var_dump(session_write_close()); +var_dump(session_encode()); +var_dump(session_start()); +var_dump(session_encode()); +var_dump(session_destroy()); +var_dump(session_encode()); + +echo "Done"; +ob_end_flush(); +?> +--EXPECTF-- +*** Testing session_encode() : variation *** + +Warning: session_encode(): Cannot encode non-existent session. in %s on line %d +bool(false) +bool(true) +bool(false) +NULL +bool(false) +bool(true) +bool(false) +bool(true) + +Warning: session_encode(): Cannot encode non-existent session. in %s on line %d +bool(false) +Done + diff --git a/ext/session/tests/session_encode_variation2.phpt b/ext/session/tests/session_encode_variation2.phpt new file mode 100644 index 000000000..7ec8a63af --- /dev/null +++ b/ext/session/tests/session_encode_variation2.phpt @@ -0,0 +1,35 @@ +--TEST-- +Test session_encode() function : variation +--SKIPIF-- +<?php include('skipif.inc'); ?> +--INI-- +session.auto_start=1 +--FILE-- +<?php + +ob_start(); + +/* + * Prototype : string session_encode(void) + * Description : Encodes the current session data as a string + * Source code : ext/session/session.c + */ + +echo "*** Testing session_encode() : variation ***\n"; + +var_dump(session_encode()); +var_dump(session_destroy()); +var_dump(session_encode()); + +echo "Done"; +ob_end_flush(); +?> +--EXPECTF-- +*** Testing session_encode() : variation *** +bool(false) +bool(true) + +Warning: session_encode(): Cannot encode non-existent session. in %s on line %d +bool(false) +Done + diff --git a/ext/session/tests/session_encode_variation3.phpt b/ext/session/tests/session_encode_variation3.phpt new file mode 100644 index 000000000..40bb44de5 --- /dev/null +++ b/ext/session/tests/session_encode_variation3.phpt @@ -0,0 +1,34 @@ +--TEST-- +Test session_encode() function : variation +--SKIPIF-- +<?php include('skipif.inc'); ?> +--FILE-- +<?php + +ob_start(); + +/* + * Prototype : string session_encode(void) + * Description : Encodes the current session data as a string + * Source code : ext/session/session.c + */ + +echo "*** Testing session_encode() : variation ***\n"; + +var_dump(session_start()); + +$array = array(1,2,3); +$_SESSION["foo"] = &$array; +var_dump(session_encode()); +var_dump(session_destroy()); + +echo "Done"; +ob_end_flush(); +?> +--EXPECTF-- +*** Testing session_encode() : variation *** +bool(true) +string(34) "foo|a:3:{i:0;i:1;i:1;i:2;i:2;i:3;}" +bool(true) +Done + diff --git a/ext/session/tests/session_encode_variation4.phpt b/ext/session/tests/session_encode_variation4.phpt new file mode 100644 index 000000000..d85b9a48a --- /dev/null +++ b/ext/session/tests/session_encode_variation4.phpt @@ -0,0 +1,36 @@ +--TEST-- +Test session_encode() function : variation +--SKIPIF-- +<?php include('skipif.inc'); ?> +--FILE-- +<?php + +ob_start(); + +/* + * Prototype : string session_encode(void) + * Description : Encodes the current session data as a string + * Source code : ext/session/session.c + */ + +echo "*** Testing session_encode() : variation ***\n"; + +var_dump(session_start()); + +$array = array(1,2,3); +$_SESSION["foo"] = &$array; +$_SESSION["guff"] = &$array; +$_SESSION["blah"] = &$array; +var_dump(session_encode()); +var_dump(session_destroy()); + +echo "Done"; +ob_end_flush(); +?> +--EXPECTF-- +*** Testing session_encode() : variation *** +bool(true) +string(52) "foo|a:3:{i:0;i:1;i:1;i:2;i:2;i:3;}guff|R:1;blah|R:1;" +bool(true) +Done + diff --git a/ext/session/tests/session_encode_variation5.phpt b/ext/session/tests/session_encode_variation5.phpt new file mode 100644 index 000000000..fc408847b --- /dev/null +++ b/ext/session/tests/session_encode_variation5.phpt @@ -0,0 +1,36 @@ +--TEST-- +Test session_encode() function : variation +--SKIPIF-- +<?php include('skipif.inc'); ?> +--FILE-- +<?php + +ob_start(); + +/* + * Prototype : string session_encode(void) + * Description : Encodes the current session data as a string + * Source code : ext/session/session.c + */ + +echo "*** Testing session_encode() : variation ***\n"; + +var_dump(session_start()); + +$array = array(1,2,3); +$array["foo"] = &$array; +$array["blah"] = &$array; +$_SESSION["data"] = &$array; +var_dump(session_encode()); +var_dump(session_destroy()); + +echo "Done"; +ob_end_flush(); +?> +--EXPECTF-- +*** Testing session_encode() : variation *** +bool(true) +string(64) "data|a:5:{i:0;i:1;i:1;i:2;i:2;i:3;s:3:"foo";R:1;s:4:"blah";R:1;}" +bool(true) +Done + diff --git a/ext/session/tests/session_encode_variation6.phpt b/ext/session/tests/session_encode_variation6.phpt new file mode 100644 index 000000000..428047382 --- /dev/null +++ b/ext/session/tests/session_encode_variation6.phpt @@ -0,0 +1,52 @@ +--TEST-- +Test session_encode() function : variation +--SKIPIF-- +<?php include('skipif.inc'); ?> +--FILE-- +<?php + +ob_start(); + +/* + * Prototype : string session_encode(void) + * Description : Encodes the current session data as a string + * Source code : ext/session/session.c + */ + +echo "*** Testing session_encode() : variation ***\n"; + +var_dump(session_start()); +$_SESSION[] = 1234567890; +var_dump(session_encode()); +var_dump(session_destroy()); +var_dump(session_start()); +$_SESSION[1234567890] = "Hello World!"; +var_dump(session_encode()); +var_dump(session_destroy()); +var_dump(session_start()); +$_SESSION[-1234567890] = 1234567890; +var_dump(session_encode()); +var_dump(session_destroy()); + +echo "Done"; +ob_end_flush(); +?> +--EXPECTF-- +*** Testing session_encode() : variation *** +bool(true) + +Notice: session_encode(): Skipping numeric key 0. in %s on line %d +bool(false) +bool(true) +bool(true) + +Notice: session_encode(): Skipping numeric key 1234567890. in %s on line %d +bool(false) +bool(true) +bool(true) + +Notice: session_encode(): Skipping numeric key -1234567890. in %s on line %d +bool(false) +bool(true) +Done + diff --git a/ext/session/tests/session_encode_variation7.phpt b/ext/session/tests/session_encode_variation7.phpt new file mode 100644 index 000000000..b3de3c68a --- /dev/null +++ b/ext/session/tests/session_encode_variation7.phpt @@ -0,0 +1,35 @@ +--TEST-- +Test session_encode() function : variation +--SKIPIF-- +<?php include('skipif.inc'); ?> +--INI-- +session.serialize_handler=php_binary +--FILE-- +<?php + +ob_start(); + +/* + * Prototype : string session_encode(void) + * Description : Encodes the current session data as a string + * Source code : ext/session/session.c + */ + +echo "*** Testing session_encode() : variation ***\n"; + +var_dump(session_start()); +$_SESSION["foo"] = 1234567890; +$encoded = session_encode(); +var_dump(base64_encode($encoded)); +var_dump(session_destroy()); + +echo "Done"; +ob_end_flush(); +?> +--EXPECTF-- +*** Testing session_encode() : variation *** +bool(true) +string(24) "A2Zvb2k6MTIzNDU2Nzg5MDs=" +bool(true) +Done + diff --git a/ext/session/tests/session_encode_variation8.phpt b/ext/session/tests/session_encode_variation8.phpt new file mode 100644 index 000000000..57c9e17bd --- /dev/null +++ b/ext/session/tests/session_encode_variation8.phpt @@ -0,0 +1,39 @@ +--TEST-- +Test session_encode() function : variation +--SKIPIF-- +<?php include('skipif.inc'); ?> +--INI-- +session.serialize_handler=blah +--FILE-- +<?php + +ob_start(); + +/* + * Prototype : string session_encode(void) + * Description : Encodes the current session data as a string + * Source code : ext/session/session.c + */ + +echo "*** Testing session_encode() : variation ***\n"; + +var_dump(session_start()); +$_SESSION["foo"] = 1234567890; +$encoded = session_encode(); +var_dump(base64_encode($encoded)); +var_dump(session_destroy()); + +echo "Done"; +ob_end_flush(); +?> +--EXPECTF-- +*** Testing session_encode() : variation *** + +Warning: session_start(): Unknown session.serialize_handler. Failed to decode session object. in %s on line %d +bool(true) + +Warning: session_encode(): Unknown session.serialize_handler. Failed to encode session object. in %s on line %d +string(0) "" +bool(true) +Done + diff --git a/ext/session/tests/session_get_cookie_params_basic.phpt b/ext/session/tests/session_get_cookie_params_basic.phpt new file mode 100644 index 000000000..5cadc7947 --- /dev/null +++ b/ext/session/tests/session_get_cookie_params_basic.phpt @@ -0,0 +1,68 @@ +--TEST-- +Test session_get_cookie_params() function : basic functionality +--SKIPIF-- +<?php include('skipif.inc'); ?> +--FILE-- +<?php + +ob_start(); + +/* + * Prototype : array session_get_cookie_params(void) + * Description : Get the session cookie parameters + * Source code : ext/session/session.c + */ + +echo "*** Testing session_get_cookie_params() : basic functionality ***\n"; + +var_dump(session_get_cookie_params()); +var_dump(session_set_cookie_params(3600, "/path", "blah", FALSE, FALSE)); +var_dump(session_get_cookie_params()); +var_dump(session_set_cookie_params(1234567890, "/guff", "foo", TRUE, TRUE)); +var_dump(session_get_cookie_params()); + +echo "Done"; +ob_end_flush(); +?> +--EXPECTF-- +*** Testing session_get_cookie_params() : basic functionality *** +array(5) { + ["lifetime"]=> + int(0) + ["path"]=> + string(1) "/" + ["domain"]=> + string(0) "" + ["secure"]=> + bool(false) + ["httponly"]=> + bool(false) +} +NULL +array(5) { + ["lifetime"]=> + int(3600) + ["path"]=> + string(5) "/path" + ["domain"]=> + string(4) "blah" + ["secure"]=> + bool(false) + ["httponly"]=> + bool(false) +} +NULL +array(5) { + ["lifetime"]=> + int(1234567890) + ["path"]=> + string(5) "/guff" + ["domain"]=> + string(3) "foo" + ["secure"]=> + bool(true) + ["httponly"]=> + bool(true) +} +Done + diff --git a/ext/session/tests/session_get_cookie_params_error.phpt b/ext/session/tests/session_get_cookie_params_error.phpt new file mode 100644 index 000000000..529ea6b11 --- /dev/null +++ b/ext/session/tests/session_get_cookie_params_error.phpt @@ -0,0 +1,217 @@ +--TEST-- +Test session_get_cookie_params() function : error functionality +--SKIPIF-- +<?php include('skipif.inc'); ?> +--FILE-- +<?php + +ob_start(); + +/* + * Prototype : array session_get_cookie_params(void) + * Description : Get the session cookie parameters + * Source code : ext/session/session.c + */ + +echo "*** Testing session_get_cookie_params() : error functionality ***\n"; + +// Get an unset variable +$unset_var = 10; +unset($unset_var); + +class classA +{ + public function __toString() { + return "Hello World!"; + } +} + +$heredoc = <<<EOT +Hello World! +EOT; + +$fp = fopen(__FILE__, "r"); + +// Unexpected values to be passed as arguments +$inputs = array( + + // Integer data +/*1*/ 0, + 1, + 12345, + -2345, + + // Float data +/*5*/ 10.5, + -10.5, + 12.3456789000e10, + 12.3456789000E-10, + .5, + + // Null data +/*10*/ NULL, + null, + + // Boolean data +/*12*/ true, + false, + TRUE, + FALSE, + + // Empty strings +/*16*/ "", + '', + + // Invalid string data +/*18*/ "Nothing", + 'Nothing', + $heredoc, + + // Object data +/*21*/ new classA(), + + // Undefined data +/*22*/ @$undefined_var, + + // Unset data +/*23*/ @$unset_var, + + // Resource variable +/*24*/ $fp +); + +$iterator = 1; +foreach($inputs as $input) { + echo "\n-- Iteration $iterator --\n"; + var_dump(session_get_cookie_params($input)); + $iterator++; +}; + +fclose($fp); +echo "Done"; +ob_end_flush(); +?> +--EXPECTF-- +*** Testing session_get_cookie_params() : error functionality *** + +-- Iteration 1 -- + +Warning: Wrong parameter count for session_get_cookie_params() in %s on line %d +NULL + +-- Iteration 2 -- + +Warning: Wrong parameter count for session_get_cookie_params() in %s on line %d +NULL + +-- Iteration 3 -- + +Warning: Wrong parameter count for session_get_cookie_params() in %s on line %d +NULL + +-- Iteration 4 -- + +Warning: Wrong parameter count for session_get_cookie_params() in %s on line %d +NULL + +-- Iteration 5 -- + +Warning: Wrong parameter count for session_get_cookie_params() in %s on line %d +NULL + +-- Iteration 6 -- + +Warning: Wrong parameter count for session_get_cookie_params() in %s on line %d +NULL + +-- Iteration 7 -- + +Warning: Wrong parameter count for session_get_cookie_params() in %s on line %d +NULL + +-- Iteration 8 -- + +Warning: Wrong parameter count for session_get_cookie_params() in %s on line %d +NULL + +-- Iteration 9 -- + +Warning: Wrong parameter count for session_get_cookie_params() in %s on line %d +NULL + +-- Iteration 10 -- + +Warning: Wrong parameter count for session_get_cookie_params() in %s on line %d +NULL + +-- Iteration 11 -- + +Warning: Wrong parameter count for session_get_cookie_params() in %s on line %d +NULL + +-- Iteration 12 -- + +Warning: Wrong parameter count for session_get_cookie_params() in %s on line %d +NULL + +-- Iteration 13 -- + +Warning: Wrong parameter count for session_get_cookie_params() in %s on line %d +NULL + +-- Iteration 14 -- + +Warning: Wrong parameter count for session_get_cookie_params() in %s on line %d +NULL + +-- Iteration 15 -- + +Warning: Wrong parameter count for session_get_cookie_params() in %s on line %d +NULL + +-- Iteration 16 -- + +Warning: Wrong parameter count for session_get_cookie_params() in %s on line %d +NULL + +-- Iteration 17 -- + +Warning: Wrong parameter count for session_get_cookie_params() in %s on line %d +NULL + +-- Iteration 18 -- + +Warning: Wrong parameter count for session_get_cookie_params() in %s on line %d +NULL + +-- Iteration 19 -- + +Warning: Wrong parameter count for session_get_cookie_params() in %s on line %d +NULL + +-- Iteration 20 -- + +Warning: Wrong parameter count for session_get_cookie_params() in %s on line %d +NULL + +-- Iteration 21 -- + +Warning: Wrong parameter count for session_get_cookie_params() in %s on line %d +NULL + +-- Iteration 22 -- + +Warning: Wrong parameter count for session_get_cookie_params() in %s on line %d +NULL + +-- Iteration 23 -- + +Warning: Wrong parameter count for session_get_cookie_params() in %s on line %d +NULL + +-- Iteration 24 -- + +Warning: Wrong parameter count for session_get_cookie_params() in %s on line %d +NULL +Done + diff --git a/ext/session/tests/session_get_cookie_params_variation1.phpt b/ext/session/tests/session_get_cookie_params_variation1.phpt new file mode 100644 index 000000000..0ab4eec88 --- /dev/null +++ b/ext/session/tests/session_get_cookie_params_variation1.phpt @@ -0,0 +1,108 @@ +--TEST-- +Test session_get_cookie_params() function : variation +--SKIPIF-- +<?php include('skipif.inc'); ?> +--FILE-- +<?php + +ob_start(); + +/* + * Prototype : array session_get_cookie_params(void) + * Description : Get the session cookie parameters + * Source code : ext/session/session.c + */ + +echo "*** Testing session_get_cookie_params() : variation ***\n"; + +var_dump(session_get_cookie_params()); +ini_set("session.cookie_lifetime", 3600); +var_dump(session_get_cookie_params()); +ini_set("session.cookie_path", "/path"); +var_dump(session_get_cookie_params()); +ini_set("session.cookie_domain", "foo"); +var_dump(session_get_cookie_params()); +ini_set("session.cookie_secure", TRUE); +var_dump(session_get_cookie_params()); +ini_set("session.cookie_httponly", TRUE); +var_dump(session_get_cookie_params()); + +echo "Done"; +ob_end_flush(); +?> +--EXPECTF-- +*** Testing session_get_cookie_params() : variation *** +array(5) { + ["lifetime"]=> + int(0) + ["path"]=> + string(1) "/" + ["domain"]=> + string(0) "" + ["secure"]=> + bool(false) + ["httponly"]=> + bool(false) +} +array(5) { + ["lifetime"]=> + int(3600) + ["path"]=> + string(1) "/" + ["domain"]=> + string(0) "" + ["secure"]=> + bool(false) + ["httponly"]=> + bool(false) +} +array(5) { + ["lifetime"]=> + int(3600) + ["path"]=> + string(5) "/path" + ["domain"]=> + string(0) "" + ["secure"]=> + bool(false) + ["httponly"]=> + bool(false) +} +array(5) { + ["lifetime"]=> + int(3600) + ["path"]=> + string(5) "/path" + ["domain"]=> + string(3) "foo" + ["secure"]=> + bool(false) + ["httponly"]=> + bool(false) +} +array(5) { + ["lifetime"]=> + int(3600) + ["path"]=> + string(5) "/path" + ["domain"]=> + string(3) "foo" + ["secure"]=> + bool(true) + ["httponly"]=> + bool(false) +} +array(5) { + ["lifetime"]=> + int(3600) + ["path"]=> + string(5) "/path" + ["domain"]=> + string(3) "foo" + ["secure"]=> + bool(true) + ["httponly"]=> + bool(true) +} +Done + diff --git a/ext/session/tests/session_id_basic.phpt b/ext/session/tests/session_id_basic.phpt new file mode 100644 index 000000000..5cb13c25e --- /dev/null +++ b/ext/session/tests/session_id_basic.phpt @@ -0,0 +1,43 @@ +--TEST-- +Test session_id() function : basic functionality +--SKIPIF-- +<?php include('skipif.inc'); ?> +--FILE-- +<?php + +ob_start(); + +/* + * Prototype : string session_id([string $id]) + * Description : Get and/or set the current session id + * Source code : ext/session/session.c + */ + +echo "*** Testing session_id() : basic functionality ***\n"; + +var_dump(session_id()); +var_dump(session_id("test")); +var_dump(session_id()); +var_dump(session_id("1234567890")); +var_dump(session_id()); +var_dump(session_start()); +var_dump(session_id()); +var_dump(session_destroy()); +var_dump(session_id()); + +echo "Done"; +ob_end_flush(); +?> +--EXPECTF-- +*** Testing session_id() : basic functionality *** +string(0) "" +string(0) "" +string(4) "test" +string(4) "test" +string(10) "1234567890" +bool(true) +string(10) "1234567890" +bool(true) +string(0) "" +Done + diff --git a/ext/session/tests/session_id_error.phpt b/ext/session/tests/session_id_error.phpt new file mode 100644 index 000000000..07c4ed702 --- /dev/null +++ b/ext/session/tests/session_id_error.phpt @@ -0,0 +1,170 @@ +--TEST-- +Test session_id() function : error functionality +--SKIPIF-- +<?php include('skipif.inc'); ?> +--FILE-- +<?php + +ob_start(); + +/* + * Prototype : string session_id([string $id]) + * Description : Get and/or set the current session id + * Source code : ext/session/session.c + */ + +echo "*** Testing session_id() : error functionality ***\n"; + +// Get an unset variable +$unset_var = 10; +unset($unset_var); + +class classA +{ + public function __toString() { + return "Hello World!"; + } +} + +$heredoc = <<<EOT +Hello World! +EOT; + +$fp = fopen(__FILE__, "r"); + +// Unexpected values to be passed as arguments +$inputs = array( + + // Integer data +/*1*/ 0, + 1, + 12345, + -2345, + + // Float data +/*5*/ 10.5, + -10.5, + 12.3456789000e10, + 12.3456789000E-10, + .5, + + // Null data +/*10*/ NULL, + null, + + // Boolean data +/*12*/ true, + false, + TRUE, + FALSE, + + // Empty strings +/*16*/ "", + '', + + // Invalid string data +/*18*/ "Nothing", + 'Nothing', + $heredoc, + + // Object data +/*21*/ new classA(), + + // Undefined data +/*22*/ @$undefined_var, + + // Unset data +/*23*/ @$unset_var, + + // Resource variable +/*24*/ $fp +); + + +$iterator = 1; +foreach($inputs as $input) { + echo "\n-- Iteration $iterator --\n"; + var_dump(session_id($input)); + $iterator++; +}; + +fclose($fp); +echo "Done"; +ob_end_flush(); +?> +--EXPECTF-- +*** Testing session_id() : error functionality *** + +-- Iteration 1 -- +string(0) "" + +-- Iteration 2 -- +string(1) "0" + +-- Iteration 3 -- +string(1) "1" + +-- Iteration 4 -- +string(5) "12345" + +-- Iteration 5 -- +string(5) "-2345" + +-- Iteration 6 -- +string(4) "10.5" + +-- Iteration 7 -- +string(5) "-10.5" + +-- Iteration 8 -- +string(12) "123456789000" + +-- Iteration 9 -- +string(13) "1.23456789E-9" + +-- Iteration 10 -- +string(3) "0.5" + +-- Iteration 11 -- +string(0) "" + +-- Iteration 12 -- +string(0) "" + +-- Iteration 13 -- +string(1) "1" + +-- Iteration 14 -- +string(0) "" + +-- Iteration 15 -- +string(1) "1" + +-- Iteration 16 -- +string(0) "" + +-- Iteration 17 -- +string(0) "" + +-- Iteration 18 -- +string(0) "" + +-- Iteration 19 -- +string(7) "Nothing" + +-- Iteration 20 -- +string(7) "Nothing" + +-- Iteration 21 -- +string(12) "Hello World!" + +-- Iteration 22 -- +string(12) "Hello World!" + +-- Iteration 23 -- +string(0) "" + +-- Iteration 24 -- +string(0) "" +Done + diff --git a/ext/session/tests/session_id_error2.phpt b/ext/session/tests/session_id_error2.phpt new file mode 100644 index 000000000..05284e797 --- /dev/null +++ b/ext/session/tests/session_id_error2.phpt @@ -0,0 +1,41 @@ +--TEST-- +Test session_id() function : error functionality +--SKIPIF-- +<?php include('skipif.inc'); ?> +--FILE-- +<?php + +ob_start(); + +/* + * Prototype : string session_id([string $id]) + * Description : Get and/or set the current session id + * Source code : ext/session/session.c + */ + +echo "*** Testing session_id() : error functionality ***\n"; + +var_dump(session_id()); +var_dump(session_start()); +var_dump(session_id("test")); +var_dump(session_id()); +var_dump(session_id("1234567890")); +var_dump(session_id()); +var_dump(session_destroy()); +var_dump(session_id()); + +echo "Done"; +ob_end_flush(); +?> +--EXPECTF-- +*** Testing session_id() : error functionality *** +string(0) "" +bool(true) +string(%d) "%s" +string(4) "test" +string(4) "test" +string(10) "1234567890" +bool(true) +string(0) "" +Done + diff --git a/ext/session/tests/session_id_error3.phpt b/ext/session/tests/session_id_error3.phpt new file mode 100644 index 000000000..fc291389d --- /dev/null +++ b/ext/session/tests/session_id_error3.phpt @@ -0,0 +1,79 @@ +--TEST-- +Test session_id() function : error functionality +--SKIPIF-- +<?php include('skipif.inc'); ?> +--FILE-- +<?php + +ob_start(); + +/* + * Prototype : string session_id([string $id]) + * Description : Get and/or set the current session id + * Source code : ext/session/session.c + */ + +echo "*** Testing session_id() : error functionality ***\n"; + +@session_start(); +var_dump(session_id()); +var_dump(session_id("!")); +var_dump(session_id()); +@session_destroy(); + +@session_start(); +var_dump(session_id()); +var_dump(session_id("?><")); +var_dump(session_id()); +@session_destroy(); + +@session_start(); +var_dump(session_id()); +var_dump(session_id("£$%^&*()")); +var_dump(session_id()); +@session_destroy(); + +@session_start(); +var_dump(session_id()); +var_dump(session_id("\r\n")); +var_dump(session_id()); +@session_destroy(); + +@session_start(); +var_dump(session_id()); +var_dump(session_id("\0")); +var_dump(session_id()); +@session_destroy(); + +@session_start(); +var_dump(session_id()); +var_dump(session_id("¬``@~:{>?><,./[]+--")); +var_dump(session_id()); +@session_destroy(); + +echo "Done"; +ob_end_flush(); +?> +--EXPECTF-- +*** Testing session_id() : error functionality *** +string(%d) "%s" +string(%d) "%s" +string(1) "!" +string(%d) "%s" +string(%d) "%s" +string(3) "?><" +string(%d) "%s" +string(%d) "%s" +string(8) "£$%^&*()" +string(%d) "%s" +string(%d) "%s" +string(2) " +" +string(%d) "%s" +string(%d) "%s" +string(0) "" +string(%d) "%s" +string(%d) "%s" +string(19) "¬``@~:{>?><,./[]+--" +Done + diff --git a/ext/session/tests/session_id_error4.phpt b/ext/session/tests/session_id_error4.phpt new file mode 100644 index 000000000..cc23578ae --- /dev/null +++ b/ext/session/tests/session_id_error4.phpt @@ -0,0 +1,33 @@ +--TEST-- +Test session_id() function : error functionality +--SKIPIF-- +<?php include('skipif.inc'); ?> +--FILE-- +<?php + +ob_start(); + +/* + * Prototype : string session_id([string $id]) + * Description : Get and/or set the current session id + * Source code : ext/session/session.c + */ + +echo "*** Testing session_id() : error functionality ***\n"; + +var_dump(ini_set("session.hash_function", -1)); +var_dump(session_id()); +var_dump(session_start()); +var_dump(session_id()); +var_dump(session_destroy()); + +echo "Done"; +ob_end_flush(); +?> +--EXPECTF-- +*** Testing session_id() : error functionality *** +string(1) "0" +string(0) "" + +Fatal error: session_start(): Invalid session hash function in %s on line %d + diff --git a/ext/session/tests/session_id_variation1.phpt b/ext/session/tests/session_id_variation1.phpt new file mode 100644 index 000000000..54d980f3a --- /dev/null +++ b/ext/session/tests/session_id_variation1.phpt @@ -0,0 +1,46 @@ +--TEST-- +Test session_id() function : variation +--SKIPIF-- +<?php include('skipif.inc'); ?> +--FILE-- +<?php + +ob_start(); + +/* + * Prototype : string session_id([string $id]) + * Description : Get and/or set the current session id + * Source code : ext/session/session.c + */ + +echo "*** Testing session_id() : variation ***\n"; + +var_dump(ini_set("session.hash_function", 0)); +var_dump(session_id()); +var_dump(session_start()); +var_dump(session_id()); +var_dump(session_destroy()); + +var_dump(ini_set("session.hash_function", 1)); +var_dump(session_id()); +var_dump(session_start()); +var_dump(session_id()); +var_dump(session_destroy()); + +echo "Done"; +ob_end_flush(); +?> +--EXPECTF-- +*** Testing session_id() : variation *** +string(1) "0" +string(0) "" +bool(true) +string(%d) "%s" +bool(true) +string(1) "0" +string(0) "" +bool(true) +string(%d) "%s" +bool(true) +Done + diff --git a/ext/session/tests/session_id_variation2.phpt b/ext/session/tests/session_id_variation2.phpt new file mode 100644 index 000000000..7b09adafc --- /dev/null +++ b/ext/session/tests/session_id_variation2.phpt @@ -0,0 +1,57 @@ +--TEST-- +Test session_id() function : variation +--SKIPIF-- +<?php include('skipif.inc'); ?> +--FILE-- +<?php + +ob_start(); + +/* + * Prototype : string session_id([string $id]) + * Description : Get and/or set the current session id + * Source code : ext/session/session.c + */ + +echo "*** Testing session_id() : variation ***\n"; + +$directory = dirname(__FILE__); +$filename = ($directory."/entropy.txt"); +var_dump(ini_set("session.entropy_file", $filename)); +var_dump(file_put_contents($filename, "Hello World!")); +var_dump(ini_set("session.entropy_length", filesize($filename))); + +var_dump(ini_set("session.hash_function", 0)); +var_dump(session_id()); +var_dump(session_start()); +var_dump(session_id()); +var_dump(session_destroy()); + +var_dump(ini_set("session.hash_function", 1)); +var_dump(session_id()); +var_dump(session_start()); +var_dump(session_id()); +var_dump(session_destroy()); +var_dump(unlink($filename)); + +echo "Done"; +ob_end_flush(); +?> +--EXPECTF-- +*** Testing session_id() : variation *** +string(0) "" +int(12) +string(1) "0" +string(1) "0" +string(0) "" +bool(true) +string(%d) "%s" +bool(true) +string(1) "0" +string(0) "" +bool(true) +string(%d) "%s" +bool(true) +bool(true) +Done + diff --git a/ext/session/tests/session_is_registered_basic.phpt b/ext/session/tests/session_is_registered_basic.phpt new file mode 100644 index 000000000..080dd0bcc --- /dev/null +++ b/ext/session/tests/session_is_registered_basic.phpt @@ -0,0 +1,269 @@ +--TEST-- +Test session_unregister() function : basic functionality +--SKIPIF-- +<?php include('skipif.inc'); ?> +--FILE-- +<?php + +ob_start(); + +/* + * Prototype : bool session_is_registered(string $name) + * Description : Find out whether a global variable is registered in a session + * Source code : ext/session/session.c + */ + +echo "*** Testing session_is_registered() : basic functionality ***\n"; + +// Get an unset variable +$unset_var = 10; +unset($unset_var); + +class classA +{ + public function __toString() { + return "Hello World!"; + } +} + +$heredoc = <<<EOT +Hello World! +EOT; + +$fp = fopen(__FILE__, "r"); + +// Unexpected values to be passed as arguments +$inputs = array( + + // Integer data +/*1*/ 0, + 1, + 12345, + -2345, + + // Float data +/*5*/ 10.5, + -10.5, + 12.3456789000e10, + 12.3456789000E-10, + .5, + + // Null data +/*10*/ NULL, + null, + + // Boolean data +/*12*/ true, + false, + TRUE, + FALSE, + + // Empty strings +/*16*/ "", + '', + + // Invalid string data +/*18*/ "Nothing", + 'Nothing', + $heredoc, + + // Object data +/*21*/ new classA(), + + // Undefined data +/*22*/ @$undefined_var, + + // Unset data +/*23*/ @$unset_var, + + // Resource variable +/*24*/ $fp +); + + +$iterator = 1; +foreach($inputs as $input) { + echo "\n-- Iteration $iterator --\n"; + var_dump(session_start()); + var_dump(session_is_registered($input)); + var_dump($_SESSION); + var_dump(session_destroy()); + $iterator++; +}; + +fclose($fp); +echo "Done"; +ob_end_flush(); +?> +--EXPECTF-- +*** Testing session_is_registered() : basic functionality *** + +-- Iteration 1 -- +bool(true) +bool(false) +array(0) { +} +bool(true) + +-- Iteration 2 -- +bool(true) +bool(false) +array(0) { +} +bool(true) + +-- Iteration 3 -- +bool(true) +bool(false) +array(0) { +} +bool(true) + +-- Iteration 4 -- +bool(true) +bool(false) +array(0) { +} +bool(true) + +-- Iteration 5 -- +bool(true) +bool(false) +array(0) { +} +bool(true) + +-- Iteration 6 -- +bool(true) +bool(false) +array(0) { +} +bool(true) + +-- Iteration 7 -- +bool(true) +bool(false) +array(0) { +} +bool(true) + +-- Iteration 8 -- +bool(true) +bool(false) +array(0) { +} +bool(true) + +-- Iteration 9 -- +bool(true) +bool(false) +array(0) { +} +bool(true) + +-- Iteration 10 -- +bool(true) +bool(false) +array(0) { +} +bool(true) + +-- Iteration 11 -- +bool(true) +bool(false) +array(0) { +} +bool(true) + +-- Iteration 12 -- +bool(true) +bool(false) +array(0) { +} +bool(true) + +-- Iteration 13 -- +bool(true) +bool(false) +array(0) { +} +bool(true) + +-- Iteration 14 -- +bool(true) +bool(false) +array(0) { +} +bool(true) + +-- Iteration 15 -- +bool(true) +bool(false) +array(0) { +} +bool(true) + +-- Iteration 16 -- +bool(true) +bool(false) +array(0) { +} +bool(true) + +-- Iteration 17 -- +bool(true) +bool(false) +array(0) { +} +bool(true) + +-- Iteration 18 -- +bool(true) +bool(false) +array(0) { +} +bool(true) + +-- Iteration 19 -- +bool(true) +bool(false) +array(0) { +} +bool(true) + +-- Iteration 20 -- +bool(true) +bool(false) +array(0) { +} +bool(true) + +-- Iteration 21 -- +bool(true) +bool(false) +array(0) { +} +bool(true) + +-- Iteration 22 -- +bool(true) +bool(false) +array(0) { +} +bool(true) + +-- Iteration 23 -- +bool(true) +bool(false) +array(0) { +} +bool(true) + +-- Iteration 24 -- +bool(true) +bool(false) +array(0) { +} +bool(true) +Done + diff --git a/ext/session/tests/session_is_registered_variation1.phpt b/ext/session/tests/session_is_registered_variation1.phpt new file mode 100644 index 000000000..f92de8297 --- /dev/null +++ b/ext/session/tests/session_is_registered_variation1.phpt @@ -0,0 +1,108 @@ +--TEST-- +Test session_unregister() function : variation +--SKIPIF-- +<?php include('skipif.inc'); ?> +--FILE-- +<?php + +ob_start(); + +/* + * Prototype : bool session_is_registered(string $name) + * Description : Find out whether a global variable is registered in a session + * Source code : ext/session/session.c + */ + +echo "*** Testing session_is_registered() : variation ***\n"; + +// Get an unset variable +$unset_var = 10; +unset($unset_var); + +class classA +{ + public function __toString() { + return "Hello World!"; + } +} + +$heredoc = <<<EOT +Hello World! +EOT; + +$fp = fopen(__FILE__, "r"); + +// Unexpected values to be passed as arguments +$inputs = array( + + // Integer data +/*1*/ 0, + 1, + 12345, + -2345, + + // Float data +/*5*/ 10.5, + -10.5, + 12.3456789000e10, + 12.3456789000E-10, + .5, + + // Null data +/*10*/ NULL, + null, + + // Boolean data +/*12*/ true, + false, + TRUE, + FALSE, + + // Empty strings +/*16*/ "", + '', + + // Invalid string data +/*18*/ "Nothing", + 'Nothing', + $heredoc, + + // Object data +/*21*/ new classA(), + + // Undefined data +/*22*/ @$undefined_var, + + // Unset data +/*23*/ @$unset_var, + + // Resource variable +/*24*/ $fp +); + +var_dump(session_start()); +var_dump($_SESSION); +var_dump(session_is_registered($inputs)); +var_dump($_SESSION); +var_dump(session_destroy()); +var_dump($_SESSION); + +fclose($fp); +echo "Done"; +ob_end_flush(); +?> +--EXPECTF-- +*** Testing session_is_registered() : variation *** +bool(true) +array(0) { +} + +Notice: Array to string conversion in %s on line %d +bool(false) +array(0) { +} +bool(true) +array(0) { +} +Done + diff --git a/ext/session/tests/session_is_registered_variation2.phpt b/ext/session/tests/session_is_registered_variation2.phpt new file mode 100644 index 000000000..582b947af --- /dev/null +++ b/ext/session/tests/session_is_registered_variation2.phpt @@ -0,0 +1,60 @@ +--TEST-- +Test session_unregister() function : variation +--SKIPIF-- +<?php include('skipif.inc'); ?> +--FILE-- +<?php + +ob_start(); + +/* + * Prototype : bool session_is_registered(string $name) + * Description : Find out whether a global variable is registered in a session + * Source code : ext/session/session.c + */ + +echo "*** Testing session_is_registered() : variation ***\n"; + +var_dump(session_is_registered("foo")); +var_dump(session_start()); +var_dump(session_is_registered("foo")); +var_dump($_SESSION); +$_SESSION["foo"] = "Hello World!"; +var_dump(session_is_registered("foo")); +var_dump($_SESSION); +var_dump(session_is_registered("foo")); +var_dump(session_unregister("foo")); +var_dump(session_is_registered("foo")); +var_dump($_SESSION); +var_dump(session_destroy()); +var_dump(session_is_registered("foo")); +var_dump($_SESSION); +var_dump(session_is_registered("foo")); + +echo "Done"; +ob_end_flush(); +?> +--EXPECTF-- +*** Testing session_is_registered() : variation *** +bool(false) +bool(true) +bool(false) +array(0) { +} +bool(true) +array(1) { + ["foo"]=> + string(12) "Hello World!" +} +bool(true) +bool(true) +bool(false) +array(0) { +} +bool(true) +bool(false) +array(0) { +} +bool(false) +Done + diff --git a/ext/session/tests/session_is_registered_variation3.phpt b/ext/session/tests/session_is_registered_variation3.phpt new file mode 100644 index 000000000..10f7ffe49 --- /dev/null +++ b/ext/session/tests/session_is_registered_variation3.phpt @@ -0,0 +1,59 @@ +--TEST-- +Test session_unregister() function : variation +--SKIPIF-- +<?php include('skipif.inc'); ?> +--FILE-- +<?php + +ob_start(); + +/* + * Prototype : bool session_is_registered(string $name) + * Description : Find out whether a global variable is registered in a session + * Source code : ext/session/session.c + */ + +echo "*** Testing session_is_registered() : variation ***\n"; + +var_dump(session_is_registered("foo")); +var_dump(session_start()); +var_dump(session_is_registered("foo")); +var_dump($_SESSION); +$blah = "Hello World!"; +var_dump(session_is_registered("foo")); +$_SESSION["foo"] = &$blah; +var_dump($_SESSION); +var_dump(session_is_registered("foo")); +var_dump(session_unregister("foo")); +var_dump(session_is_registered("foo")); +var_dump($_SESSION); +var_dump(session_destroy()); +var_dump(session_is_registered("foo")); +var_dump($_SESSION); + +echo "Done"; +ob_end_flush(); +?> +--EXPECTF-- +*** Testing session_is_registered() : variation *** +bool(false) +bool(true) +bool(false) +array(0) { +} +bool(false) +array(1) { + ["foo"]=> + &string(12) "Hello World!" +} +bool(true) +bool(true) +bool(false) +array(0) { +} +bool(true) +bool(false) +array(0) { +} +Done + diff --git a/ext/session/tests/session_module_name_basic.phpt b/ext/session/tests/session_module_name_basic.phpt new file mode 100644 index 000000000..2daf6fc62 --- /dev/null +++ b/ext/session/tests/session_module_name_basic.phpt @@ -0,0 +1,35 @@ +--TEST-- +Test session_module_name() function : basic functionality +--SKIPIF-- +<?php include('skipif.inc'); ?> +--FILE-- +<?php + +ob_start(); + +/* + * Prototype : string session_module_name([string $module]) + * Description : Get and/or set the current session module + * Source code : ext/session/session.c + */ + +echo "*** Testing session_module_name() : basic functionality ***\n"; +var_dump(session_module_name("files")); +var_dump(session_module_name()); +var_dump(session_start()); +var_dump(session_module_name()); +var_dump(session_destroy()); +var_dump(session_module_name()); + +echo "Done"; +ob_end_flush(); +?> +--EXPECTF-- +*** Testing session_module_name() : basic functionality *** +string(%d) "%s" +string(5) "files" +bool(true) +string(5) "files" +bool(true) +string(5) "files" +Done diff --git a/ext/session/tests/session_module_name_error.phpt b/ext/session/tests/session_module_name_error.phpt new file mode 100644 index 000000000..84cfde499 --- /dev/null +++ b/ext/session/tests/session_module_name_error.phpt @@ -0,0 +1,216 @@ +--TEST-- +Test session_module_name() function : error functionality +--SKIPIF-- +<?php include('skipif.inc'); ?> +--FILE-- +<?php + +ob_start(); + +/* + * Prototype : string session_module_name([string $module]) + * Description : Get and/or set the current session module + * Source code : ext/session/session.c + */ + +echo "*** Testing session_module_name() : error functionality ***\n"; + +// Get an unset variable +$unset_var = 10; +unset($unset_var); + +class classA +{ + public function __toString() { + return "Hello World!"; + } +} + +$heredoc = <<<EOT +Hello World! +EOT; + +$fp = fopen(__FILE__, "r"); + +// Unexpected values to be passed as arguments +$inputs = array( + + // Integer data +/*1*/ 0, + 1, + 12345, + -2345, + + // Float data +/*5*/ 10.5, + -10.5, + 12.3456789000e10, + 12.3456789000E-10, + .5, + + // Null data +/*10*/ NULL, + null, + + // Boolean data +/*12*/ true, + false, + TRUE, + FALSE, + + // Empty strings +/*16*/ "", + '', + + // Invalid string data +/*18*/ "Nothing", + 'Nothing', + $heredoc, + + // Object data +/*21*/ new classA(), + + // Undefined data +/*22*/ @$undefined_var, + + // Unset data +/*23*/ @$unset_var, + + // Resource variable +/*24*/ $fp +); + +$iterator = 1; +foreach($inputs as $input) { + echo "\n-- Iteration $iterator --\n"; + var_dump(session_module_name($input)); + $iterator++; +}; + +fclose($fp); +echo "Done"; +ob_end_flush(); +?> +--EXPECTF-- +*** Testing session_module_name() : error functionality *** + +-- Iteration 1 -- + +Warning: session_module_name(): Cannot find named PHP session module (0) in %s on line %d +bool(false) + +-- Iteration 2 -- + +Warning: session_module_name(): Cannot find named PHP session module (1) in %s on line %d +bool(false) + +-- Iteration 3 -- + +Warning: session_module_name(): Cannot find named PHP session module (12345) in %s on line %d +bool(false) + +-- Iteration 4 -- + +Warning: session_module_name(): Cannot find named PHP session module (-2345) in %s on line %d +bool(false) + +-- Iteration 5 -- + +Warning: session_module_name(): Cannot find named PHP session module (10.5) in %s on line %d +bool(false) + +-- Iteration 6 -- + +Warning: session_module_name(): Cannot find named PHP session module (-10.5) in %s on line %d +bool(false) + +-- Iteration 7 -- + +Warning: session_module_name(): Cannot find named PHP session module (123456789000) in %s on line %d +bool(false) + +-- Iteration 8 -- + +Warning: session_module_name(): Cannot find named PHP session module (1.23456789E-9) in %s on line %d +bool(false) + +-- Iteration 9 -- + +Warning: session_module_name(): Cannot find named PHP session module (0.5) in %s on line %d +bool(false) + +-- Iteration 10 -- + +Warning: session_module_name(): Cannot find named PHP session module () in %s on line %d +bool(false) + +-- Iteration 11 -- + +Warning: session_module_name(): Cannot find named PHP session module () in %s on line %d +bool(false) + +-- Iteration 12 -- + +Warning: session_module_name(): Cannot find named PHP session module (1) in %s on line %d +bool(false) + +-- Iteration 13 -- + +Warning: session_module_name(): Cannot find named PHP session module () in %s on line %d +bool(false) + +-- Iteration 14 -- + +Warning: session_module_name(): Cannot find named PHP session module (1) in %s on line %d +bool(false) + +-- Iteration 15 -- + +Warning: session_module_name(): Cannot find named PHP session module () in %s on line %d +bool(false) + +-- Iteration 16 -- + +Warning: session_module_name(): Cannot find named PHP session module () in %s on line %d +bool(false) + +-- Iteration 17 -- + +Warning: session_module_name(): Cannot find named PHP session module () in %s on line %d +bool(false) + +-- Iteration 18 -- + +Warning: session_module_name(): Cannot find named PHP session module (Nothing) in %s on line %d +bool(false) + +-- Iteration 19 -- + +Warning: session_module_name(): Cannot find named PHP session module (Nothing) in %s on line %d +bool(false) + +-- Iteration 20 -- + +Warning: session_module_name(): Cannot find named PHP session module (Hello World!) in %s on line %d +bool(false) + +-- Iteration 21 -- + +Warning: session_module_name(): Cannot find named PHP session module (Hello World!) in %s on line %d +bool(false) + +-- Iteration 22 -- + +Warning: session_module_name(): Cannot find named PHP session module () in %s on line %d +bool(false) + +-- Iteration 23 -- + +Warning: session_module_name(): Cannot find named PHP session module () in %s on line %d +bool(false) + +-- Iteration 24 -- + +Warning: session_module_name(): Cannot find named PHP session module (Resource id #%d) in %s on line %d +bool(false) +Done diff --git a/ext/session/tests/session_module_name_variation1.phpt b/ext/session/tests/session_module_name_variation1.phpt new file mode 100644 index 000000000..2034b7eff --- /dev/null +++ b/ext/session/tests/session_module_name_variation1.phpt @@ -0,0 +1,35 @@ +--TEST-- +Test session_module_name() function : variation +--SKIPIF-- +<?php include('skipif.inc'); ?> +--FILE-- +<?php + +ob_start(); + +/* + * Prototype : string session_module_name([string $module]) + * Description : Get and/or set the current session module + * Source code : ext/session/session.c + */ + +echo "*** Testing session_module_name() : variation ***\n"; +var_dump(session_module_name("blah")); +var_dump(session_start()); +var_dump(session_module_name()); +var_dump(session_destroy()); +var_dump(session_module_name()); + +echo "Done"; +ob_end_flush(); +?> +--EXPECTF-- +*** Testing session_module_name() : variation *** + +Warning: session_module_name(): Cannot find named PHP session module (blah) in %s on line %d +bool(false) +bool(true) +string(%d) "%s" +bool(true) +string(%d) "%s" +Done diff --git a/ext/session/tests/session_module_name_variation2.phpt b/ext/session/tests/session_module_name_variation2.phpt new file mode 100644 index 000000000..aa7b33c76 --- /dev/null +++ b/ext/session/tests/session_module_name_variation2.phpt @@ -0,0 +1,34 @@ +--TEST-- +Test session_module_name() function : variation +--SKIPIF-- +<?php include('skipif.inc'); ?> +--FILE-- +<?php + +ob_start(); + +/* + * Prototype : string session_module_name([string $module]) + * Description : Get and/or set the current session module + * Source code : ext/session/session.c + */ + +echo "*** Testing session_module_name() : variation ***\n"; + +function open($save_path, $session_name) { } +function close() { } +function read($id) { } +function write($id, $session_data) { } +function destroy($id) { } +function gc($maxlifetime) { } + +var_dump(session_module_name("files")); +session_set_save_handler("open", "close", "read", "write", "destroy", "gc"); +var_dump(session_module_name()); + +ob_end_flush(); +?> +--EXPECTF-- +*** Testing session_module_name() : variation *** +string(%d) "%s" +string(4) "user" diff --git a/ext/session/tests/session_module_name_variation3.phpt b/ext/session/tests/session_module_name_variation3.phpt new file mode 100644 index 000000000..dc1c6ba5e --- /dev/null +++ b/ext/session/tests/session_module_name_variation3.phpt @@ -0,0 +1,49 @@ +--TEST-- +Test session_module_name() function : variation +--INI-- +session.save_path= +session.name=PHPSESSID +--SKIPIF-- +<?php include('skipif.inc'); ?> +--FILE-- +<?php + +ob_start(); + +/* + * Prototype : string session_module_name([string $module]) + * Description : Get and/or set the current session module + * Source code : ext/session/session.c + */ + +echo "*** Testing session_module_name() : variation ***\n"; +function open($save_path, $session_name) { + throw new Exception("Stop...!"); +} + +function close() { } +function read($id) { } +function write($id, $session_data) { } +function destroy($id) { } +function gc($maxlifetime) { } + +var_dump(session_module_name("files")); +session_set_save_handler("open", "close", "read", "write", "destroy", "gc"); +var_dump(session_module_name()); +var_dump(session_start()); +var_dump(session_module_name()); +var_dump(session_destroy()); + +ob_end_flush(); +?> +--EXPECTF-- +*** Testing session_module_name() : variation *** +string(%d) "%s" +string(4) "user" + +Fatal error: Uncaught exception 'Exception' with message 'Stop...!' in %s:%d +Stack trace: +#0 [internal function]: open('', 'PHPSESSID') +#1 %s(%d): session_start() +#2 {main} + thrown in %s on line %d diff --git a/ext/session/tests/session_module_name_variation4.phpt b/ext/session/tests/session_module_name_variation4.phpt new file mode 100644 index 000000000..0748b3db2 --- /dev/null +++ b/ext/session/tests/session_module_name_variation4.phpt @@ -0,0 +1,67 @@ +--TEST-- +Test session_module_name() function : variation +--SKIPIF-- +<?php include('skipif.inc'); ?> +--INI-- +session.gc_probability=1 +session.gc_divisor=1 +session.gc_maxlifetime=0 +--FILE-- +<?php + +ob_start(); + +/* + * Prototype : string session_module_name([string $module]) + * Description : Get and/or set the current session module + * Source code : ext/session/session.c + */ + +echo "*** Testing session_module_name() : variation ***\n"; + +require_once "save_handler.inc"; +$path = dirname(__FILE__); +session_save_path($path); +session_module_name("files"); + +session_start(); +$_SESSION["Blah"] = "Hello World!"; +$_SESSION["Foo"] = FALSE; +$_SESSION["Guff"] = 1234567890; +var_dump($_SESSION); + +var_dump(session_write_close()); +session_start(); +var_dump($_SESSION); +var_dump(session_destroy()); +session_start(); +var_dump($_SESSION); +var_dump(session_destroy()); + +ob_end_flush(); +?> +--EXPECTF-- +*** Testing session_module_name() : variation *** + +array(3) { + ["Blah"]=> + string(12) "Hello World!" + ["Foo"]=> + bool(false) + ["Guff"]=> + int(1234567890) +} +NULL +array(3) { + ["Blah"]=> + string(12) "Hello World!" + ["Foo"]=> + bool(false) + ["Guff"]=> + int(1234567890) +} +bool(true) +array(0) { +} +bool(true) + diff --git a/ext/session/tests/session_name_basic.phpt b/ext/session/tests/session_name_basic.phpt new file mode 100644 index 000000000..959f40666 --- /dev/null +++ b/ext/session/tests/session_name_basic.phpt @@ -0,0 +1,40 @@ +--TEST-- +Test session_name() function : error functionality +--INI-- +session.save_path= +session.name=PHPSESSID +--SKIPIF-- +<?php include('skipif.inc'); ?> +--FILE-- +<?php + +ob_start(); + +/* + * Prototype : string session_name([string $name]) + * Description : Get and/or set the current session name + * Source code : ext/session/session.c + */ + +echo "*** Testing session_name() : error functionality ***\n"; + +var_dump(session_name()); +var_dump(session_name("blah")); +var_dump(session_start()); +var_dump(session_name()); +var_dump(session_destroy()); +var_dump(session_name()); + +echo "Done"; +ob_end_flush(); +?> +--EXPECTF-- +*** Testing session_name() : error functionality *** +string(9) "PHPSESSID" +string(9) "PHPSESSID" +bool(true) +string(4) "blah" +bool(true) +string(4) "blah" +Done + diff --git a/ext/session/tests/session_name_error.phpt b/ext/session/tests/session_name_error.phpt new file mode 100644 index 000000000..a2dc01b51 --- /dev/null +++ b/ext/session/tests/session_name_error.phpt @@ -0,0 +1,172 @@ +--TEST-- +Test session_name() function : error functionality +--INI-- +session.save_path= +session.name=PHPSESSID +--SKIPIF-- +<?php include('skipif.inc'); ?> +--FILE-- +<?php + +ob_start(); + +/* + * Prototype : string session_name([string $name]) + * Description : Get and/or set the current session name + * Source code : ext/session/session.c + */ + +echo "*** Testing session_name() : error functionality ***\n"; + +// Get an unset variable +$unset_var = 10; +unset($unset_var); + +class classA +{ + public function __toString() { + return "Hello World!"; + } +} + +$heredoc = <<<EOT +Hello World! +EOT; + +$fp = fopen(__FILE__, "r"); + +// Unexpected values to be passed as arguments +$inputs = array( + + // Integer data +/*1*/ 0, + 1, + 12345, + -2345, + + // Float data +/*5*/ 10.5, + -10.5, + 12.3456789000e10, + 12.3456789000E-10, + .5, + + // Null data +/*10*/ NULL, + null, + + // Boolean data +/*12*/ true, + false, + TRUE, + FALSE, + + // Empty strings +/*16*/ "", + '', + + // Invalid string data +/*18*/ "Nothing", + 'Nothing', + $heredoc, + + // Object data +/*21*/ new classA(), + + // Undefined data +/*22*/ @$undefined_var, + + // Unset data +/*23*/ @$unset_var, + + // Resource variable +/*24*/ $fp +); + +$iterator = 1; +foreach($inputs as $input) { + echo "\n-- Iteration $iterator --\n"; + var_dump(session_name($input)); + $iterator++; +}; + +fclose($fp); +echo "Done"; +ob_end_flush(); +?> +--EXPECTF-- +*** Testing session_name() : error functionality *** + +-- Iteration 1 -- +string(9) "PHPSESSID" + +-- Iteration 2 -- +string(1) "0" + +-- Iteration 3 -- +string(1) "1" + +-- Iteration 4 -- +string(5) "12345" + +-- Iteration 5 -- +string(5) "-2345" + +-- Iteration 6 -- +string(4) "10.5" + +-- Iteration 7 -- +string(5) "-10.5" + +-- Iteration 8 -- +string(12) "123456789000" + +-- Iteration 9 -- +string(13) "1.23456789E-9" + +-- Iteration 10 -- +string(3) "0.5" + +-- Iteration 11 -- +string(0) "" + +-- Iteration 12 -- +string(0) "" + +-- Iteration 13 -- +string(1) "1" + +-- Iteration 14 -- +string(0) "" + +-- Iteration 15 -- +string(1) "1" + +-- Iteration 16 -- +string(0) "" + +-- Iteration 17 -- +string(0) "" + +-- Iteration 18 -- +string(0) "" + +-- Iteration 19 -- +string(7) "Nothing" + +-- Iteration 20 -- +string(7) "Nothing" + +-- Iteration 21 -- +string(12) "Hello World!" + +-- Iteration 22 -- +string(12) "Hello World!" + +-- Iteration 23 -- +string(0) "" + +-- Iteration 24 -- +string(0) "" +Done + diff --git a/ext/session/tests/session_name_variation1.phpt b/ext/session/tests/session_name_variation1.phpt new file mode 100644 index 000000000..16d6ad462 --- /dev/null +++ b/ext/session/tests/session_name_variation1.phpt @@ -0,0 +1,60 @@ +--TEST-- +Test session_name() function : variation +--INI-- +session.save_path= +session.name=PHPSESSID +--SKIPIF-- +<?php include('skipif.inc'); ?> +--FILE-- +<?php + +ob_start(); + +/* + * Prototype : string session_name([string $name]) + * Description : Get and/or set the current session name + * Source code : ext/session/session.c + */ + +echo "*** Testing session_name() : variation ***\n"; + +var_dump(session_name("\0")); +var_dump(session_start()); +var_dump(session_name()); +var_dump(session_destroy()); +var_dump(session_name()); + +var_dump(session_name("\t")); +var_dump(session_start()); +var_dump(session_name()); +var_dump(session_destroy()); +var_dump(session_name()); + +var_dump(session_name("")); +var_dump(session_start()); +var_dump(session_name()); +var_dump(session_destroy()); +var_dump(session_name()); + +echo "Done"; +ob_end_flush(); +?> +--EXPECTF-- +*** Testing session_name() : variation *** +string(9) "PHPSESSID" +bool(true) +string(0) "" +bool(true) +string(0) "" +string(0) "" +bool(true) +string(1) " " +bool(true) +string(1) " " +string(1) " " +bool(true) +string(0) "" +bool(true) +string(0) "" +Done + diff --git a/ext/session/tests/session_name_variation2.phpt b/ext/session/tests/session_name_variation2.phpt new file mode 100644 index 000000000..84bfeba74 --- /dev/null +++ b/ext/session/tests/session_name_variation2.phpt @@ -0,0 +1,39 @@ +--TEST-- +Test session_name() function : variation +--SKIPIF-- +<?php include('skipif.inc'); ?> +--INI-- +session.name=blah +--FILE-- +<?php + +ob_start(); + +/* + * Prototype : string session_name([string $name]) + * Description : Get and/or set the current session name + * Source code : ext/session/session.c + */ + +echo "*** Testing session_name() : variation ***\n"; + +var_dump(session_name()); +var_dump(session_name("blah")); +var_dump(session_start()); +var_dump(session_name()); +var_dump(session_destroy()); +var_dump(session_name()); + +echo "Done"; +ob_end_flush(); +?> +--EXPECTF-- +*** Testing session_name() : variation *** +string(4) "blah" +string(4) "blah" +bool(true) +string(4) "blah" +bool(true) +string(4) "blah" +Done + diff --git a/ext/session/tests/session_regenerate_id_basic.phpt b/ext/session/tests/session_regenerate_id_basic.phpt new file mode 100644 index 000000000..910620a66 --- /dev/null +++ b/ext/session/tests/session_regenerate_id_basic.phpt @@ -0,0 +1,43 @@ +--TEST-- +Test session_regenerate_id() function : basic functionality +--SKIPIF-- +<?php include('skipif.inc'); ?> +--FILE-- +<?php + +ob_start(); + +/* + * Prototype : bool session_regenerate_id([bool $delete_old_session]) + * Description : Update the current session id with a newly generated one + * Source code : ext/session/session.c + */ + +echo "*** Testing session_regenerate_id() : basic functionality ***\n"; + +var_dump(session_id()); +var_dump(session_regenerate_id()); +var_dump(session_id()); +var_dump(session_start()); +var_dump(session_regenerate_id()); +var_dump(session_id()); +var_dump(session_destroy()); +var_dump(session_regenerate_id()); +var_dump(session_id()); + +echo "Done"; +ob_end_flush(); +?> +--EXPECTF-- +*** Testing session_regenerate_id() : basic functionality *** +string(0) "" +bool(false) +string(0) "" +bool(true) +bool(true) +string(%d) "%s" +bool(true) +bool(false) +string(0) "" +Done + diff --git a/ext/session/tests/session_regenerate_id_error.phpt b/ext/session/tests/session_regenerate_id_error.phpt new file mode 100644 index 000000000..9e119f17f --- /dev/null +++ b/ext/session/tests/session_regenerate_id_error.phpt @@ -0,0 +1,174 @@ +--TEST-- +Test session_regenerate_id() function : error functionality +--SKIPIF-- +<?php include('skipif.inc'); ?> +--FILE-- +<?php + +ob_start(); + +/* + * Prototype : bool session_regenerate_id([bool $delete_old_session]) + * Description : Update the current session id with a newly generated one + * Source code : ext/session/session.c + */ + +echo "*** Testing session_regenerate_id() : error functionality ***\n"; + +// Get an unset variable +$unset_var = 10; +unset($unset_var); + +class classA +{ + public function __toString() { + return "Hello World!"; + } +} + +$heredoc = <<<EOT +Hello World! +EOT; + +$fp = fopen(__FILE__, "r"); + +// Unexpected values to be passed as arguments +$inputs = array( + + // Integer data +/*1*/ 0, + 1, + 12345, + -2345, + + // Float data +/*5*/ 10.5, + -10.5, + 12.3456789000e10, + 12.3456789000E-10, + .5, + + // Null data +/*10*/ NULL, + null, + + // Boolean data +/*12*/ true, + false, + TRUE, + FALSE, + + // Empty strings +/*16*/ "", + '', + + // Invalid string data +/*18*/ "Nothing", + 'Nothing', + $heredoc, + + // Object data +/*21*/ new classA(), + + // Undefined data +/*22*/ @$undefined_var, + + // Unset data +/*23*/ @$unset_var, + + // Resource variable +/*24*/ $fp +); + + +$iterator = 1; +foreach($inputs as $input) { + echo "\n-- Iteration $iterator --\n"; + var_dump(session_regenerate_id($input)); + $iterator++; +}; + +fclose($fp); +echo "Done"; +ob_end_flush(); +?> +--EXPECTF-- +*** Testing session_regenerate_id() : error functionality *** + +-- Iteration 1 -- +bool(false) + +-- Iteration 2 -- +bool(false) + +-- Iteration 3 -- +bool(false) + +-- Iteration 4 -- +bool(false) + +-- Iteration 5 -- +bool(false) + +-- Iteration 6 -- +bool(false) + +-- Iteration 7 -- +bool(false) + +-- Iteration 8 -- +bool(false) + +-- Iteration 9 -- +bool(false) + +-- 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 -- + +Warning: session_regenerate_id() expects parameter 1 to be boolean, object given in %s on line %d +NULL + +-- Iteration 22 -- +bool(false) + +-- Iteration 23 -- +bool(false) + +-- Iteration 24 -- + +Warning: session_regenerate_id() expects parameter 1 to be boolean, resource given in %s on line %d +NULL +Done + diff --git a/ext/session/tests/session_regenerate_id_variation1.phpt b/ext/session/tests/session_regenerate_id_variation1.phpt new file mode 100644 index 000000000..95d4a77c8 --- /dev/null +++ b/ext/session/tests/session_regenerate_id_variation1.phpt @@ -0,0 +1,43 @@ +--TEST-- +Test session_regenerate_id() function : variation +--SKIPIF-- +<?php include('skipif.inc'); ?> +--FILE-- +<?php + +ob_start(); + +/* + * Prototype : bool session_regenerate_id([bool $delete_old_session]) + * Description : Update the current session id with a newly generated one + * Source code : ext/session/session.c + */ + +echo "*** Testing session_regenerate_id() : variation ***\n"; + +var_dump(session_id()); +var_dump(session_regenerate_id(TRUE)); +var_dump(session_id()); +var_dump(session_start()); +var_dump(session_regenerate_id(TRUE)); +var_dump(session_id()); +var_dump(session_destroy()); +var_dump(session_regenerate_id(TRUE)); +var_dump(session_id()); + +echo "Done"; +ob_end_flush(); +?> +--EXPECTF-- +*** Testing session_regenerate_id() : variation *** +string(0) "" +bool(false) +string(0) "" +bool(true) +bool(true) +string(%d) "%s" +bool(true) +bool(false) +string(0) "" +Done + diff --git a/ext/session/tests/session_register_basic.phpt b/ext/session/tests/session_register_basic.phpt new file mode 100644 index 000000000..75ae97286 --- /dev/null +++ b/ext/session/tests/session_register_basic.phpt @@ -0,0 +1,317 @@ +--TEST-- +Test session_register() function : basic functionality +--SKIPIF-- +<?php include('skipif.inc'); ?> +--FILE-- +<?php + +ob_start(); + +/* + * Prototype : bool session_register(mixed $name [,mixed $...]) + * Description : Register one or more global variables with the current session + * Source code : ext/session/session.c + */ + +echo "*** Testing session_register() : basic functionality ***\n"; + +// Get an unset variable +$unset_var = 10; +unset($unset_var); + +class classA +{ + public function __toString() { + return "Hello World!"; + } +} + +$heredoc = <<<EOT +Hello World! +EOT; + +$fp = fopen(__FILE__, "r"); + +// Unexpected values to be passed as arguments +$inputs = array( + + // Integer data +/*1*/ 0, + 1, + 12345, + -2345, + + // Float data +/*5*/ 10.5, + -10.5, + 12.3456789000e10, + 12.3456789000E-10, + .5, + + // Null data +/*10*/ NULL, + null, + + // Boolean data +/*12*/ true, + false, + TRUE, + FALSE, + + // Empty strings +/*16*/ "", + '', + + // Invalid string data +/*18*/ "Nothing", + 'Nothing', + $heredoc, + + // Object data +/*21*/ new classA(), + + // Undefined data +/*22*/ @$undefined_var, + + // Unset data +/*23*/ @$unset_var, + + // Resource variable +/*24*/ $fp +); + + +$iterator = 1; +foreach($inputs as $input) { + echo "\n-- Iteration $iterator --\n"; + var_dump(session_start()); + var_dump(session_register($input)); + var_dump($_SESSION); + var_dump(session_destroy()); + $iterator++; +}; + +fclose($fp); +echo "Done"; +ob_end_flush(); +?> +--EXPECTF-- +*** Testing session_register() : basic functionality *** + +-- Iteration 1 -- +bool(true) +bool(true) +array(1) { + ["0"]=> + NULL +} +bool(true) + +-- Iteration 2 -- +bool(true) +bool(true) +array(1) { + ["1"]=> + NULL +} +bool(true) + +-- Iteration 3 -- +bool(true) +bool(true) +array(1) { + ["12345"]=> + NULL +} +bool(true) + +-- Iteration 4 -- +bool(true) +bool(true) +array(1) { + ["-2345"]=> + NULL +} +bool(true) + +-- Iteration 5 -- +bool(true) +bool(true) +array(1) { + ["10.5"]=> + NULL +} +bool(true) + +-- Iteration 6 -- +bool(true) +bool(true) +array(1) { + ["-10.5"]=> + NULL +} +bool(true) + +-- Iteration 7 -- +bool(true) +bool(true) +array(1) { + ["123456789000"]=> + NULL +} +bool(true) + +-- Iteration 8 -- +bool(true) +bool(true) +array(1) { + ["1.23456789E-9"]=> + NULL +} +bool(true) + +-- Iteration 9 -- +bool(true) +bool(true) +array(1) { + ["0.5"]=> + NULL +} +bool(true) + +-- Iteration 10 -- +bool(true) +bool(true) +array(1) { + [""]=> + NULL +} +bool(true) + +-- Iteration 11 -- +bool(true) +bool(true) +array(1) { + [""]=> + NULL +} +bool(true) + +-- Iteration 12 -- +bool(true) +bool(true) +array(1) { + ["1"]=> + NULL +} +bool(true) + +-- Iteration 13 -- +bool(true) +bool(true) +array(1) { + [""]=> + NULL +} +bool(true) + +-- Iteration 14 -- +bool(true) +bool(true) +array(1) { + ["1"]=> + NULL +} +bool(true) + +-- Iteration 15 -- +bool(true) +bool(true) +array(1) { + [""]=> + NULL +} +bool(true) + +-- Iteration 16 -- +bool(true) +bool(true) +array(1) { + [""]=> + NULL +} +bool(true) + +-- Iteration 17 -- +bool(true) +bool(true) +array(1) { + [""]=> + NULL +} +bool(true) + +-- Iteration 18 -- +bool(true) +bool(true) +array(1) { + ["Nothing"]=> + NULL +} +bool(true) + +-- Iteration 19 -- +bool(true) +bool(true) +array(1) { + ["Nothing"]=> + NULL +} +bool(true) + +-- Iteration 20 -- +bool(true) +bool(true) +array(1) { + ["Hello World!"]=> + NULL +} +bool(true) + +-- Iteration 21 -- +bool(true) +bool(true) +array(1) { + ["Hello World!"]=> + NULL +} +bool(true) + +-- Iteration 22 -- +bool(true) +bool(true) +array(1) { + [""]=> + NULL +} +bool(true) + +-- Iteration 23 -- +bool(true) +bool(true) +array(1) { + [""]=> + NULL +} +bool(true) + +-- Iteration 24 -- +bool(true) +bool(true) +array(1) { + ["Resource id #%d"]=> + NULL +} +bool(true) +Done + diff --git a/ext/session/tests/session_register_variation1.phpt b/ext/session/tests/session_register_variation1.phpt new file mode 100644 index 000000000..4f40a095b --- /dev/null +++ b/ext/session/tests/session_register_variation1.phpt @@ -0,0 +1,158 @@ +--TEST-- +Test session_register() function : variation +--SKIPIF-- +<?php include('skipif.inc'); ?> +--FILE-- +<?php + +ob_start(); + +/* + * Prototype : bool session_register(mixed $name [,mixed $...]) + * Description : Register one or more global variables with the current session + * Source code : ext/session/session.c + */ + +echo "*** Testing session_register() : variation ***\n"; + +// Get an unset variable +$unset_var = 10; +unset($unset_var); + +class classA +{ + public function __toString() { + return "Hello World!"; + } +} + +$heredoc = <<<EOT +Hello World! +EOT; + +$fp = fopen(__FILE__, "r"); + +// Unexpected values to be passed as arguments +$inputs = array( + + // Integer data +/*1*/ 0, + 1, + 12345, + -2345, + + // Float data +/*5*/ 10.5, + -10.5, + 12.3456789000e10, + 12.3456789000E-10, + .5, + + // Null data +/*10*/ NULL, + null, + + // Boolean data +/*12*/ true, + false, + TRUE, + FALSE, + + // Empty strings +/*16*/ "", + '', + + // Invalid string data +/*18*/ "Nothing", + 'Nothing', + $heredoc, + + // Object data +/*21*/ new classA(), + + // Undefined data +/*22*/ @$undefined_var, + + // Unset data +/*23*/ @$unset_var, + + // Resource variable +/*24*/ $fp +); + +var_dump(session_start()); +var_dump($_SESSION); +var_dump(session_register($inputs)); +var_dump($_SESSION); +var_dump(session_destroy()); +var_dump($_SESSION); + +fclose($fp); +echo "Done"; +ob_end_flush(); +?> +--EXPECTF-- +*** Testing session_register() : variation *** +bool(true) +array(0) { +} +bool(true) +array(13) { + ["0"]=> + NULL + ["1"]=> + NULL + ["12345"]=> + NULL + ["-2345"]=> + NULL + ["10.5"]=> + NULL + ["-10.5"]=> + NULL + ["123456789000"]=> + NULL + ["1.23456789E-9"]=> + NULL + ["0.5"]=> + NULL + [""]=> + NULL + ["Nothing"]=> + NULL + ["Hello World!"]=> + NULL + ["Resource id #%d"]=> + NULL +} +bool(true) +array(13) { + ["0"]=> + NULL + ["1"]=> + NULL + ["12345"]=> + NULL + ["-2345"]=> + NULL + ["10.5"]=> + NULL + ["-10.5"]=> + NULL + ["123456789000"]=> + NULL + ["1.23456789E-9"]=> + NULL + ["0.5"]=> + NULL + [""]=> + NULL + ["Nothing"]=> + NULL + ["Hello World!"]=> + NULL + ["Resource id #%d"]=> + NULL +} +Done + diff --git a/ext/session/tests/session_register_variation2.phpt b/ext/session/tests/session_register_variation2.phpt new file mode 100644 index 000000000..11189c597 --- /dev/null +++ b/ext/session/tests/session_register_variation2.phpt @@ -0,0 +1,40 @@ +--TEST-- +Test session_register() function : variation +--SKIPIF-- +<?php include('skipif.inc'); ?> +--FILE-- +<?php + +ob_start(); + +/* + * Prototype : bool session_register(mixed $name [,mixed $...]) + * Description : Register one or more global variables with the current session + * Source code : ext/session/session.c + */ + +echo "*** Testing session_register() : variation ***\n"; + +var_dump(session_start()); +var_dump($_SESSION); +var_dump(session_register()); +var_dump($_SESSION); +var_dump(session_destroy()); +var_dump($_SESSION); + +echo "Done"; +ob_end_flush(); +?> +--EXPECTF-- +*** Testing session_register() : variation *** +bool(true) +array(0) { +} +bool(false) +array(0) { +} +bool(true) +array(0) { +} +Done + diff --git a/ext/session/tests/session_register_variation3.phpt b/ext/session/tests/session_register_variation3.phpt new file mode 100644 index 000000000..7051dea93 --- /dev/null +++ b/ext/session/tests/session_register_variation3.phpt @@ -0,0 +1,45 @@ +--TEST-- +Test session_register() function : variation +--SKIPIF-- +<?php include('skipif.inc'); ?> +--FILE-- +<?php + +ob_start(); + +/* + * Prototype : bool session_register(mixed $name [,mixed $...]) + * Description : Register one or more global variables with the current session + * Source code : ext/session/session.c + */ + +echo "*** Testing session_register() : variation ***\n"; + +$blah = "Hello World!"; +var_dump(session_start()); +var_dump($_SESSION); +var_dump(session_register("blah")); +var_dump($_SESSION); +var_dump(session_destroy()); +var_dump($_SESSION); + +echo "Done"; +ob_end_flush(); +?> +--EXPECTF-- +*** Testing session_register() : variation *** +bool(true) +array(0) { +} +bool(true) +array(1) { + ["blah"]=> + NULL +} +bool(true) +array(1) { + ["blah"]=> + NULL +} +Done + diff --git a/ext/session/tests/session_register_variation4.phpt b/ext/session/tests/session_register_variation4.phpt new file mode 100644 index 000000000..384133ee6 --- /dev/null +++ b/ext/session/tests/session_register_variation4.phpt @@ -0,0 +1,46 @@ +--TEST-- +Test session_register() function : variation +--SKIPIF-- +<?php include('skipif.inc'); ?> +--FILE-- +<?php + +ob_start(); + +/* + * Prototype : bool session_register(mixed $name [,mixed $...]) + * Description : Register one or more global variables with the current session + * Source code : ext/session/session.c + */ + +echo "*** Testing session_register() : variation ***\n"; + +$blah = "Hello World!"; +$foo = &$blah; +var_dump(session_start()); +var_dump($_SESSION); +var_dump(session_register("foo")); +var_dump($_SESSION); +var_dump(session_destroy()); +var_dump($_SESSION); + +echo "Done"; +ob_end_flush(); +?> +--EXPECTF-- +*** Testing session_register() : variation *** +bool(true) +array(0) { +} +bool(true) +array(1) { + ["foo"]=> + NULL +} +bool(true) +array(1) { + ["foo"]=> + NULL +} +Done + diff --git a/ext/session/tests/session_save_path_basic.phpt b/ext/session/tests/session_save_path_basic.phpt new file mode 100644 index 000000000..2895f46c0 --- /dev/null +++ b/ext/session/tests/session_save_path_basic.phpt @@ -0,0 +1,36 @@ +--TEST-- +Test session_save_path() function : basic functionality +--INI-- +session.gc_probability=0 +session.save_path= +session.name=PHPSESSID +--SKIPIF-- +<?php include('skipif.inc'); ?> +--FILE-- +<?php + +ob_start(); + +/* + * Prototype : string session_save_path([string $path]) + * Description : Get and/or set the current session save path + * Source code : ext/session/session.c + */ + +echo "*** Testing session_save_path() : error functionality ***\n"; + +$directory = dirname(__FILE__); +var_dump(session_save_path()); +var_dump(session_save_path($directory)); +var_dump(session_save_path()); + +echo "Done"; +ob_end_flush(); +?> +--EXPECTF-- +*** Testing session_save_path() : error functionality *** +string(0) "" +string(0) "" +string(%d) "%s" +Done + diff --git a/ext/session/tests/session_save_path_error.phpt b/ext/session/tests/session_save_path_error.phpt new file mode 100644 index 000000000..b58e73133 --- /dev/null +++ b/ext/session/tests/session_save_path_error.phpt @@ -0,0 +1,176 @@ +--TEST-- +Test session_save_path() function : error functionality +--INI-- +session.gc_probability=0 +session.save_path= +session.name=PHPSESSID +--SKIPIF-- +<?php include('skipif.inc'); ?> +--FILE-- +<?php + +ob_start(); + +/* + * Prototype : string session_save_path([string $path]) + * Description : Get and/or set the current session save path + * Source code : ext/session/session.c + */ + +echo "*** Testing session_save_path() : error functionality ***\n"; + +// Get an unset variable +$unset_var = 10; +unset($unset_var); + +class classA +{ + public function __toString() { + return "Hello World!"; + } +} + +$heredoc = <<<EOT +Hello World! +EOT; + +$fp = fopen(__FILE__, "r"); + +// Unexpected values to be passed as arguments +$inputs = array( + + // Integer data +/*1*/ 0, + 1, + 12345, + -2345, + + // Float data +/*5*/ 10.5, + -10.5, + 12.3456789000e10, + 12.3456789000E-10, + .5, + + // Null data +/*10*/ NULL, + null, + + // Boolean data +/*12*/ true, + false, + TRUE, + FALSE, + + // Empty strings +/*16*/ "", + '', + + // Invalid string data +/*18*/ "Nothing", + 'Nothing', + $heredoc, + + // Object data +/*21*/ new classA(), + + // Undefined data +/*22*/ @$undefined_var, + + // Unset data +/*23*/ @$unset_var, + + // Resource variable +/*24*/ $fp +); + +session_start(); + +$iterator = 1; +foreach($inputs as $input) { + echo "\n-- Iteration $iterator --\n"; + var_dump(session_save_path($input)); + $iterator++; +}; + +session_destroy(); +fclose($fp); +echo "Done"; +ob_end_flush(); +?> +--EXPECTF-- +*** Testing session_save_path() : error functionality *** + +-- Iteration 1 -- +string(0) "" + +-- Iteration 2 -- +string(1) "0" + +-- Iteration 3 -- +string(1) "1" + +-- Iteration 4 -- +string(5) "12345" + +-- Iteration 5 -- +string(5) "-2345" + +-- Iteration 6 -- +string(4) "10.5" + +-- Iteration 7 -- +string(5) "-10.5" + +-- Iteration 8 -- +string(12) "123456789000" + +-- Iteration 9 -- +string(13) "1.23456789E-9" + +-- Iteration 10 -- +string(3) "0.5" + +-- Iteration 11 -- +string(0) "" + +-- Iteration 12 -- +string(0) "" + +-- Iteration 13 -- +string(1) "1" + +-- Iteration 14 -- +string(0) "" + +-- Iteration 15 -- +string(1) "1" + +-- Iteration 16 -- +string(0) "" + +-- Iteration 17 -- +string(0) "" + +-- Iteration 18 -- +string(0) "" + +-- Iteration 19 -- +string(7) "Nothing" + +-- Iteration 20 -- +string(7) "Nothing" + +-- Iteration 21 -- +string(12) "Hello World!" + +-- Iteration 22 -- +string(12) "Hello World!" + +-- Iteration 23 -- +string(0) "" + +-- Iteration 24 -- +string(0) "" +Done + diff --git a/ext/session/tests/session_save_path_variation1.phpt b/ext/session/tests/session_save_path_variation1.phpt new file mode 100644 index 000000000..d5f64d985 --- /dev/null +++ b/ext/session/tests/session_save_path_variation1.phpt @@ -0,0 +1,44 @@ +--TEST-- +Test session_save_path() function : variation +--INI-- +session.gc_probability=0 +session.save_path= +session.name=PHPSESSID +--SKIPIF-- +<?php include('skipif.inc'); ?> +--FILE-- +<?php + +ob_start(); + +/* + * Prototype : string session_save_path([string $path]) + * Description : Get and/or set the current session save path + * Source code : ext/session/session.c + */ + +echo "*** Testing session_save_path() : variation ***\n"; + +$directory = dirname(__FILE__); +var_dump(session_save_path()); +var_dump(session_start()); +var_dump(session_save_path()); +var_dump(session_save_path($directory)); +var_dump(session_save_path()); +var_dump(session_destroy()); +var_dump(session_save_path()); + +echo "Done"; +ob_end_flush(); +?> +--EXPECTF-- +*** Testing session_save_path() : variation *** +string(0) "" +bool(true) +string(0) "" +string(0) "" +string(%d) "%s" +bool(true) +string(%d) "%s" +Done + diff --git a/ext/session/tests/session_save_path_variation2.phpt b/ext/session/tests/session_save_path_variation2.phpt new file mode 100644 index 000000000..6b0848031 --- /dev/null +++ b/ext/session/tests/session_save_path_variation2.phpt @@ -0,0 +1,40 @@ +--TEST-- +Test session_save_path() function : variation +--SKIPIF-- +<?php include('skipif.inc'); ?> +--INI-- +session.save_handler=files +session.gc_probability=0 +--FILE-- +<?php + +ob_start(); + +/* + * Prototype : string session_save_path([string $path]) + * Description : Get and/or set the current session save path + * Source code : ext/session/session.c + */ + +echo "*** Testing session_save_path() : variation ***\n"; + +ini_set("session.save_path", "/blah"); +var_dump(ini_get("session.save_path")); +var_dump(session_start()); +var_dump(ini_get("session.save_path")); +var_dump(session_destroy()); +var_dump(ini_get("session.save_path")); + +echo "Done"; +ob_end_flush(); +?> +--EXPECTF-- +*** Testing session_save_path() : variation *** +string(5) "/blah" + +Warning: session_start(): open(%s, O_RDWR) failed: No such file or directory (2) in %s on line %d +bool(true) +string(5) "/blah" +bool(true) +string(5) "/blah" +Done diff --git a/ext/session/tests/session_save_path_variation3.phpt b/ext/session/tests/session_save_path_variation3.phpt new file mode 100644 index 000000000..b064f3018 --- /dev/null +++ b/ext/session/tests/session_save_path_variation3.phpt @@ -0,0 +1,40 @@ +--TEST-- +Test session_save_path() function : variation +--SKIPIF-- +<?php include('skipif.inc'); ?> +--INI-- +session.save_handler=files +session.gc_probability=0 +--FILE-- +<?php + +ob_start(); + +/* + * Prototype : string session_save_path([string $path]) + * Description : Get and/or set the current session save path + * Source code : ext/session/session.c + */ + +echo "*** Testing session_save_path() : variation ***\n"; + +ini_set("session.save_path", "/blah"); +var_dump(session_save_path()); +var_dump(session_start()); +var_dump(session_save_path()); +var_dump(session_destroy()); +var_dump(session_save_path()); + +echo "Done"; +ob_end_flush(); +?> +--EXPECTF-- +*** Testing session_save_path() : variation *** +string(5) "/blah" + +Warning: session_start(): open(%s, O_RDWR) failed: No such file or directory (2) in %s on line %d +bool(true) +string(5) "/blah" +bool(true) +string(5) "/blah" +Done diff --git a/ext/session/tests/session_save_path_variation4.phpt b/ext/session/tests/session_save_path_variation4.phpt new file mode 100644 index 000000000..453645d31 --- /dev/null +++ b/ext/session/tests/session_save_path_variation4.phpt @@ -0,0 +1,63 @@ +--TEST-- +Test session_save_path() function : variation +--SKIPIF-- +<?php include('skipif.inc'); +if(substr(PHP_OS, 0, 3) != "WIN") + die("skip Only for Windows"); +?> +--INI-- +open_basedir=. +session.save_handler=files +session.save_path= +session.name=PHPSESSID +--FILE-- +<?php + +ob_start(); + +/* + * Prototype : string session_save_path([string $path]) + * Description : Get and/or set the current session save path + * Source code : ext/session/session.c + */ + +echo "*** Testing session_save_path() : variation ***\n"; +$directory = dirname(__FILE__); +$sessions = ($directory."/sessions"); + +chdir($directory); + +// Delete the existing directory +if (file_exists($sessions) === TRUE) { + @rmdir($sessions); +} + +var_dump(mkdir($sessions)); +var_dump(chdir($sessions)); +ini_set("session.save_path", $directory); +var_dump(session_save_path()); +var_dump(session_start()); +var_dump(session_save_path()); +var_dump(session_destroy()); +var_dump(session_save_path()); +var_dump(rmdir($sessions)); + +echo "Done"; +ob_end_flush(); +?> +--CLEAN-- +$directory = dirname(__FILE__); +$sessions = ($directory."/sessions"); +var_dump(rmdir($sessions)); +--EXPECTF-- +*** Testing session_save_path() : variation *** +bool(true) +bool(true) + +Warning: ini_set(): open_basedir restriction in effect. File(%s) is not within the allowed path(s): (.) in %s on line %d +string(0) "" + +Warning: session_start(): open_basedir restriction in effect. File(%s) is not within the allowed path(s): (.) in %s on line %d + +Fatal error: session_start(): Failed to initialize storage module: files (path: ) in %s on line %d + diff --git a/ext/session/tests/session_save_path_variation5.phpt b/ext/session/tests/session_save_path_variation5.phpt new file mode 100644 index 000000000..4f1f98892 --- /dev/null +++ b/ext/session/tests/session_save_path_variation5.phpt @@ -0,0 +1,65 @@ +--TEST-- +Test session_save_path() function : variation +--SKIPIF-- +<?php include('skipif.inc'); +if(substr(PHP_OS, 0, 3) == "WIN") + die("skip Not for Windows"); +?> +--INI-- +open_basedir=. +session.save_handler=files +session.save_path= +session.name=PHPSESSID +--FILE-- +<?php + +ob_start(); + +/* + * Prototype : string session_save_path([string $path]) + * Description : Get and/or set the current session save path + * Source code : ext/session/session.c + */ + +echo "*** Testing session_save_path() : variation ***\n"; +$directory = dirname(__FILE__); +$sessions = ($directory."/sessions"); + +chdir($directory); + +// Delete the existing directory +if (file_exists($sessions) === TRUE) { + @rmdir($sessions); +} + +var_dump(mkdir($sessions)); +var_dump(chdir($sessions)); +ini_set("session.save_path", $directory); +var_dump(session_save_path()); +var_dump(session_start()); +var_dump(session_save_path()); +var_dump(session_destroy()); +var_dump(session_save_path()); +var_dump(rmdir($sessions)); + +echo "Done"; +ob_end_flush(); +?> +--CLEAN-- +$directory = dirname(__FILE__); +$sessions = ($directory."/sessions"); +var_dump(rmdir($sessions)); +--EXPECTF-- +*** Testing session_save_path() : variation *** +bool(true) +bool(true) + +Warning: ini_set(): open_basedir restriction in effect. File(%s) is not within the allowed path(s): (.) in %s on line %d +string(0) "" +bool(true) +string(0) "" +bool(true) +string(0) "" +bool(true) +Done + diff --git a/ext/session/tests/session_set_cookie_params_basic.phpt b/ext/session/tests/session_set_cookie_params_basic.phpt new file mode 100644 index 000000000..5055d1c69 --- /dev/null +++ b/ext/session/tests/session_set_cookie_params_basic.phpt @@ -0,0 +1,35 @@ +--TEST-- +Test session_set_cookie_params() function : basic functionality +--SKIPIF-- +<?php include('skipif.inc'); ?> +--FILE-- +<?php + +ob_start(); + +/* + * Prototype : void session_set_cookie_params(int $lifetime [, string $path [, string $domain [, bool $secure [, bool $httponly]]]]) + * Description : Set the session cookie parameters + * Source code : ext/session/session.c + */ + +echo "*** Testing session_set_cookie_params() : basic functionality ***\n"; + +var_dump(session_set_cookie_params(3600)); +var_dump(session_start()); +var_dump(session_set_cookie_params(1800)); +var_dump(session_destroy()); +var_dump(session_set_cookie_params(1234567890)); + +echo "Done"; +ob_end_flush(); +?> +--EXPECTF-- +*** Testing session_set_cookie_params() : basic functionality *** +NULL +bool(true) +NULL +bool(true) +NULL +Done + diff --git a/ext/session/tests/session_set_cookie_params_error.phpt b/ext/session/tests/session_set_cookie_params_error.phpt new file mode 100644 index 000000000..389387f6a --- /dev/null +++ b/ext/session/tests/session_set_cookie_params_error.phpt @@ -0,0 +1,298 @@ +--TEST-- +Test session_set_cookie_params() function : error functionality +--SKIPIF-- +<?php include('skipif.inc'); ?> +--FILE-- +<?php + +ob_start(); + +/* + * Prototype : void session_set_cookie_params(int $lifetime [, string $path [, string $domain [, bool $secure [, bool $httponly]]]]) + * Description : Set the session cookie parameters + * Source code : ext/session/session.c + */ + +echo "*** Testing session_set_cookie_params() : error functionality ***\n"; + +// Get an unset variable +$unset_var = 10; +unset($unset_var); + +class classA +{ + public function __toString() { + return "Hello World!"; + } +} + +$heredoc = <<<EOT +Hello World! +EOT; + +$fp = fopen(__FILE__, "r"); + +// Unexpected values to be passed as arguments +$inputs = array( + + // Integer data +/*1*/ 0, + 1, + 12345, + -2345, + + // Float data +/*5*/ 10.5, + -10.5, + 12.3456789000e10, + 12.3456789000E-10, + .5, + + // Null data +/*10*/ NULL, + null, + + // Boolean data +/*12*/ true, + false, + TRUE, + FALSE, + + // Empty strings +/*16*/ "", + '', + + // Invalid string data +/*18*/ "Nothing", + 'Nothing', + $heredoc, + + // Object data +/*21*/ new classA(), + + // Undefined data +/*22*/ @$undefined_var, + + // Unset data +/*23*/ @$unset_var, + + // Resource variable +/*24*/ $fp +); + +$iterator = 1; +foreach($inputs as $input) { + echo "\n-- Iteration $iterator --\n"; + var_dump(session_set_cookie_params($input)); + var_dump(session_set_cookie_params(1234567890, $input)); + var_dump(session_set_cookie_params(1234567890, "blah", $input)); + var_dump(session_set_cookie_params(1234567890, "blah", "foo", $input)); + var_dump(session_set_cookie_params(1234567890, "blah", "foo", TRUE, $input)); + var_dump(session_set_cookie_params(1234567890, "blah", "foo", TRUE, FALSE)); + $iterator++; +}; + +fclose($fp); +echo "Done"; +ob_end_flush(); +?> +--EXPECTF-- +*** Testing session_set_cookie_params() : error functionality *** + +-- Iteration 1 -- +NULL +NULL +NULL +NULL +NULL +NULL + +-- Iteration 2 -- +NULL +NULL +NULL +NULL +NULL +NULL + +-- Iteration 3 -- +NULL +NULL +NULL +NULL +NULL +NULL + +-- Iteration 4 -- +NULL +NULL +NULL +NULL +NULL +NULL + +-- Iteration 5 -- +NULL +NULL +NULL +NULL +NULL +NULL + +-- Iteration 6 -- +NULL +NULL +NULL +NULL +NULL +NULL + +-- Iteration 7 -- +NULL +NULL +NULL +NULL +NULL +NULL + +-- Iteration 8 -- +NULL +NULL +NULL +NULL +NULL +NULL + +-- Iteration 9 -- +NULL +NULL +NULL +NULL +NULL +NULL + +-- Iteration 10 -- +NULL +NULL +NULL +NULL +NULL +NULL + +-- Iteration 11 -- +NULL +NULL +NULL +NULL +NULL +NULL + +-- Iteration 12 -- +NULL +NULL +NULL +NULL +NULL +NULL + +-- Iteration 13 -- +NULL +NULL +NULL +NULL +NULL +NULL + +-- Iteration 14 -- +NULL +NULL +NULL +NULL +NULL +NULL + +-- Iteration 15 -- +NULL +NULL +NULL +NULL +NULL +NULL + +-- Iteration 16 -- +NULL +NULL +NULL +NULL +NULL +NULL + +-- Iteration 17 -- +NULL +NULL +NULL +NULL +NULL +NULL + +-- Iteration 18 -- +NULL +NULL +NULL +NULL +NULL +NULL + +-- Iteration 19 -- +NULL +NULL +NULL +NULL +NULL +NULL + +-- Iteration 20 -- +NULL +NULL +NULL +NULL +NULL +NULL + +-- Iteration 21 -- +NULL +NULL +NULL + +Notice: Object of class classA could not be converted to int in %s on line %d +NULL + +Notice: Object of class classA could not be converted to int in %s on line %d +NULL +NULL + +-- Iteration 22 -- +NULL +NULL +NULL +NULL +NULL +NULL + +-- Iteration 23 -- +NULL +NULL +NULL +NULL +NULL +NULL + +-- Iteration 24 -- +NULL +NULL +NULL +NULL +NULL +NULL +Done + diff --git a/ext/session/tests/session_set_cookie_params_variation1.phpt b/ext/session/tests/session_set_cookie_params_variation1.phpt new file mode 100644 index 000000000..02b901f3c --- /dev/null +++ b/ext/session/tests/session_set_cookie_params_variation1.phpt @@ -0,0 +1,49 @@ +--TEST-- +Test session_set_cookie_params() function : variation +--INI-- +session.cookie_lifetime=3600 +--SKIPIF-- +<?php include('skipif.inc'); ?> +--FILE-- +<?php + +ob_start(); + +/* + * Prototype : void session_set_cookie_params(int $lifetime [, string $path [, string $domain [, bool $secure [, bool $httponly]]]]) + * Description : Set the session cookie parameters + * Source code : ext/session/session.c + */ + +echo "*** Testing session_set_cookie_params() : variation ***\n"; + +var_dump(ini_get("session.cookie_lifetime")); +var_dump(session_set_cookie_params(3600)); +var_dump(ini_get("session.cookie_lifetime")); +var_dump(session_start()); +var_dump(ini_get("session.cookie_lifetime")); +var_dump(session_set_cookie_params(1800)); +var_dump(ini_get("session.cookie_lifetime")); +var_dump(session_destroy()); +var_dump(ini_get("session.cookie_lifetime")); +var_dump(session_set_cookie_params(1234567890)); +var_dump(ini_get("session.cookie_lifetime")); + +echo "Done"; +ob_end_flush(); +?> +--EXPECTF-- +*** Testing session_set_cookie_params() : variation *** +string(4) "3600" +NULL +string(4) "3600" +bool(true) +string(4) "3600" +NULL +string(4) "1800" +bool(true) +string(4) "1800" +NULL +string(10) "1234567890" +Done + diff --git a/ext/session/tests/session_set_cookie_params_variation2.phpt b/ext/session/tests/session_set_cookie_params_variation2.phpt new file mode 100644 index 000000000..5d7a01096 --- /dev/null +++ b/ext/session/tests/session_set_cookie_params_variation2.phpt @@ -0,0 +1,49 @@ +--TEST-- +Test session_set_cookie_params() function : variation +--INI-- +session.cookie_path=/path +--SKIPIF-- +<?php include('skipif.inc'); ?> +--FILE-- +<?php + +ob_start(); + +/* + * Prototype : void session_set_cookie_params(int $lifetime [, string $path [, string $domain [, bool $secure [, bool $httponly]]]]) + * Description : Set the session cookie parameters + * Source code : ext/session/session.c + */ + +echo "*** Testing session_set_cookie_params() : variation ***\n"; + +var_dump(ini_get("session.cookie_path")); +var_dump(session_set_cookie_params(3600, "/foo")); +var_dump(ini_get("session.cookie_path")); +var_dump(session_start()); +var_dump(ini_get("session.cookie_path")); +var_dump(session_set_cookie_params(3600, "/blah")); +var_dump(ini_get("session.cookie_path")); +var_dump(session_destroy()); +var_dump(ini_get("session.cookie_path")); +var_dump(session_set_cookie_params(3600, "/guff")); +var_dump(ini_get("session.cookie_path")); + +echo "Done"; +ob_end_flush(); +?> +--EXPECTF-- +*** Testing session_set_cookie_params() : variation *** +string(5) "/path" +NULL +string(4) "/foo" +bool(true) +string(4) "/foo" +NULL +string(5) "/blah" +bool(true) +string(5) "/blah" +NULL +string(5) "/guff" +Done + diff --git a/ext/session/tests/session_set_cookie_params_variation3.phpt b/ext/session/tests/session_set_cookie_params_variation3.phpt new file mode 100644 index 000000000..5e8f0ff57 --- /dev/null +++ b/ext/session/tests/session_set_cookie_params_variation3.phpt @@ -0,0 +1,49 @@ +--TEST-- +Test session_set_cookie_params() function : variation +--INI-- +session.cookie_domain=foo +--SKIPIF-- +<?php include('skipif.inc'); ?> +--FILE-- +<?php + +ob_start(); + +/* + * Prototype : void session_set_cookie_params(int $lifetime [, string $path [, string $domain [, bool $secure [, bool $httponly]]]]) + * Description : Set the session cookie parameters + * Source code : ext/session/session.c + */ + +echo "*** Testing session_set_cookie_params() : variation ***\n"; + +var_dump(ini_get("session.cookie_domain")); +var_dump(session_set_cookie_params(3600, "/path", "blah")); +var_dump(ini_get("session.cookie_domain")); +var_dump(session_start()); +var_dump(ini_get("session.cookie_domain")); +var_dump(session_set_cookie_params(3600, "/path", "guff")); +var_dump(ini_get("session.cookie_domain")); +var_dump(session_destroy()); +var_dump(ini_get("session.cookie_domain")); +var_dump(session_set_cookie_params(3600, "/path", "foo")); +var_dump(ini_get("session.cookie_domain")); + +echo "Done"; +ob_end_flush(); +?> +--EXPECTF-- +*** Testing session_set_cookie_params() : variation *** +string(3) "foo" +NULL +string(4) "blah" +bool(true) +string(4) "blah" +NULL +string(4) "guff" +bool(true) +string(4) "guff" +NULL +string(3) "foo" +Done + diff --git a/ext/session/tests/session_set_cookie_params_variation4.phpt b/ext/session/tests/session_set_cookie_params_variation4.phpt new file mode 100644 index 000000000..7b825968f --- /dev/null +++ b/ext/session/tests/session_set_cookie_params_variation4.phpt @@ -0,0 +1,49 @@ +--TEST-- +Test session_set_cookie_params() function : variation +--INI-- +session.cookie_secure=TRUE +--SKIPIF-- +<?php include('skipif.inc'); ?> +--FILE-- +<?php + +ob_start(); + +/* + * Prototype : void session_set_cookie_params(int $lifetime [, string $path [, string $domain [, bool $secure [, bool $httponly]]]]) + * Description : Set the session cookie parameters + * Source code : ext/session/session.c + */ + +echo "*** Testing session_set_cookie_params() : variation ***\n"; + +var_dump(ini_get("session.cookie_secure")); +var_dump(session_set_cookie_params(3600, "/path", "blah", FALSE)); +var_dump(ini_get("session.cookie_secure")); +var_dump(session_start()); +var_dump(ini_get("session.cookie_secure")); +var_dump(session_set_cookie_params(3600, "/path", "blah", TRUE)); +var_dump(ini_get("session.cookie_secure")); +var_dump(session_destroy()); +var_dump(ini_get("session.cookie_secure")); +var_dump(session_set_cookie_params(3600, "/path", "blah", FALSE)); +var_dump(ini_get("session.cookie_secure")); + +echo "Done"; +ob_end_flush(); +?> +--EXPECTF-- +*** Testing session_set_cookie_params() : variation *** +string(1) "1" +NULL +string(1) "0" +bool(true) +string(1) "0" +NULL +string(1) "1" +bool(true) +string(1) "1" +NULL +string(1) "0" +Done + diff --git a/ext/session/tests/session_set_cookie_params_variation5.phpt b/ext/session/tests/session_set_cookie_params_variation5.phpt new file mode 100644 index 000000000..29559f7fd --- /dev/null +++ b/ext/session/tests/session_set_cookie_params_variation5.phpt @@ -0,0 +1,49 @@ +--TEST-- +Test session_set_cookie_params() function : variation +--INI-- +session.cookie_httponly=TRUE +--SKIPIF-- +<?php include('skipif.inc'); ?> +--FILE-- +<?php + +ob_start(); + +/* + * Prototype : void session_set_cookie_params(int $lifetime [, string $path [, string $domain [, bool $secure [, bool $httponly]]]]) + * Description : Set the session cookie parameters + * Source code : ext/session/session.c + */ + +echo "*** Testing session_set_cookie_params() : variation ***\n"; + +var_dump(ini_get("session.cookie_httponly")); +var_dump(session_set_cookie_params(3600, "/path", "blah", FALSE, FALSE)); +var_dump(ini_get("session.cookie_httponly")); +var_dump(session_start()); +var_dump(ini_get("session.cookie_httponly")); +var_dump(session_set_cookie_params(3600, "/path", "blah", FALSE, TRUE)); +var_dump(ini_get("session.cookie_httponly")); +var_dump(session_destroy()); +var_dump(ini_get("session.cookie_httponly")); +var_dump(session_set_cookie_params(3600, "/path", "blah", FALSE, FALSE)); +var_dump(ini_get("session.cookie_httponly")); + +echo "Done"; +ob_end_flush(); +?> +--EXPECTF-- +*** Testing session_set_cookie_params() : variation *** +string(1) "1" +NULL +string(1) "0" +bool(true) +string(1) "0" +NULL +string(1) "1" +bool(true) +string(1) "1" +NULL +string(1) "0" +Done + diff --git a/ext/session/tests/session_set_save_handler_basic.phpt b/ext/session/tests/session_set_save_handler_basic.phpt new file mode 100644 index 000000000..3897ba9a9 --- /dev/null +++ b/ext/session/tests/session_set_save_handler_basic.phpt @@ -0,0 +1,95 @@ +--TEST-- +Test session_set_save_handler() function : basic functionality +--INI-- +session.save_path= +session.name=PHPSESSID +--SKIPIF-- +<?php include('skipif.inc'); ?> +--FILE-- +<?php + +ob_start(); + +/* + * Prototype : bool session_set_save_handler(callback $open, callback $close, callback $read, callback $write, callback $destroy, callback $gc) + * Description : Sets user-level session storage functions + * Source code : ext/session/session.c + */ + +echo "*** Testing session_set_save_handler() : basic functionality ***\n"; + +require_once "save_handler.inc"; +var_dump(session_module_name()); +var_dump(session_module_name(FALSE)); +var_dump(session_module_name("blah")); +var_dump(session_module_name("foo")); + +$path = dirname(__FILE__); +session_save_path($path); +session_set_save_handler("open", "close", "read", "write", "destroy", "gc"); + +session_start(); +$_SESSION["Blah"] = "Hello World!"; +$_SESSION["Foo"] = FALSE; +$_SESSION["Guff"] = 1234567890; +var_dump($_SESSION); + +session_write_close(); +session_unset(); +var_dump($_SESSION); + +echo "Starting session again..!\n"; +session_id($session_id); +session_set_save_handler("open", "close", "read", "write", "destroy", "gc"); +session_start(); +var_dump($_SESSION); +session_write_close(); + +ob_end_flush(); +?> +--EXPECTF-- +*** Testing session_set_save_handler() : basic functionality *** + +string(%d) "%s" + +Warning: session_module_name(): Cannot find named PHP session module () in %s on line %d +bool(false) + +Warning: session_module_name(): Cannot find named PHP session module (blah) in %s on line %d +bool(false) + +Warning: session_module_name(): Cannot find named PHP session module (foo) in %s on line %d +bool(false) +Open [%s,PHPSESSID] +Read [%s,%s] +array(3) { + ["Blah"]=> + string(12) "Hello World!" + ["Foo"]=> + bool(false) + ["Guff"]=> + int(1234567890) +} +Write [%s,%s,Blah|s:12:"Hello World!";Foo|b:0;Guff|i:1234567890;] +Close [%s,PHPSESSID] +array(3) { + ["Blah"]=> + string(12) "Hello World!" + ["Foo"]=> + bool(false) + ["Guff"]=> + int(1234567890) +} +Starting session again..! +Open [%s,PHPSESSID] +Read [%s,%s] +array(3) { + ["Blah"]=> + string(12) "Hello World!" + ["Foo"]=> + bool(false) + ["Guff"]=> + int(1234567890) +} +Write [%s,%s,Blah|s:12:"Hello World!";Foo|b:0;Guff|i:1234567890;] +Close [%s,PHPSESSID] diff --git a/ext/session/tests/session_set_save_handler_error.phpt b/ext/session/tests/session_set_save_handler_error.phpt new file mode 100644 index 000000000..bf9d25de5 --- /dev/null +++ b/ext/session/tests/session_set_save_handler_error.phpt @@ -0,0 +1,218 @@ +--TEST-- +Test session_set_save_handler() function : error functionality +--SKIPIF-- +<?php include('skipif.inc'); ?> +--FILE-- +<?php + +ob_start(); + +/* + * Prototype : bool session_set_save_handler(callback $open, callback $close, callback $read, callback $write, callback $destroy, callback $gc) + * Description : Sets user-level session storage functions + * Source code : ext/session/session.c + */ + +echo "*** Testing session_set_save_handler() : error functionality ***\n"; + +// Get an unset variable +$unset_var = 10; +unset($unset_var); + +class classA +{ + public function __toString() { + return "Hello World!"; + } +} + +$heredoc = <<<EOT +Hello World! +EOT; + +$fp = fopen(__FILE__, "r"); + +// Unexpected values to be passed as arguments +$inputs = array( + + // Integer data +/*1*/ 0, + 1, + 12345, + -2345, + + // Float data +/*5*/ 10.5, + -10.5, + 12.3456789000e10, + 12.3456789000E-10, + .5, + + // Null data +/*10*/ NULL, + null, + + // Boolean data +/*12*/ true, + false, + TRUE, + FALSE, + + // Empty strings +/*16*/ "", + '', + + // Invalid string data +/*18*/ "Nothing", + 'Nothing', + $heredoc, + + // Object data +/*21*/ new classA(), + + // Undefined data +/*22*/ @$undefined_var, + + // Unset data +/*23*/ @$unset_var, + + // Resource variable +/*24*/ $fp +); + + +$iterator = 1; +foreach($inputs as $input) { + echo "\n-- Iteration $iterator --\n"; + var_dump(session_set_save_handler($input, NULL, NULL, NULL, NULL, NULL)); + $iterator++; +}; + +fclose($fp); +echo "Done"; +ob_end_flush(); +?> +--EXPECTF-- +*** Testing session_set_save_handler() : error functionality *** + +-- Iteration 1 -- + +Warning: session_set_save_handler(): Argument 1 is not a valid callback in %s on line %d +bool(false) + +-- Iteration 2 -- + +Warning: session_set_save_handler(): Argument 1 is not a valid callback in %s on line %d +bool(false) + +-- Iteration 3 -- + +Warning: session_set_save_handler(): Argument 1 is not a valid callback in %s on line %d +bool(false) + +-- Iteration 4 -- + +Warning: session_set_save_handler(): Argument 1 is not a valid callback in %s on line %d +bool(false) + +-- Iteration 5 -- + +Warning: session_set_save_handler(): Argument 1 is not a valid callback in %s on line %d +bool(false) + +-- Iteration 6 -- + +Warning: session_set_save_handler(): Argument 1 is not a valid callback in %s on line %d +bool(false) + +-- Iteration 7 -- + +Warning: session_set_save_handler(): Argument 1 is not a valid callback in %s on line %d +bool(false) + +-- Iteration 8 -- + +Warning: session_set_save_handler(): Argument 1 is not a valid callback in %s on line %d +bool(false) + +-- Iteration 9 -- + +Warning: session_set_save_handler(): Argument 1 is not a valid callback in %s on line %d +bool(false) + +-- Iteration 10 -- + +Warning: session_set_save_handler(): Argument 1 is not a valid callback in %s on line %d +bool(false) + +-- Iteration 11 -- + +Warning: session_set_save_handler(): Argument 1 is not a valid callback in %s on line %d +bool(false) + +-- Iteration 12 -- + +Warning: session_set_save_handler(): Argument 1 is not a valid callback in %s on line %d +bool(false) + +-- Iteration 13 -- + +Warning: session_set_save_handler(): Argument 1 is not a valid callback in %s on line %d +bool(false) + +-- Iteration 14 -- + +Warning: session_set_save_handler(): Argument 1 is not a valid callback in %s on line %d +bool(false) + +-- Iteration 15 -- + +Warning: session_set_save_handler(): Argument 1 is not a valid callback in %s on line %d +bool(false) + +-- Iteration 16 -- + +Warning: session_set_save_handler(): Argument 1 is not a valid callback in %s on line %d +bool(false) + +-- Iteration 17 -- + +Warning: session_set_save_handler(): Argument 1 is not a valid callback in %s on line %d +bool(false) + +-- Iteration 18 -- + +Warning: session_set_save_handler(): Argument 1 is not a valid callback in %s on line %d +bool(false) + +-- Iteration 19 -- + +Warning: session_set_save_handler(): Argument 1 is not a valid callback in %s on line %d +bool(false) + +-- Iteration 20 -- + +Warning: session_set_save_handler(): Argument 1 is not a valid callback in %s on line %d +bool(false) + +-- Iteration 21 -- + +Warning: session_set_save_handler(): Argument 1 is not a valid callback in %s on line %d +bool(false) + +-- Iteration 22 -- + +Warning: session_set_save_handler(): Argument 1 is not a valid callback in %s on line %d +bool(false) + +-- Iteration 23 -- + +Warning: session_set_save_handler(): Argument 1 is not a valid callback in %s on line %d +bool(false) + +-- Iteration 24 -- + +Warning: session_set_save_handler(): Argument 1 is not a valid callback in %s on line %d +bool(false) +Done + diff --git a/ext/session/tests/session_set_save_handler_error2.phpt b/ext/session/tests/session_set_save_handler_error2.phpt new file mode 100644 index 000000000..03ba3b04d --- /dev/null +++ b/ext/session/tests/session_set_save_handler_error2.phpt @@ -0,0 +1,62 @@ +--TEST-- +Test session_set_save_handler() function : error functionality +--SKIPIF-- +<?php include('skipif.inc'); ?> +--FILE-- +<?php + +ob_start(); + +/* + * Prototype : bool session_set_save_handler(callback $open, callback $close, callback $read, callback $write, callback $destroy, callback $gc) + * Description : Sets user-level session storage functions + * Source code : ext/session/session.c + */ + +echo "*** Testing session_set_save_handler() : error functionality ***\n"; + +function open($save_path, $session_name) { return true; } +function close() { return true; } +function read($id) { return false; } +function write($id, $session_data) { } +function destroy($id) { return true; } +function gc($maxlifetime) { return true; } + +session_set_save_handler("open", "close", "read", "write", "destroy", "gc"); + +session_start(); +$_SESSION["Blah"] = "Hello World!"; +$_SESSION["Foo"] = FALSE; +$_SESSION["Guff"] = 1234567890; +var_dump($_SESSION); + +session_write_close(); +var_dump($_SESSION); +session_set_save_handler("open", "close", "read", "write", "destroy", "gc"); +session_start(); +var_dump($_SESSION); +session_destroy(); + +ob_end_flush(); +?> +--EXPECTF-- +*** Testing session_set_save_handler() : error functionality *** +array(3) { + ["Blah"]=> + string(12) "Hello World!" + ["Foo"]=> + bool(false) + ["Guff"]=> + int(1234567890) +} +array(3) { + ["Blah"]=> + string(12) "Hello World!" + ["Foo"]=> + bool(false) + ["Guff"]=> + int(1234567890) +} +array(0) { +} + diff --git a/ext/session/tests/session_set_save_handler_error3.phpt b/ext/session/tests/session_set_save_handler_error3.phpt new file mode 100644 index 000000000..446ef7b75 --- /dev/null +++ b/ext/session/tests/session_set_save_handler_error3.phpt @@ -0,0 +1,43 @@ +--TEST-- +Test session_set_save_handler() function : error functionality +--INI-- +session.save_path= +session.name=PHPSESSID +--SKIPIF-- +<?php include('skipif.inc'); ?> +--FILE-- +<?php + +ob_start(); + +/* + * Prototype : bool session_set_save_handler(callback $open, callback $close, callback $read, callback $write, callback $destroy, callback $gc) + * Description : Sets user-level session storage functions + * Source code : ext/session/session.c + */ + +echo "*** Testing session_set_save_handler() : error functionality ***\n"; +function open($save_path, $session_name) { + throw new Exception("Do something bad..!"); +} + +function close() { return true; } +function read($id) { return false; } +function write($id, $session_data) { } +function destroy($id) { return true; } +function gc($maxlifetime) { return true; } + +session_set_save_handler("open", "close", "read", "write", "destroy", "gc"); +session_start(); +ob_end_flush(); +?> +--EXPECTF-- +*** Testing session_set_save_handler() : error functionality *** + +Fatal error: Uncaught exception 'Exception' with message 'Do something bad..!' in %s:%d +Stack trace: +#0 [internal function]: open('', 'PHPSESSID') +#1 %s(%d): session_start() +#2 {main} + thrown in %s on line %d + diff --git a/ext/session/tests/session_set_save_handler_error4.phpt b/ext/session/tests/session_set_save_handler_error4.phpt new file mode 100644 index 000000000..4debde5b0 --- /dev/null +++ b/ext/session/tests/session_set_save_handler_error4.phpt @@ -0,0 +1,42 @@ +--TEST-- +Test session_set_save_handler() function : error functionality +--SKIPIF-- +<?php include('skipif.inc'); ?> +--FILE-- +<?php + +ob_start(); + +/* + * Prototype : bool session_set_save_handler(callback $open, callback $close, callback $read, callback $write, callback $destroy, callback $gc) + * Description : Sets user-level session storage functions + * Source code : ext/session/session.c + */ + +echo "*** Testing session_set_save_handler() : error functionality ***\n"; + +function callback() { } + +session_set_save_handler("callback", "callback", "callback", "callback", "callback", "callback"); +session_set_save_handler("callback", "echo", "callback", "callback", "callback", "callback"); +session_set_save_handler("callback", "callback", "echo", "callback", "callback", "callback"); +session_set_save_handler("callback", "callback", "callback", "echo", "callback", "callback"); +session_set_save_handler("callback", "callback", "callback", "callback", "echo", "callback"); +session_set_save_handler("callback", "callback", "callback", "callback", "callback", "echo"); +session_set_save_handler("callback", "callback", "callback", "callback", "callback", "callback"); +session_start(); +ob_end_flush(); +?> +--EXPECTF-- +*** Testing session_set_save_handler() : error functionality *** + +Warning: session_set_save_handler(): Argument 2 is not a valid callback in %s on line %d + +Warning: session_set_save_handler(): Argument 3 is not a valid callback in %s on line %d + +Warning: session_set_save_handler(): Argument 4 is not a valid callback in %s on line %d + +Warning: session_set_save_handler(): Argument 5 is not a valid callback in %s on line %d + +Warning: session_set_save_handler(): Argument 6 is not a valid callback in %s on line %d + diff --git a/ext/session/tests/session_set_save_handler_variation1.phpt b/ext/session/tests/session_set_save_handler_variation1.phpt new file mode 100644 index 000000000..fe1d2b0b5 --- /dev/null +++ b/ext/session/tests/session_set_save_handler_variation1.phpt @@ -0,0 +1,40 @@ +--TEST-- +Test session_set_save_handler() function : variation +--SKIPIF-- +<?php include('skipif.inc'); ?> +--FILE-- +<?php + +ob_start(); + +/* + * Prototype : bool session_set_save_handler(callback $open, callback $close, callback $read, callback $write, callback $destroy, callback $gc) + * Description : Sets user-level session storage functions + * Source code : ext/session/session.c + */ + +echo "*** Testing session_set_save_handler() : variation ***\n"; + +var_dump(session_module_name()); +var_dump(session_module_name(FALSE)); +var_dump(session_module_name()); +var_dump(session_module_name("blah")); +var_dump(session_module_name()); +var_dump(session_module_name("files")); +var_dump(session_module_name()); + +ob_end_flush(); +?> +--EXPECTF-- +*** Testing session_set_save_handler() : variation *** +string(%d) "%s" + +Warning: session_module_name(): Cannot find named PHP session module () in %s on line %d +bool(false) +string(%d) "%s" + +Warning: session_module_name(): Cannot find named PHP session module (blah) in %s on line %d +bool(false) +string(%d) "%s" +string(%d) "%s" +string(5) "files" diff --git a/ext/session/tests/session_set_save_handler_variation2.phpt b/ext/session/tests/session_set_save_handler_variation2.phpt new file mode 100644 index 000000000..1c019bb5a --- /dev/null +++ b/ext/session/tests/session_set_save_handler_variation2.phpt @@ -0,0 +1,33 @@ +--TEST-- +Test session_set_save_handler() function : variation +--SKIPIF-- +<?php include('skipif.inc'); ?> +--FILE-- +<?php + +ob_start(); + +/* + * Prototype : bool session_set_save_handler(callback $open, callback $close, callback $read, callback $write, callback $destroy, callback $gc) + * Description : Sets user-level session storage functions + * Source code : ext/session/session.c + */ + +echo "*** Testing session_set_save_handler() : variation ***\n"; + +require_once "save_handler.inc"; +$path = dirname(__FILE__); +session_save_path($path); +var_dump(session_start()); +var_dump(session_set_save_handler("open", "close", "read", "write", "destroy", "gc")); +var_dump(session_destroy()); + +ob_end_flush(); +?> +--EXPECTF-- +*** Testing session_set_save_handler() : variation *** + +bool(true) +bool(false) +bool(true) + diff --git a/ext/session/tests/session_set_save_handler_variation3.phpt b/ext/session/tests/session_set_save_handler_variation3.phpt new file mode 100644 index 000000000..774d0db48 --- /dev/null +++ b/ext/session/tests/session_set_save_handler_variation3.phpt @@ -0,0 +1,33 @@ +--TEST-- +Test session_set_save_handler() function : variation +--SKIPIF-- +<?php include('skipif.inc'); ?> +--INI-- +session.auto_start=1 +--FILE-- +<?php + +ob_start(); + +/* + * Prototype : bool session_set_save_handler(callback $open, callback $close, callback $read, callback $write, callback $destroy, callback $gc) + * Description : Sets user-level session storage functions + * Source code : ext/session/session.c + */ + +echo "*** Testing session_set_save_handler() : variation ***\n"; + +require_once "save_handler.inc"; +$path = dirname(__FILE__); +session_save_path($path); +var_dump(session_set_save_handler("open", "close", "read", "write", "destroy", "gc")); +var_dump(session_destroy()); + +ob_end_flush(); +?> +--EXPECTF-- +*** Testing session_set_save_handler() : variation *** + +bool(false) +bool(true) + diff --git a/ext/session/tests/session_set_save_handler_variation4.phpt b/ext/session/tests/session_set_save_handler_variation4.phpt new file mode 100644 index 000000000..3485f2373 --- /dev/null +++ b/ext/session/tests/session_set_save_handler_variation4.phpt @@ -0,0 +1,83 @@ +--TEST-- +Test session_set_save_handler() function : variation +--SKIPIF-- +<?php include('skipif.inc'); ?> +--INI-- +session.gc_probability=1 +session.gc_divisor=1 +session.gc_maxlifetime=0 +session.save_path= +session.name=PHPSESSID +--FILE-- +<?php + +ob_start(); + +/* + * Prototype : bool session_set_save_handler(callback $open, callback $close, callback $read, callback $write, callback $destroy, callback $gc) + * Description : Sets user-level session storage functions + * Source code : ext/session/session.c + */ + +echo "*** Testing session_set_save_handler() : variation ***\n"; + +function noisy_gc($maxlifetime) { + echo("GC [".$maxlifetime."]\n"); + gc($maxlifetime); +} + +require_once "save_handler.inc"; +$path = dirname(__FILE__); +session_save_path($path); +session_set_save_handler("open", "close", "read", "write", "destroy", "noisy_gc"); + +session_start(); +$_SESSION["Blah"] = "Hello World!"; +$_SESSION["Foo"] = FALSE; +$_SESSION["Guff"] = 1234567890; +var_dump($_SESSION); +$session_id = session_id(); +var_dump(session_write_close()); + +session_set_save_handler("open", "close", "read", "write", "destroy", "noisy_gc"); +session_id($session_id); +session_start(); +var_dump($_SESSION); +var_dump(session_destroy()); + +ob_end_flush(); +?> +--EXPECTF-- +*** Testing session_set_save_handler() : variation *** + +Open [%s,PHPSESSID] +Read [%s,%s] +GC [0] +array(3) { + ["Blah"]=> + string(12) "Hello World!" + ["Foo"]=> + bool(false) + ["Guff"]=> + int(1234567890) +} +Write [%s,%s,Blah|s:12:"Hello World!";Foo|b:0;Guff|i:1234567890;] +Close [%s,PHPSESSID] +NULL +Open [%s,PHPSESSID] +Read [%s,%s] +GC [0] +array(3) { + ["Blah"]=> + string(12) "Hello World!" + ["Foo"]=> + bool(false) + ["Guff"]=> + int(1234567890) +} +Destroy [%s,%s] + +Warning: unlink(%s): No such file or directory in %s on line %d +Close [%s,PHPSESSID] +bool(true) + diff --git a/ext/session/tests/session_start_error.phpt b/ext/session/tests/session_start_error.phpt new file mode 100644 index 000000000..8cbf42c86 --- /dev/null +++ b/ext/session/tests/session_start_error.phpt @@ -0,0 +1,195 @@ +--TEST-- +Test session_start() function : error functionality +--SKIPIF-- +<?php include('skipif.inc'); ?> +--FILE-- +<?php + +ob_start(); + +/* + * Prototype : bool session_start(void) + * Description : Initialize session data + * Source code : ext/session/session.c + */ + +echo "*** Testing session_start() : error functionality ***\n"; + +// Get an unset variable +$unset_var = 10; +unset($unset_var); + +class classA +{ + public function __toString() { + return "Hello World!"; + } +} + +$heredoc = <<<EOT +Hello World! +EOT; + +$fp = fopen(__FILE__, "r"); + +// Unexpected values to be passed as arguments +$inputs = array( + + // Integer data +/*1*/ 0, + 1, + 12345, + -2345, + + // Float data +/*5*/ 10.5, + -10.5, + 12.3456789000e10, + 12.3456789000E-10, + .5, + + // Null data +/*10*/ NULL, + null, + + // Boolean data +/*12*/ true, + false, + TRUE, + FALSE, + + // Empty strings +/*16*/ "", + '', + + // Invalid string data +/*18*/ "Nothing", + 'Nothing', + $heredoc, + + // Object data +/*21*/ new classA(), + + // Undefined data +/*22*/ @$undefined_var, + + // Unset data +/*23*/ @$unset_var, + + // Resource variable +/*24*/ $fp +); + + +$iterator = 1; +foreach($inputs as $input) { + echo "\n-- Iteration $iterator --\n"; + var_dump(session_start($input)); + var_dump(session_destroy()); + $iterator++; +}; + +fclose($fp); +echo "Done"; +ob_end_flush(); +?> +--EXPECTF-- +*** Testing session_start() : error functionality *** + +-- Iteration 1 -- +bool(true) +bool(true) + +-- Iteration 2 -- +bool(true) +bool(true) + +-- Iteration 3 -- +bool(true) +bool(true) + +-- Iteration 4 -- +bool(true) +bool(true) + +-- Iteration 5 -- +bool(true) +bool(true) + +-- Iteration 6 -- +bool(true) +bool(true) + +-- Iteration 7 -- +bool(true) +bool(true) + +-- Iteration 8 -- +bool(true) +bool(true) + +-- Iteration 9 -- +bool(true) +bool(true) + +-- Iteration 10 -- +bool(true) +bool(true) + +-- Iteration 11 -- +bool(true) +bool(true) + +-- Iteration 12 -- +bool(true) +bool(true) + +-- Iteration 13 -- +bool(true) +bool(true) + +-- Iteration 14 -- +bool(true) +bool(true) + +-- Iteration 15 -- +bool(true) +bool(true) + +-- Iteration 16 -- +bool(true) +bool(true) + +-- Iteration 17 -- +bool(true) +bool(true) + +-- Iteration 18 -- +bool(true) +bool(true) + +-- Iteration 19 -- +bool(true) +bool(true) + +-- Iteration 20 -- +bool(true) +bool(true) + +-- Iteration 21 -- +bool(true) +bool(true) + +-- Iteration 22 -- +bool(true) +bool(true) + +-- Iteration 23 -- +bool(true) +bool(true) + +-- Iteration 24 -- +bool(true) +bool(true) +Done + diff --git a/ext/session/tests/session_start_variation1.phpt b/ext/session/tests/session_start_variation1.phpt new file mode 100644 index 000000000..1c8f3eb3b --- /dev/null +++ b/ext/session/tests/session_start_variation1.phpt @@ -0,0 +1,44 @@ +--TEST-- +Test session_start() function : variation +--SKIPIF-- +<?php include('skipif.inc'); ?> +--FILE-- +<?php + +ob_start(); + +/* + * Prototype : bool session_start(void) + * Description : Initialize session data + * Source code : ext/session/session.c + */ + +echo "*** Testing session_start() : variation ***\n"; + +var_dump(session_start()); +var_dump(session_start()); +var_dump(session_start()); +var_dump(session_start()); +var_dump(session_start()); + +session_destroy(); +echo "Done"; +ob_end_flush(); +?> +--EXPECTF-- +*** Testing session_start() : variation *** +bool(true) + +Notice: A session had already been started - ignoring session_start() in %s on line %d +bool(true) + +Notice: A session had already been started - ignoring session_start() in %s on line %d +bool(true) + +Notice: A session had already been started - ignoring session_start() in %s on line %d +bool(true) + +Notice: A session had already been started - ignoring session_start() in %s on line %d +bool(true) +Done + diff --git a/ext/session/tests/session_start_variation2.phpt b/ext/session/tests/session_start_variation2.phpt new file mode 100644 index 000000000..6c9b29e3e --- /dev/null +++ b/ext/session/tests/session_start_variation2.phpt @@ -0,0 +1,45 @@ +--TEST-- +Test session_start() function : variation +--SKIPIF-- +<?php include('skipif.inc'); ?> +--FILE-- +<?php + +ob_start(); + +/* + * Prototype : bool session_start(void) + * Description : Initialize session data + * Source code : ext/session/session.c + */ + +echo "*** Testing session_start() : variation ***\n"; + +var_dump(session_start()); +var_dump(session_destroy()); +var_dump(session_start()); +var_dump(session_destroy()); +var_dump(session_start()); +var_dump(session_destroy()); +var_dump(session_start()); +var_dump(session_destroy()); +var_dump(session_start()); +var_dump(session_destroy()); + +echo "Done"; +ob_end_flush(); +?> +--EXPECTF-- +*** Testing session_start() : variation *** +bool(true) +bool(true) +bool(true) +bool(true) +bool(true) +bool(true) +bool(true) +bool(true) +bool(true) +bool(true) +Done + diff --git a/ext/session/tests/session_start_variation3.phpt b/ext/session/tests/session_start_variation3.phpt new file mode 100644 index 000000000..e87f84bce --- /dev/null +++ b/ext/session/tests/session_start_variation3.phpt @@ -0,0 +1,49 @@ +--TEST-- +Test session_start() function : variation +--SKIPIF-- +<?php include('skipif.inc'); ?> +--FILE-- +<?php + +ob_start(); + +/* + * Prototype : bool session_start(void) + * Description : Initialize session data + * Source code : ext/session/session.c + */ + +echo "*** Testing session_start() : variation ***\n"; + +var_dump(session_start()); +var_dump(session_write_close()); +var_dump(session_start()); +var_dump(session_write_close()); +var_dump(session_start()); +var_dump(session_write_close()); +var_dump(session_start()); +var_dump(session_write_close()); +var_dump(session_start()); +var_dump(session_write_close()); +var_dump(session_destroy()); + +echo "Done"; +ob_end_flush(); +?> +--EXPECTF-- +*** Testing session_start() : variation *** +bool(true) +NULL +bool(true) +NULL +bool(true) +NULL +bool(true) +NULL +bool(true) +NULL + +Warning: session_destroy(): Trying to destroy uninitialized session in %s on line %d +bool(false) +Done + diff --git a/ext/session/tests/session_start_variation4.phpt b/ext/session/tests/session_start_variation4.phpt new file mode 100644 index 000000000..42895493a --- /dev/null +++ b/ext/session/tests/session_start_variation4.phpt @@ -0,0 +1,37 @@ +--TEST-- +Test session_start() function : variation +--SKIPIF-- +<?php include('skipif.inc'); ?> +--FILE-- +<?php + +ob_start(); + +/* + * Prototype : bool session_start(void) + * Description : Initialize session data + * Source code : ext/session/session.c + */ + +echo "*** Testing session_start() : variation ***\n"; + +$_SESSION['blah'] = 'foo'; +var_dump($_SESSION); +session_start(); +var_dump($_SESSION); + +session_destroy(); +echo "Done"; +ob_end_flush(); + +?> +--EXPECTF-- +*** Testing session_start() : variation *** +array(1) { + ["blah"]=> + string(3) "foo" +} +array(0) { +} +Done + diff --git a/ext/session/tests/session_start_variation5.phpt b/ext/session/tests/session_start_variation5.phpt new file mode 100644 index 000000000..4dcafac33 --- /dev/null +++ b/ext/session/tests/session_start_variation5.phpt @@ -0,0 +1,58 @@ +--TEST-- +Test session_start() function : variation +--SKIPIF-- +<?php include('skipif.inc'); ?> +--FILE-- +<?php + +ob_start(); + +/* + * Prototype : bool session_start(void) + * Description : Initialize session data + * Source code : ext/session/session.c + */ + +echo "*** Testing session_start() : variation ***\n"; + +session_start(); + +$_SESSION['colour'] = 'green'; +$_SESSION['animal'] = 'cat'; +$_SESSION['person'] = 'julia'; +$_SESSION['age'] = 6; + +var_dump($_SESSION); +var_dump(session_write_close()); +var_dump($_SESSION); + +session_start(); +session_destroy(); +echo "Done"; +ob_end_flush(); +?> +--EXPECTF-- +*** Testing session_start() : variation *** +array(4) { + ["colour"]=> + string(5) "green" + ["animal"]=> + string(3) "cat" + ["person"]=> + string(5) "julia" + ["age"]=> + int(6) +} +NULL +array(4) { + ["colour"]=> + string(5) "green" + ["animal"]=> + string(3) "cat" + ["person"]=> + string(5) "julia" + ["age"]=> + int(6) +} +Done + diff --git a/ext/session/tests/session_start_variation6.phpt b/ext/session/tests/session_start_variation6.phpt new file mode 100644 index 000000000..378554bbe --- /dev/null +++ b/ext/session/tests/session_start_variation6.phpt @@ -0,0 +1,69 @@ +--TEST-- +Test session_start() function : variation +--SKIPIF-- +<?php include('skipif.inc'); ?> +--FILE-- +<?php + +ob_start(); + +/* + * Prototype : bool session_start(void) + * Description : Initialize session data + * Source code : ext/session/session.c + */ + +echo "*** Testing session_start() : variation ***\n"; + +session_start(); + +$_SESSION['colour'] = 'green'; +$_SESSION['animal'] = 'cat'; +$_SESSION['person'] = 'julia'; +$_SESSION['age'] = 6; + +var_dump($_SESSION); +var_dump(session_write_close()); +var_dump($_SESSION); +session_start(); +var_dump($_SESSION); + +session_destroy(); +echo "Done"; +ob_end_flush(); +?> +--EXPECTF-- +*** Testing session_start() : variation *** +array(4) { + ["colour"]=> + string(5) "green" + ["animal"]=> + string(3) "cat" + ["person"]=> + string(5) "julia" + ["age"]=> + int(6) +} +NULL +array(4) { + ["colour"]=> + string(5) "green" + ["animal"]=> + string(3) "cat" + ["person"]=> + string(5) "julia" + ["age"]=> + int(6) +} +array(4) { + ["colour"]=> + string(5) "green" + ["animal"]=> + string(3) "cat" + ["person"]=> + string(5) "julia" + ["age"]=> + int(6) +} +Done + diff --git a/ext/session/tests/session_start_variation7.phpt b/ext/session/tests/session_start_variation7.phpt new file mode 100644 index 000000000..be079f335 --- /dev/null +++ b/ext/session/tests/session_start_variation7.phpt @@ -0,0 +1,61 @@ +--TEST-- +Test session_start() function : variation +--SKIPIF-- +<?php include('skipif.inc'); ?> +--FILE-- +<?php + +ob_start(); + +/* + * Prototype : bool session_start(void) + * Description : Initialize session data + * Source code : ext/session/session.c + */ + +echo "*** Testing session_start() : variation ***\n"; + +session_start(); + +$_SESSION['colour'] = 'green'; +$_SESSION['animal'] = 'cat'; +$_SESSION['person'] = 'julia'; +$_SESSION['age'] = 6; + +var_dump($_SESSION); +var_dump(session_destroy()); +var_dump($_SESSION); +session_start(); +var_dump($_SESSION); + +session_destroy(); +echo "Done"; +ob_end_flush(); +?> +--EXPECTF-- +*** Testing session_start() : variation *** +array(4) { + ["colour"]=> + string(5) "green" + ["animal"]=> + string(3) "cat" + ["person"]=> + string(5) "julia" + ["age"]=> + int(6) +} +bool(true) +array(4) { + ["colour"]=> + string(5) "green" + ["animal"]=> + string(3) "cat" + ["person"]=> + string(5) "julia" + ["age"]=> + int(6) +} +array(0) { +} +Done + diff --git a/ext/session/tests/session_start_variation8.phpt b/ext/session/tests/session_start_variation8.phpt new file mode 100644 index 000000000..936547527 --- /dev/null +++ b/ext/session/tests/session_start_variation8.phpt @@ -0,0 +1,35 @@ +--TEST-- +Test session_start() function : variation +--SKIPIF-- +<?php include('skipif.inc'); ?> +--FILE-- +<?php + +ob_start(); + +/* + * Prototype : bool session_start(void) + * Description : Initialize session data + * Source code : ext/session/session.c + */ + +echo "*** Testing session_start() : variation ***\n"; + +var_dump(session_id()); +var_dump(session_start()); +var_dump(session_id()); +var_dump(session_destroy()); +var_dump(session_id()); + +echo "Done"; +ob_end_flush(); +?> +--EXPECTF-- +*** Testing session_start() : variation *** +string(0) "" +bool(true) +string(%d) "%s" +bool(true) +string(0) "" +Done + diff --git a/ext/session/tests/session_start_variation9.phpt b/ext/session/tests/session_start_variation9.phpt new file mode 100644 index 000000000..21523e065 --- /dev/null +++ b/ext/session/tests/session_start_variation9.phpt @@ -0,0 +1,39 @@ +--TEST-- +Test session_start() function : variation +--SKIPIF-- +<?php include('skipif.inc'); ?> +--INI-- +session.auto_start=1 +--FILE-- +<?php + +ob_start(); + +/* + * Prototype : bool session_start(void) + * Description : Initialize session data + * Source code : ext/session/session.c + */ + +echo "*** Testing session_start() : variation ***\n"; + +var_dump(session_id()); +var_dump(session_start()); +var_dump(session_id()); +var_dump(session_destroy()); +var_dump(session_id()); + +echo "Done"; +ob_end_flush(); +?> +--EXPECTF-- +*** Testing session_start() : variation *** +string(%d) "%s" + +Notice: A session had already been started - ignoring session_start() in %s on line %d +bool(true) +string(%d) "%s" +bool(true) +string(0) "" +Done + diff --git a/ext/session/tests/session_unregister_basic.phpt b/ext/session/tests/session_unregister_basic.phpt new file mode 100644 index 000000000..8ce512693 --- /dev/null +++ b/ext/session/tests/session_unregister_basic.phpt @@ -0,0 +1,176 @@ +--TEST-- +Test session_unregister() function : basic functionality +--SKIPIF-- +<?php include('skipif.inc'); ?> +--FILE-- +<?php + +ob_start(); + +/* + * Prototype : bool session_unregister(string $name) + * Description : Unregister a global variable from the current session + * Source code : ext/session/session.c + */ + +echo "*** Testing session_unregister() : basic functionality ***\n"; + +// Get an unset variable +$unset_var = 10; +unset($unset_var); + +class classA +{ + public function __toString() { + return "Hello World!"; + } +} + +$heredoc = <<<EOT +Hello World! +EOT; + +$fp = fopen(__FILE__, "r"); + +// Unexpected values to be passed as arguments +$inputs = array( + + // Integer data +/*1*/ 0, + 1, + 12345, + -2345, + + // Float data +/*5*/ 10.5, + -10.5, + 12.3456789000e10, + 12.3456789000E-10, + .5, + + // Null data +/*10*/ NULL, + null, + + // Boolean data +/*12*/ true, + false, + TRUE, + FALSE, + + // Empty strings +/*16*/ "", + '', + + // Invalid string data +/*18*/ "Nothing", + 'Nothing', + $heredoc, + + // Object data +/*21*/ new classA(), + + // Undefined data +/*22*/ @$undefined_var, + + // Unset data +/*23*/ @$unset_var, + + // Resource variable +/*24*/ $fp +); + + +var_dump(session_start()); + +$iterator = 1; +foreach($inputs as $input) { + echo "\n-- Iteration $iterator --\n"; + var_dump(session_unregister($input)); + $iterator++; +}; + +var_dump(session_destroy()); + +fclose($fp); +echo "Done"; +ob_end_flush(); +?> +--EXPECTF-- +*** Testing session_unregister() : basic functionality *** +bool(true) + +-- Iteration 1 -- +bool(true) + +-- Iteration 2 -- +bool(true) + +-- Iteration 3 -- +bool(true) + +-- Iteration 4 -- +bool(true) + +-- Iteration 5 -- +bool(true) + +-- Iteration 6 -- +bool(true) + +-- Iteration 7 -- +bool(true) + +-- Iteration 8 -- +bool(true) + +-- Iteration 9 -- +bool(true) + +-- Iteration 10 -- +bool(true) + +-- Iteration 11 -- +bool(true) + +-- Iteration 12 -- +bool(true) + +-- Iteration 13 -- +bool(true) + +-- Iteration 14 -- +bool(true) + +-- Iteration 15 -- +bool(true) + +-- Iteration 16 -- +bool(true) + +-- Iteration 17 -- +bool(true) + +-- Iteration 18 -- +bool(true) + +-- Iteration 19 -- +bool(true) + +-- Iteration 20 -- +bool(true) + +-- Iteration 21 -- +bool(true) + +-- Iteration 22 -- +bool(true) + +-- Iteration 23 -- +bool(true) + +-- Iteration 24 -- +bool(true) +bool(true) +Done + diff --git a/ext/session/tests/session_unregister_variation1.phpt b/ext/session/tests/session_unregister_variation1.phpt new file mode 100644 index 000000000..f6de13ed9 --- /dev/null +++ b/ext/session/tests/session_unregister_variation1.phpt @@ -0,0 +1,158 @@ +--TEST-- +Test session_unregister() function : variation +--SKIPIF-- +<?php include('skipif.inc'); ?> +--FILE-- +<?php + +ob_start(); + +/* + * Prototype : bool session_unregister(string $name) + * Description : Unregister a global variable from the current session + * Source code : ext/session/session.c + */ + +echo "*** Testing session_unregister() : variation ***\n"; + +// Get an unset variable +$unset_var = 10; +unset($unset_var); + +class classA +{ + public function __toString() { + return "Hello World!"; + } +} + +$heredoc = <<<EOT +Hello World! +EOT; + +$fp = fopen(__FILE__, "r"); + +// Unexpected values to be passed as arguments +$inputs = array( + + // Integer data +/*1*/ 0, + 1, + 12345, + -2345, + + // Float data +/*5*/ 10.5, + -10.5, + 12.3456789000e10, + 12.3456789000E-10, + .5, + + // Null data +/*10*/ NULL, + null, + + // Boolean data +/*12*/ true, + false, + TRUE, + FALSE, + + // Empty strings +/*16*/ "", + '', + + // Invalid string data +/*18*/ "Nothing", + 'Nothing', + $heredoc, + + // Object data +/*21*/ new classA(), + + // Undefined data +/*22*/ @$undefined_var, + + // Unset data +/*23*/ @$unset_var, + + // Resource variable +/*24*/ $fp +); + +var_dump(session_start()); +var_dump($_SESSION); +var_dump(session_register($inputs)); +var_dump($_SESSION); +var_dump(session_destroy()); +var_dump($_SESSION); + +fclose($fp); +echo "Done"; +ob_end_flush(); +?> +--EXPECTF-- +*** Testing session_unregister() : variation *** +bool(true) +array(0) { +} +bool(true) +array(13) { + ["0"]=> + NULL + ["1"]=> + NULL + ["12345"]=> + NULL + ["-2345"]=> + NULL + ["10.5"]=> + NULL + ["-10.5"]=> + NULL + ["123456789000"]=> + NULL + ["1.23456789E-9"]=> + NULL + ["0.5"]=> + NULL + [""]=> + NULL + ["Nothing"]=> + NULL + ["Hello World!"]=> + NULL + ["Resource id #%d"]=> + NULL +} +bool(true) +array(13) { + ["0"]=> + NULL + ["1"]=> + NULL + ["12345"]=> + NULL + ["-2345"]=> + NULL + ["10.5"]=> + NULL + ["-10.5"]=> + NULL + ["123456789000"]=> + NULL + ["1.23456789E-9"]=> + NULL + ["0.5"]=> + NULL + [""]=> + NULL + ["Nothing"]=> + NULL + ["Hello World!"]=> + NULL + ["Resource id #%d"]=> + NULL +} +Done + diff --git a/ext/session/tests/session_unregister_variation2.phpt b/ext/session/tests/session_unregister_variation2.phpt new file mode 100644 index 000000000..cd5778877 --- /dev/null +++ b/ext/session/tests/session_unregister_variation2.phpt @@ -0,0 +1,46 @@ +--TEST-- +Test session_unregister() function : variation +--SKIPIF-- +<?php include('skipif.inc'); ?> +--FILE-- +<?php + +ob_start(); + +/* + * Prototype : bool session_unregister(string $name) + * Description : Unregister a global variable from the current session + * Source code : ext/session/session.c + */ + +echo "*** Testing session_unregister() : variation ***\n"; + +var_dump(session_start()); +var_dump($_SESSION); +$_SESSION["foo"] = "Hello World!"; +var_dump($_SESSION); +var_dump(session_unregister("foo")); +var_dump($_SESSION); +var_dump(session_destroy()); +var_dump($_SESSION); + +echo "Done"; +ob_end_flush(); +?> +--EXPECTF-- +*** Testing session_unregister() : variation *** +bool(true) +array(0) { +} +array(1) { + ["foo"]=> + string(12) "Hello World!" +} +bool(true) +array(0) { +} +bool(true) +array(0) { +} +Done + diff --git a/ext/session/tests/session_unregister_variation3.phpt b/ext/session/tests/session_unregister_variation3.phpt new file mode 100644 index 000000000..97609266d --- /dev/null +++ b/ext/session/tests/session_unregister_variation3.phpt @@ -0,0 +1,47 @@ +--TEST-- +Test session_unregister() function : variation +--SKIPIF-- +<?php include('skipif.inc'); ?> +--FILE-- +<?php + +ob_start(); + +/* + * Prototype : bool session_unregister(string $name) + * Description : Unregister a global variable from the current session + * Source code : ext/session/session.c + */ + +echo "*** Testing session_unregister() : variation ***\n"; + +var_dump(session_start()); +var_dump($_SESSION); +$blah = "Hello World!"; +$_SESSION["foo"] = &$blah; +var_dump($_SESSION); +var_dump(session_unregister("foo")); +var_dump($_SESSION); +var_dump(session_destroy()); +var_dump($_SESSION); + +echo "Done"; +ob_end_flush(); +?> +--EXPECTF-- +*** Testing session_unregister() : variation *** +bool(true) +array(0) { +} +array(1) { + ["foo"]=> + &string(12) "Hello World!" +} +bool(true) +array(0) { +} +bool(true) +array(0) { +} +Done + diff --git a/ext/session/tests/session_unset_basic.phpt b/ext/session/tests/session_unset_basic.phpt new file mode 100644 index 000000000..21b12c4dd --- /dev/null +++ b/ext/session/tests/session_unset_basic.phpt @@ -0,0 +1,43 @@ +--TEST-- +Test session_unset() function : basic functionality +--SKIPIF-- +<?php include('skipif.inc'); ?> +--FILE-- +<?php + +ob_start(); + +/* + * Prototype : void session_unset(void) + * Description : Free all session variables + * Source code : ext/session/session.c + */ + +echo "*** Testing session_unset() : basic functionality ***\n"; + +var_dump(session_start()); +$_SESSION["foo"] = "Hello World!"; +var_dump($_SESSION); +var_dump(session_unset()); +var_dump($_SESSION); +var_dump(session_destroy()); +var_dump($_SESSION); + +echo "Done"; +ob_end_flush(); +?> +--EXPECTF-- +*** Testing session_unset() : basic functionality *** +bool(true) +array(1) { + ["foo"]=> + string(12) "Hello World!" +} +NULL +array(0) { +} +bool(true) +array(0) { +} +Done + diff --git a/ext/session/tests/session_unset_error.phpt b/ext/session/tests/session_unset_error.phpt new file mode 100644 index 000000000..947834550 --- /dev/null +++ b/ext/session/tests/session_unset_error.phpt @@ -0,0 +1,170 @@ +--TEST-- +Test session_unset() function : error functionality +--SKIPIF-- +<?php include('skipif.inc'); ?> +--FILE-- +<?php + +ob_start(); + +/* + * Prototype : void session_unset(void) + * Description : Free all session variables + * Source code : ext/session/session.c + */ + +echo "*** Testing session_unset() : error functionality ***\n"; + +// Get an unset variable +$unset_var = 10; +unset($unset_var); + +class classA +{ + public function __toString() { + return "Hello World!"; + } +} + +$heredoc = <<<EOT +Hello World! +EOT; + +$fp = fopen(__FILE__, "r"); + +// Unexpected values to be passed as arguments +$inputs = array( + + // Integer data +/*1*/ 0, + 1, + 12345, + -2345, + + // Float data +/*5*/ 10.5, + -10.5, + 12.3456789000e10, + 12.3456789000E-10, + .5, + + // Null data +/*10*/ NULL, + null, + + // Boolean data +/*12*/ true, + false, + TRUE, + FALSE, + + // Empty strings +/*16*/ "", + '', + + // Invalid string data +/*18*/ "Nothing", + 'Nothing', + $heredoc, + + // Object data +/*21*/ new classA(), + + // Undefined data +/*22*/ @$undefined_var, + + // Unset data +/*23*/ @$unset_var, + + // Resource variable +/*24*/ $fp +); + + +$iterator = 1; +foreach($inputs as $input) { + echo "\n-- Iteration $iterator --\n"; + var_dump(session_unset($input)); + $iterator++; +}; + +fclose($fp); +echo "Done"; +ob_end_flush(); +?> +--EXPECTF-- +*** Testing session_unset() : error functionality *** + +-- Iteration 1 -- +bool(false) + +-- Iteration 2 -- +bool(false) + +-- Iteration 3 -- +bool(false) + +-- Iteration 4 -- +bool(false) + +-- Iteration 5 -- +bool(false) + +-- Iteration 6 -- +bool(false) + +-- Iteration 7 -- +bool(false) + +-- Iteration 8 -- +bool(false) + +-- Iteration 9 -- +bool(false) + +-- 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) +Done + diff --git a/ext/session/tests/session_unset_variation1.phpt b/ext/session/tests/session_unset_variation1.phpt new file mode 100644 index 000000000..17ab283a1 --- /dev/null +++ b/ext/session/tests/session_unset_variation1.phpt @@ -0,0 +1,48 @@ +--TEST-- +Test session_unset() function : variation +--SKIPIF-- +<?php include('skipif.inc'); ?> +--FILE-- +<?php + +ob_start(); + +/* + * Prototype : void session_unset(void) + * Description : Free all session variables + * Source code : ext/session/session.c + */ + +echo "*** Testing session_unset() : variation ***\n"; + +var_dump(session_unset()); +var_dump(session_start()); +var_dump(session_unset()); +$_SESSION["foo"] = "Hello World!"; +var_dump($_SESSION); +var_dump(session_destroy()); +var_dump(session_unset()); +var_dump($_SESSION); +var_dump(session_unset()); + +echo "Done"; +ob_end_flush(); +?> +--EXPECTF-- +*** Testing session_unset() : variation *** +bool(false) +bool(true) +NULL +array(1) { + ["foo"]=> + string(12) "Hello World!" +} +bool(true) +bool(false) +array(1) { + ["foo"]=> + string(12) "Hello World!" +} +bool(false) +Done + diff --git a/ext/session/tests/session_write_close_basic.phpt b/ext/session/tests/session_write_close_basic.phpt new file mode 100644 index 000000000..0841afed9 --- /dev/null +++ b/ext/session/tests/session_write_close_basic.phpt @@ -0,0 +1,45 @@ +--TEST-- +Test session_write_close() function : basic functionality +--SKIPIF-- +<?php include('skipif.inc'); ?> +--FILE-- +<?php + +ob_start(); + +/* + * Prototype : bool session_write_close(void) + * Description : Write session data and end session + * Source code : ext/session/session.c + */ + +echo "*** Testing session_write_close() : basic functionality ***\n"; + +var_dump(session_start()); +var_dump($_SESSION); +var_dump(session_write_close()); +var_dump($_SESSION); +var_dump(session_start()); +var_dump($_SESSION); +var_dump(session_destroy()); +var_dump($_SESSION); + +echo "Done"; +ob_end_flush(); +?> +--EXPECTF-- +*** Testing session_write_close() : basic functionality *** +bool(true) +array(0) { +} +NULL +array(0) { +} +bool(true) +array(0) { +} +bool(true) +array(0) { +} +Done + diff --git a/ext/session/tests/session_write_close_error.phpt b/ext/session/tests/session_write_close_error.phpt new file mode 100644 index 000000000..cbdb55f26 --- /dev/null +++ b/ext/session/tests/session_write_close_error.phpt @@ -0,0 +1,170 @@ +--TEST-- +Test session_write_close() function : error functionality +--SKIPIF-- +<?php include('skipif.inc'); ?> +--FILE-- +<?php + +ob_start(); + +/* + * Prototype : bool session_write_close(void) + * Description : Write session data and end session + * Source code : ext/session/session.c + */ + +echo "*** Testing session_write_close() : error functionality ***\n"; + +// Get an unset variable +$unset_var = 10; +unset($unset_var); + +class classA +{ + public function __toString() { + return "Hello World!"; + } +} + +$heredoc = <<<EOT +Hello World! +EOT; + +$fp = fopen(__FILE__, "r"); + +// Unexpected values to be passed as arguments +$inputs = array( + + // Integer data +/*1*/ 0, + 1, + 12345, + -2345, + + // Float data +/*5*/ 10.5, + -10.5, + 12.3456789000e10, + 12.3456789000E-10, + .5, + + // Null data +/*10*/ NULL, + null, + + // Boolean data +/*12*/ true, + false, + TRUE, + FALSE, + + // Empty strings +/*16*/ "", + '', + + // Invalid string data +/*18*/ "Nothing", + 'Nothing', + $heredoc, + + // Object data +/*21*/ new classA(), + + // Undefined data +/*22*/ @$undefined_var, + + // Unset data +/*23*/ @$unset_var, + + // Resource variable +/*24*/ $fp +); + + +$iterator = 1; +foreach($inputs as $input) { + echo "\n-- Iteration $iterator --\n"; + var_dump(session_write_close($input)); + $iterator++; +}; + +fclose($fp); +echo "Done"; +ob_end_flush(); +?> +--EXPECTF-- +*** Testing session_write_close() : error functionality *** + +-- Iteration 1 -- +NULL + +-- Iteration 2 -- +NULL + +-- Iteration 3 -- +NULL + +-- Iteration 4 -- +NULL + +-- Iteration 5 -- +NULL + +-- Iteration 6 -- +NULL + +-- Iteration 7 -- +NULL + +-- Iteration 8 -- +NULL + +-- Iteration 9 -- +NULL + +-- Iteration 10 -- +NULL + +-- Iteration 11 -- +NULL + +-- Iteration 12 -- +NULL + +-- Iteration 13 -- +NULL + +-- Iteration 14 -- +NULL + +-- Iteration 15 -- +NULL + +-- Iteration 16 -- +NULL + +-- Iteration 17 -- +NULL + +-- Iteration 18 -- +NULL + +-- Iteration 19 -- +NULL + +-- Iteration 20 -- +NULL + +-- Iteration 21 -- +NULL + +-- Iteration 22 -- +NULL + +-- Iteration 23 -- +NULL + +-- Iteration 24 -- +NULL +Done + diff --git a/ext/session/tests/session_write_close_variation1.phpt b/ext/session/tests/session_write_close_variation1.phpt new file mode 100644 index 000000000..595796dbe --- /dev/null +++ b/ext/session/tests/session_write_close_variation1.phpt @@ -0,0 +1,41 @@ +--TEST-- +Test session_write_close() function : variation +--SKIPIF-- +<?php include('skipif.inc'); ?> +--FILE-- +<?php + +ob_start(); + +/* + * Prototype : bool session_write_close(void) + * Description : Write session data and end session + * Source code : ext/session/session.c + */ + +echo "*** Testing session_write_close() : variation ***\n"; + +var_dump(session_start()); +var_dump(session_write_close()); +var_dump(session_write_close()); +var_dump(session_write_close()); +var_dump(session_write_close()); +var_dump(session_write_close()); +var_dump(session_start()); +var_dump(session_destroy()); + +echo "Done"; +ob_end_flush(); +?> +--EXPECTF-- +*** Testing session_write_close() : variation *** +bool(true) +NULL +NULL +NULL +NULL +NULL +bool(true) +bool(true) +Done + diff --git a/ext/session/tests/session_write_close_variation2.phpt b/ext/session/tests/session_write_close_variation2.phpt new file mode 100644 index 000000000..40871c5cd --- /dev/null +++ b/ext/session/tests/session_write_close_variation2.phpt @@ -0,0 +1,59 @@ +--TEST-- +Test session_write_close() function : variation +--SKIPIF-- +<?php include('skipif.inc'); ?> +--FILE-- +<?php + +ob_start(); + +/* + * Prototype : bool session_write_close(void) + * Description : Write session data and end session + * Source code : ext/session/session.c + */ + +echo "*** Testing session_write_close() : variation ***\n"; + +var_dump(session_start()); +var_dump($_SESSION); +var_dump(session_write_close()); +var_dump($_SESSION); +var_dump(session_start()); +var_dump($_SESSION); +var_dump(session_write_close()); +var_dump($_SESSION); +var_dump(session_start()); +var_dump($_SESSION); +var_dump(session_write_close()); +var_dump($_SESSION); +var_dump(session_start()); +var_dump(session_destroy()); + +echo "Done"; +ob_end_flush(); +?> +--EXPECTF-- +*** Testing session_write_close() : variation *** +bool(true) +array(0) { +} +NULL +array(0) { +} +bool(true) +array(0) { +} +NULL +array(0) { +} +bool(true) +array(0) { +} +NULL +array(0) { +} +bool(true) +bool(true) +Done + diff --git a/ext/session/tests/session_write_close_variation3.phpt b/ext/session/tests/session_write_close_variation3.phpt new file mode 100644 index 000000000..0f8061662 --- /dev/null +++ b/ext/session/tests/session_write_close_variation3.phpt @@ -0,0 +1,39 @@ +--TEST-- +Test session_start() function : variation +--SKIPIF-- +<?php include('skipif.inc'); ?> +--INI-- +session.auto_start=1 +--FILE-- +<?php + +ob_start(); + +/* + * Prototype : bool session_write_close(void) + * Description : Write session data and end session + * Source code : ext/session/session.c + */ + +echo "*** Testing session_write_close() : variation ***\n"; + +var_dump($_SESSION); +var_dump(session_write_close()); +var_dump($_SESSION); +var_dump(session_start()); +var_dump(session_destroy()); + +echo "Done"; +ob_end_flush(); +?> +--EXPECTF-- +*** Testing session_write_close() : variation *** +array(0) { +} +NULL +array(0) { +} +bool(true) +bool(true) +Done + diff --git a/ext/session/tests/session_write_close_variation4.phpt b/ext/session/tests/session_write_close_variation4.phpt new file mode 100644 index 000000000..249c1555c --- /dev/null +++ b/ext/session/tests/session_write_close_variation4.phpt @@ -0,0 +1,55 @@ +--TEST-- +Test session_write_close() function : variation +--SKIPIF-- +<?php include('skipif.inc'); ?> +--FILE-- +<?php + +ob_start(); + +/* + * Prototype : bool session_write_close(void) + * Description : Write session data and end session + * Source code : ext/session/session.c + */ + +echo "*** Testing session_write_close() : variation ***\n"; + +var_dump(session_id("test")); +var_dump(session_start()); +var_dump(session_id()); +var_dump(session_write_close()); +var_dump(session_id()); +var_dump(session_start()); +var_dump(session_id()); +var_dump(session_write_close()); +var_dump(session_id()); +var_dump(session_start()); +var_dump(session_id()); +var_dump(session_write_close()); +var_dump(session_id()); +var_dump(session_start()); +var_dump(session_destroy()); + +echo "Done"; +ob_end_flush(); +?> +--EXPECTF-- +*** Testing session_write_close() : variation *** +string(0) "" +bool(true) +string(4) "test" +NULL +string(4) "test" +bool(true) +string(4) "test" +NULL +string(4) "test" +bool(true) +string(4) "test" +NULL +string(4) "test" +bool(true) +bool(true) +Done + |
