Skip to content

Fix tests for PHP 7.1 #297

New issue

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

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

Already on GitHub? Sign in to your account

Merged
merged 4 commits into from
Jan 20, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 1 addition & 5 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,6 @@ php:

matrix:
fast_finish: true
allow_failures:
- php: 7.1

env:
- LIBMEMCACHED_VERSION=1.0.18 # Debian Jessie / Ubuntu Xenial
Expand All @@ -31,6 +29,4 @@ script:

cache:
directories:
- $HOME/cache


- $HOME/cache
1 change: 1 addition & 0 deletions package.xml
Original file line number Diff line number Diff line change
Expand Up @@ -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>
Expand Down
17 changes: 8 additions & 9 deletions tests/invoke_callback_2.phpt
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand All @@ -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');

Expand All @@ -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');
Expand All @@ -63,25 +61,26 @@ $m1 = new Foo('baz');

echo "cb second persistent in object\n";
$m1 = new Foo('baz');

?>
--EXPECT--
cb call
string(9) "Memcached"
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"
Expand Down
62 changes: 62 additions & 0 deletions tests/session_lock-php71.phpt
Original file line number Diff line number Diff line change
@@ -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
2 changes: 2 additions & 0 deletions tests/session_lock.phpt
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down