Skip to content

Commit

Permalink
Move working tests up a folder (#503)
Browse files Browse the repository at this point in the history
Tests in the experimental/ folder were not executed on CI. The ones that work move up, the few
that remain in experimental/ need further investigation to get working or remove.
  • Loading branch information
xPaw authored Apr 27, 2023
1 parent 5833590 commit 7348cc1
Show file tree
Hide file tree
Showing 35 changed files with 190 additions and 150 deletions.
6 changes: 3 additions & 3 deletions tests/experimental/add_bykey.phpt → tests/add_bykey.phpt
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
--TEST--
Memcached::addByKey()
--SKIPIF--
<?php include dirname(dirname(__FILE__)) . "/skipif.inc";?>
<?php include "skipif.inc";?>
--FILE--
<?php
include dirname(dirname(__FILE__)) . '/config.inc';
include dirname(__FILE__) . '/config.inc';
$m = memc_get_instance ();

$m->delete('foo');
Expand All @@ -15,7 +15,7 @@ echo $m->getResultMessage(), "\n";
var_dump($m->addByKey('foo', '', 1, 10));
echo $m->getResultMessage(), "\n";
// This is OK for the binary protocol
$rv = $m->addByKey('foo', ' asd åäö', 1, 1);
$rv = $m->addByKey('foo', ' asd åäö', 1, 1);
if ($m->getOption(Memcached::OPT_BINARY_PROTOCOL)) {
if ($rv !== true and $m->getResultCode() !== Memcached::RES_SUCCESS) {
var_dump($rv);
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
--TEST--
Memcached::addServer() unix doamin socket
--SKIPIF--
<?php include dirname(dirname(__FILE__)) . "/skipif.inc";?>
<?php include "skipif.inc";?>
--CLEAN--
<?php
unlink('/tmp/memc_test_unix_socket');
Expand Down
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
--TEST--
Memcached::appendByKey()
--SKIPIF--
<?php include dirname(dirname(__FILE__)) . "/skipif.inc";?>
<?php include "skipif.inc";?>
--FILE--
<?php
include dirname(dirname(__FILE__)) . '/config.inc';
include dirname(__FILE__) . '/config.inc';
$m = memc_get_instance ();
$m->setOption(Memcached::OPT_COMPRESSION, false);

Expand Down
4 changes: 2 additions & 2 deletions tests/experimental/cas_bykey.phpt → tests/cas_bykey.phpt
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
--TEST--
Memcached::casByKey()
--SKIPIF--
<?php include dirname(dirname(__FILE__)) . "/skipif.inc";?>
<?php include "skipif.inc";?>
--FILE--
<?php
include dirname(dirname(__FILE__)) . '/config.inc';
include dirname(__FILE__) . '/config.inc';
$m = memc_get_instance ();

$m->delete('cas_test');
Expand Down
Original file line number Diff line number Diff line change
@@ -1,17 +1,17 @@
--TEST--
Memcached::cas() with strange key
--SKIPIF--
<?php include dirname(dirname(__FILE__)) . "/skipif.inc";?>
<?php include "skipif.inc";?>
--FILE--
<?php
include dirname(dirname(__FILE__)) . '/config.inc';
include dirname(__FILE__) . '/config.inc';
$m = memc_get_instance ();

error_reporting(0);
var_dump($m->cas(0, '', true, 10));
echo $m->getResultMessage(), "\n";

var_dump($m->cas(0, ' äö jas kjjhask d ', true, 10)); # no spaces allowed
var_dump($m->cas(0, ' äö jas kjjhask d ', true, 10)); # no spaces allowed
echo $m->getResultMessage(), "\n";

--EXPECTF--
Expand Down
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
--TEST--
Memcached::deleteByKey()
--SKIPIF--
<?php include dirname(dirname(__FILE__)) . "/skipif.inc";?>
<?php include "skipif.inc";?>
--FILE--
<?php
include dirname(dirname(__FILE__)) . '/config.inc';
include dirname(__FILE__) . '/config.inc';
$m = memc_get_instance ();

$m->setByKey('keffe', 'eisaleeoo', "foo");
Expand All @@ -21,7 +21,7 @@ var_dump($m->deleteByKey('keffe', ''));
echo $m->getResultMessage(), "\n";
var_dump($m->deleteByKey('', 'keffe'));
echo $m->getResultMessage(), "\n";
var_dump($m->deleteByKey('keffe', 'äöåasäö åaösdäf asdf')); # no spaces allowed
var_dump($m->deleteByKey('keffe', 'äöåasäö åaösdäf asdf')); # no spaces allowed
echo $m->getResultMessage(), "\n";
--EXPECTF--
string(3) "foo"
Expand Down
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
--TEST--
Delete multi with integer keys
--SKIPIF--
<?php include dirname(dirname(__FILE__)) . "/skipif.inc";?>
<?php include "skipif.inc";?>
--FILE--
<?php
include dirname(dirname(__FILE__)) . '/config.inc';
include dirname(__FILE__) . '/config.inc';
$m = memc_get_instance ();

$data = array(
Expand Down
70 changes: 0 additions & 70 deletions tests/experimental/get_bykey_cas.phpt

This file was deleted.

4 changes: 2 additions & 2 deletions tests/experimental/fetch.phpt → tests/fetch.phpt
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
--TEST--
Memcached getDelayed() and fetch() with and without cas
--SKIPIF--
<?php include dirname(dirname(__FILE__)) . "/skipif.inc";?>
<?php include "skipif.inc";?>
--FILE--
<?php

Expand Down Expand Up @@ -33,7 +33,7 @@ function simple_compare(array $data, array $actual, $has_cas) {
}


include dirname(dirname(__FILE__)) . '/config.inc';
include dirname(__FILE__) . '/config.inc';
$m = memc_get_instance ();

$data = array(
Expand Down
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
--TEST--
Memcached::fetch() with bad unserialize
--SKIPIF--
<?php include dirname(dirname(__FILE__)) . "/skipif.inc";?>
<?php include "skipif.inc";?>
--FILE--
<?php
include dirname(dirname(__FILE__)) . '/config.inc';
include dirname(__FILE__) . '/config.inc';
$m = memc_get_instance ();

class Foo implements Serializable {
Expand All @@ -31,6 +31,17 @@ class Foo implements Serializable {
public function unserialize($str) {
throw new Exception("123456");
}

public function __serialize() {
if ($this->serialize_throws) {
throw new Exception("1234");
}
return ["1234"];
}

public function __unserialize($str) {
throw new Exception("123456");
}
}

$data = new Foo();
Expand Down
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
--TEST--
Memcached::fetch() with bad unserialize
--SKIPIF--
<?php include dirname(dirname(__FILE__)) . "/skipif.inc";?>
<?php include "skipif.inc";?>
--FILE--
<?php
include dirname(dirname(__FILE__)) . '/config.inc';
include dirname(__FILE__) . '/config.inc';
$m = memc_get_instance ();

class Foo implements Serializable {
Expand All @@ -31,6 +31,17 @@ class Foo implements Serializable {
public function unserialize($str) {
throw new Exception("123456");
}

public function __serialize() {
if ($this->serialize_throws) {
throw new Exception("1234");
}
return ["1234"];
}

public function __unserialize($str) {
throw new Exception("123456");
}
}

$data = new Foo();
Expand Down
6 changes: 3 additions & 3 deletions tests/experimental/get.phpt → tests/get.phpt
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
--TEST--
Memcached::get()
--SKIPIF--
<?php include dirname(dirname(__FILE__)) . "/skipif.inc";?>
<?php include "skipif.inc";?>
--FILE--
<?php
include dirname(dirname(__FILE__)) . '/config.inc';
include dirname(__FILE__) . '/config.inc';
$m = memc_get_instance ();

$m->delete('foo');
Expand All @@ -20,7 +20,7 @@ var_dump($m->get('foo'));
echo $m->getResultMessage(), "\n";

$m->delete('foo');
var_dump($m->get(' ä foo jkh a s åäö'));
var_dump($m->get(' ä foo jkh a s åäö'));
echo $m->getResultMessage(), "\n";
--EXPECT--
bool(false)
Expand Down
6 changes: 3 additions & 3 deletions tests/experimental/get_bykey.phpt → tests/get_bykey.phpt
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
--TEST--
Memcached::getByKey()
--SKIPIF--
<?php include dirname(dirname(__FILE__)) . "/skipif.inc";?>
<?php include "skipif.inc";?>
--FILE--
<?php
include dirname(dirname(__FILE__)) . '/config.inc';
include dirname(__FILE__) . '/config.inc';
$m = memc_get_instance ();

$m->set('foo', 1, 10);
Expand All @@ -20,7 +20,7 @@ var_dump($m->getByKey('foo', 'bar'));
echo $m->getResultMessage(), "\n";

$m->delete('foo');
var_dump($m->getByKey(' ä foo jkh a s åäö', 'foo'));
var_dump($m->getByKey(' ä foo jkh a s åäö', 'foo'));
echo $m->getResultMessage(), "\n";

--EXPECTF--
Expand Down
61 changes: 61 additions & 0 deletions tests/get_bykey_cas.phpt
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
--TEST--
Memcached::getByKey() with CAS
--SKIPIF--
<?php include "skipif.inc";?>
--FILE--
<?php
include dirname(__FILE__) . '/config.inc';
$m = memc_get_instance ();

function the_callback(Memcached $memc, $key, &$value) {
echo "called\n";
$value = "1234";
return true;
}

$m->set('foo', 1, 10);

$v = $m->getByKey('foo', 'foo', null, Memcached::GET_EXTENDED);
var_dump($v['value']);
var_dump($v['cas']);
echo $m->getResultMessage(), "\n";

$v = $m->getByKey('', 'foo', null, Memcached::GET_EXTENDED);
var_dump($v['value']);
var_dump($v['cas']);
echo $m->getResultMessage(), "\n";

$m->set('bar', "asdf", 10);

$v = $m->getByKey('foo', 'bar', null, Memcached::GET_EXTENDED);
var_dump($v['value']);
var_dump($v['cas']);
echo $m->getResultMessage(), "\n";

$m->delete('foo');
var_dump($m->getByKey(' ä foo jkh a s åäö', 'foo', null, Memcached::GET_EXTENDED));
echo $m->getResultMessage(), "\n";

var_dump($m->getByKey(' ä foo jkh a s åäö', '', null, Memcached::GET_EXTENDED));
echo $m->getResultMessage(), "\n";

$m->delete('foo');
var_dump($m->getByKey('foo', 'foo', 'the_callback', Memcached::GET_EXTENDED));
var_dump($m->getByKey('foo', 'foo'));
--EXPECTF--
int(1)
int(%d)
SUCCESS
int(1)
int(%d)
SUCCESS
string(4) "asdf"
int(%d)
SUCCESS
bool(false)
NOT FOUND
bool(false)
A BAD KEY WAS PROVIDED/CHARACTERS OUT OF RANGE
called
bool(false)
bool(false)
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
--TEST--
Memcached::getDelayedByKey() with bad server
--SKIPIF--
<?php include dirname(dirname(__FILE__)) . "/skipif.inc";?>
<?php include "skipif.inc";?>
--FILE--
<?php
$m = new Memcached();
Expand Down
Loading

0 comments on commit 7348cc1

Please sign in to comment.