mirror of
https://github.com/php-win-ext/php-memcached.git
synced 2026-03-24 00:52:18 +01:00
Fix tests for PHP 7.1 (#297)
invoke_callback_2 fails because of ArgumentCountException (init_cb_arg gets only 2 args) Check number of passed arguments with func_num_args() insteadof checking $args is null session_lock fails because of second warning in 7.1 Skip session_lock.phpt for php < 7.1 and create new testcase for >= 7.1 which tests both warnings. Update .travis.yml, don't allow failures for 7.1 anymore!
This commit is contained in:
@@ -8,8 +8,6 @@ php:
|
||||
|
||||
matrix:
|
||||
fast_finish: true
|
||||
allow_failures:
|
||||
- php: 7.1
|
||||
|
||||
env:
|
||||
- LIBMEMCACHED_VERSION=1.0.18 # Debian Jessie / Ubuntu Xenial
|
||||
@@ -31,6 +29,4 @@ script:
|
||||
|
||||
cache:
|
||||
directories:
|
||||
- $HOME/cache
|
||||
|
||||
|
||||
- $HOME/cache
|
||||
@@ -165,6 +165,7 @@ Tests
|
||||
<file role='test' name='stats.phpt'/>
|
||||
<file role='test' name='default_behavior.phpt'/>
|
||||
<file role='test' name='reset_keyprefix.phpt'/>
|
||||
<file role='test' name='session_lock-php71.phpt'/>
|
||||
</dir>
|
||||
</dir>
|
||||
</contents>
|
||||
|
||||
@@ -18,9 +18,9 @@ function init_cb_fail($m, $id) {
|
||||
echo "configured, should not be called.\n";
|
||||
}
|
||||
|
||||
function init_cb_arg($m, $id, $arg) {
|
||||
function init_cb_arg($m, $id) {
|
||||
var_dump(func_num_args());
|
||||
var_dump($id);
|
||||
var_dump($arg);
|
||||
}
|
||||
|
||||
function init_nopersist_cb($m, $id) {
|
||||
@@ -33,15 +33,14 @@ class Foo extends Memcached {
|
||||
parent::__construct($id, array($this, 'init'));
|
||||
}
|
||||
|
||||
function init($obj, $id, $options) {
|
||||
function init($obj, $id) {
|
||||
var_dump(func_num_args());
|
||||
var_dump($this->isPristine());
|
||||
var_dump($this->isPersistent());
|
||||
var_dump($id);
|
||||
}
|
||||
}
|
||||
|
||||
error_reporting(0);
|
||||
|
||||
echo "cb call\n";
|
||||
$m1 = new Memcached('foo1', 'init_cb');
|
||||
|
||||
@@ -50,7 +49,6 @@ $m1 = new Memcached('foo1', 'init_cb_fail');
|
||||
|
||||
echo "cb arg without arg\n";
|
||||
$m1 = new Memcached('foo3', 'init_cb_arg');
|
||||
echo $php_errormsg, "\n";
|
||||
|
||||
echo "cb arg not persistent\n";
|
||||
$m1 = new Memcached(null, 'init_nopersist_cb');
|
||||
@@ -63,7 +61,7 @@ $m1 = new Foo('baz');
|
||||
|
||||
echo "cb second persistent in object\n";
|
||||
$m1 = new Foo('baz');
|
||||
|
||||
?>
|
||||
--EXPECT--
|
||||
cb call
|
||||
string(9) "Memcached"
|
||||
@@ -71,17 +69,18 @@ bool(true)
|
||||
string(4) "foo1"
|
||||
cb not run
|
||||
cb arg without arg
|
||||
int(2)
|
||||
string(4) "foo3"
|
||||
NULL
|
||||
|
||||
cb arg not persistent
|
||||
bool(false)
|
||||
NULL
|
||||
cb in object
|
||||
int(2)
|
||||
bool(true)
|
||||
bool(false)
|
||||
NULL
|
||||
cb persistent in object
|
||||
int(2)
|
||||
bool(true)
|
||||
bool(true)
|
||||
string(3) "baz"
|
||||
|
||||
62
tests/session_lock-php71.phpt
Normal file
62
tests/session_lock-php71.phpt
Normal file
@@ -0,0 +1,62 @@
|
||||
--TEST--
|
||||
Session lock
|
||||
--SKIPIF--
|
||||
<?php
|
||||
include dirname(__FILE__) . "/skipif.inc";
|
||||
if (!Memcached::HAVE_SESSION) print "skip";
|
||||
|
||||
if (PHP_VERSION_ID < 70100) print "skip";
|
||||
?>
|
||||
--INI--
|
||||
memcached.sess_locking = true
|
||||
memcached.sess_lock_wait_min = 500
|
||||
memcached.sess_lock_wait_max = 1000
|
||||
memcached.sess_lock_retries = 3
|
||||
memcached.sess_prefix = "memc.test."
|
||||
|
||||
session.save_handler = memcached
|
||||
|
||||
--FILE--
|
||||
<?php
|
||||
|
||||
include dirname (__FILE__) . '/config.inc';
|
||||
|
||||
$m = new Memcached();
|
||||
$m->addServer(MEMC_SERVER_HOST, MEMC_SERVER_PORT);
|
||||
|
||||
ob_start();
|
||||
ini_set ('session.save_path', MEMC_SERVER_HOST . ':' . MEMC_SERVER_PORT);
|
||||
|
||||
session_start();
|
||||
$session_id = session_id();
|
||||
|
||||
$_SESSION["test"] = "hello";
|
||||
session_write_close();
|
||||
|
||||
session_start();
|
||||
var_dump ($m->get ('memc.test.' . session_id()));
|
||||
var_dump ($m->get ('memc.test.lock.' . session_id()));
|
||||
session_write_close();
|
||||
var_dump ($m->get ('memc.test.lock.' . session_id()));
|
||||
|
||||
// Test lock min / max
|
||||
$m->set ('memc.test.lock.' . $session_id, '1');
|
||||
|
||||
$time_start = microtime(true);
|
||||
session_start();
|
||||
$time = microtime(true) - $time_start;
|
||||
|
||||
if (round ($time, 1) != 2.5) {
|
||||
echo "Waited longer than expected: $time" . PHP_EOL;
|
||||
}
|
||||
echo "OK";
|
||||
|
||||
--EXPECTF--
|
||||
string(17) "test|s:5:"hello";"
|
||||
string(1) "1"
|
||||
bool(false)
|
||||
|
||||
Warning: session_start(): Unable to clear session lock record in %s on line %d
|
||||
|
||||
Warning: session_start(): Failed to read session data: memcached (path: 127.0.0.1:11211) in %s on line %d
|
||||
OK
|
||||
@@ -4,6 +4,8 @@ Session lock
|
||||
<?php
|
||||
include dirname(__FILE__) . "/skipif.inc";
|
||||
if (!Memcached::HAVE_SESSION) print "skip";
|
||||
|
||||
if (PHP_VERSION_ID >= 70100) print "skip";
|
||||
?>
|
||||
--INI--
|
||||
memcached.sess_locking = true
|
||||
|
||||
Reference in New Issue
Block a user