| Current File : /home/mmdealscpanel/yummmdeals.com/alt-php83-pecl-leveldb_0.3.0-1.el8.tar |
tests/010-compression.phpt 0000644 00000001102 15041322103 0011423 0 ustar 00 --TEST--
leveldb - compression
--SKIPIF--
<?php include 'skipif.inc'; ?>
--FILE--
<?php
$leveldb_path = dirname(__FILE__) . '/leveldb-compression.test-db';
$db = new LevelDB($leveldb_path, array('compression' => 33));
unset($db);
$db = new LevelDB($leveldb_path, array('compression' => LEVELDB_SNAPPY_COMPRESSION));
$db->set("key", "value");
?>
==DONE==
--CLEAN--
<?php
$leveldb_path = dirname(__FILE__) . '/leveldb-compression.test-db';
LevelDB::destroy($leveldb_path);
?>
--EXPECTF--
Warning: LevelDB::__construct(): Unsupported compression type in %s on line %s
==DONE==
tests/019-null-comparator.phpt 0000644 00000001043 15041322103 0012216 0 ustar 00 --TEST--
leveldb - NULL comparator should not throw exception
--DESCRIPTION--
NULL is the default value of comparator open options
open with null shouldn't throw exception
--SKIPIF--
<?php include 'skipif.inc'; ?>
--FILE--
<?php
$leveldb_path = dirname(__FILE__) . '/null-comparator.test-db';
$db = new LevelDB($leveldb_path, array('comparator' => NULL));
?>
Should no exception
==DONE==
--CLEAN--
<?php
$leveldb_path = dirname(__FILE__) . '/null-comparator.test-db';
LevelDB::destroy($leveldb_path);
?>
--EXPECT--
Should no exception
==DONE==
tests/018-snapshot.phpt 0000644 00000002600 15041322103 0010735 0 ustar 00 --TEST--
leveldb - snapshot
--SKIPIF--
<?php include 'skipif.inc'; ?>
--FILE--
<?php
$leveldb_path = dirname(__FILE__) . '/leveldb-snapshot.test-db';
@unlink($leveldb_path);
$db = new LevelDB($leveldb_path);
$db->put("key1", "value1");
$db->put("key2", "value2");
$snapshot = new LevelDBSnapshot($db);
$db->put("key3", "value3");
try {
$it = new LevelDBIterator($db, array('snapshot' => ''));
} catch(LevelDBException $e) {
var_dump($e->getMessage());
}
$it = $db->getIterator(array('snapshot' => $snapshot));
foreach($it as $k => $v) {
echo "$k => $v\n";
}
var_dump($db->get("key3", array('snapshot' => $snapshot)));
var_dump($db->get("key3"));
echo "*** Release snapshot x1 ***\n";
$snapshot->release();
echo "*** Release snapshot x2 ***\n";
$snapshot->release();
echo "*** Try to use released snapshot ***\n";
try {
$it = new LevelDBIterator($db, array('snapshot' => $snapshot));
} catch(LevelDBException $e) {
var_dump($e->getMessage());
}
?>
==DONE==
--CLEAN--
<?php
$leveldb_path = dirname(__FILE__) . '/leveldb-snapshot.test-db';
LevelDB::destroy($leveldb_path);
?>
--EXPECTF--
string(69) "Invalid snapshot parameter, it must be an instance of LevelDBSnapshot"
key1 => value1
key2 => value2
bool(false)
string(6) "value3"
*** Release snapshot x1 ***
*** Release snapshot x2 ***
*** Try to use released snapshot ***
string(48) "Invalid snapshot parameter, it has been released"
==DONE==
tests/011-getApproximateSizes.phpt 0000644 00000001533 15041322103 0013102 0 ustar 00 --TEST--
leveldb - getApproximateSizes
--SKIPIF--
<?php include 'skipif.inc'; ?>
--FILE--
<?php
$leveldb_path = dirname(__FILE__) . '/leveldb-getApproximateSizes.test-db';
$db = new LevelDB($leveldb_path);
for($i=0; $i < 99999; ++$i) {
$db->set("b{$i}", "value");
}
unset($db);
$db = new LevelDB($leveldb_path);
var_dump($db->getApproximateSizes(array("A", "B", 3), array("b0", "Z")));
var_dump($db->getApproximateSizes(array(), array()));
var_dump($db->getApproximateSizes(array("a", "b"), array("c", "Z")));
?>
==DONE==
--CLEAN--
<?php
$leveldb_path = dirname(__FILE__) . '/leveldb-getApproximateSizes.test-db';
LevelDB::destroy($leveldb_path);
?>
--EXPECTF--
Warning: LevelDB::getApproximateSizes(): The num of start keys and limit keys didn't match in %s on line %d
bool(false)
array(0) {
}
array(2) {
[0]=>
int(%d)
[1]=>
int(%d)
}
==DONE==
tests/008-options.phpt 0000644 00000001651 15041322103 0010575 0 ustar 00 --TEST--
leveldb - options open options
--SKIPIF--
<?php include 'skipif.inc'; ?>
--FILE--
<?php
$leveldb_path = dirname(__FILE__) . '/leveldb_options.test-db';
try {
$db = new LevelDB($leveldb_path, array("create_if_missing" => false));
} catch(LevelDBException $e) {
echo $e->getMessage() . "\n";
}
try {
$db = new LevelDB($leveldb_path, array("max_open_files" => 10));
$db->set("key", "value");
var_dump($db->get("key"));
} catch(LevelDBException $e) {
echo $e->getMessage() . "\n";
}
unset($db);
try {
$db = new LevelDB($leveldb_path, array("error_if_exists" => true));
} catch(LevelDBException $e) {
echo $e->getMessage() . "\n";
}
?>
==DONE==
--CLEAN--
<?php
$leveldb_path = dirname(__FILE__) . '/leveldb_options.test-db';
LevelDB::destroy($leveldb_path);
?>
--EXPECTF--
Invalid argument: %s: does not exist (create_if_missing is false)
string(5) "value"
Invalid argument: %s: exists (error_if_exists is true)
==DONE==
tests/003-openbasedir.phpt 0000644 00000001236 15041322104 0011370 0 ustar 00 --TEST--
leveldb - open base dir
--INI--
open_basedir=.
--SKIPIF--
<?php include 'skipif.inc'; ?>
--FILE--
<?php
$cwd = getcwd();
$path = $cwd . '/../leveldb_openbasedir.test-db';
$db = new LevelDB($path);
LevelDB::destroy($path);
LevelDB::repair($path);
?>
--EXPECTF--
Warning: LevelDB::__construct(): open_basedir restriction in effect. File(%s) is not within the allowed path(s): (%s) in %s on line %d
Warning: LevelDB::destroy(): open_basedir restriction in effect. File(%s) is not within the allowed path(s): (%s) in %s on line %d
Warning: LevelDB::repair(): open_basedir restriction in effect. File(%s) is not within the allowed path(s): (%s) in %s on line %d
tests/014-iterator-destroy.phpt 0000644 00000001043 15041322104 0012413 0 ustar 00 --TEST--
leveldb - iterator destroy
--SKIPIF--
<?php include 'skipif.inc'; ?>
--FILE--
<?php
$leveldb_path = dirname(__FILE__) . '/leveldb_iterator_destroy.test-db';
$db = new LevelDB($leveldb_path);
$db->set("key", "value");
$it = new LevelDBIterator($db);
$it->destroy();
try {
$it->next();
} catch(LevelDBException $e) {
echo $e->getMessage() . "\n";
}
?>
==DONE==
--CLEAN--
<?php
$leveldb_path = dirname(__FILE__) . '/leveldb_iterator_destroy.test-db';
LevelDB::destroy($leveldb_path);
?>
--EXPECTF--
Iterator has been destroyed
==DONE==
tests/015-double-iterator.phpt 0000644 00000001000 15041322104 0012166 0 ustar 00 --TEST--
leveldb - Fixed bug segfault when double construct iterator
--SKIPIF--
<?php include 'skipif.inc'; ?>
--FILE--
<?php
$leveldb_path = dirname(__FILE__) . '/leveldb_iterator_double_construct.test-db';
$db = new LevelDB($leveldb_path);
$it1 = new LevelDBIterator($db);
$it2 = new LevelDBIterator($db);
$it1->destroy();
$it2->destroy();
?>
==DONE==
--CLEAN--
<?php
$leveldb_path = dirname(__FILE__) . '/leveldb_iterator_double_construct.test-db';
LevelDB::destroy($leveldb_path);
?>
--EXPECTF--
==DONE==
tests/012-getProperty.phpt 0000644 00000001763 15041322104 0011426 0 ustar 00 --TEST--
leveldb - getProperty
--SKIPIF--
<?php include 'skipif.inc'; ?>
--FILE--
<?php
$leveldb_path = dirname(__FILE__) . '/leveldb-getProperty.test-db';
$db = new LevelDB($leveldb_path);
for($i=0; $i < 99999; ++$i) {
$db->set("b{$i}", "value{$i}");
}
$stats = $db->getProperty('leveldb.stats');
var_dump($stats !== false);
var_dump(strlen($stats) > 1);
var_dump($db->getProperty('leveldb.num-files-at-level1'));
var_dump($db->getProperty('leveldb.num-files-at-level2'));
var_dump($db->getProperty('leveldb.num-files-at-level3'));
$sstables = $db->getProperty('leveldb.sstables');
var_dump($sstables !== false);
var_dump(strlen($sstables) > 1);
var_dump($db->getProperty('leveldb.anything'));
var_dump($db->getProperty('anythingelse'));
?>
==DONE==
--CLEAN--
<?php
$leveldb_path = dirname(__FILE__) . '/leveldb-getProperty.test-db';
LevelDB::destroy($leveldb_path);
?>
--EXPECTF--
bool(true)
bool(true)
string(1) "%d"
string(1) "%d"
string(1) "%d"
bool(true)
bool(true)
bool(false)
bool(false)
==DONE==
tests/009-comparator.phpt 0000644 00000003711 15041322104 0011252 0 ustar 00 --TEST--
leveldb - custom comparator
--SKIPIF--
<?php include 'skipif.inc'; ?>
--FILE--
<?php
$leveldb_path = dirname(__FILE__) . '/leveldb-comparator.test-db';
echo "*** could not use invalid custom comparator ***\n";
try {
$db = new LevelDB($leveldb_path, array('comparator' => 'invaid_func'));
} catch(LevelDBException $e) {
echo $e->getMessage() . "\n";
}
echo "*** valid custom comparator ***\n";
$db = new LevelDB($leveldb_path, array('comparator' => 'custom_comparator'));
$values = array(3, 1, 4, 6, 2, 5);
foreach($values as $v) {
$db->set($v, $v);
}
$it = new LevelDBIterator($db);
foreach($it as $v) {
echo "$v\n";
}
unset($it);
unset($db);
echo "*** custom comparator can only open with the same comparator again ***\n";
try {
$db = new LevelDB($leveldb_path);
} catch(LevelDBException $e) {
echo $e->getMessage() . "\n";
}
$db = new LevelDB($leveldb_path, array('comparator' => 'custom_comparator'));
var_dump($db->get(1) == 1);
unset($db);
echo "*** custom comparator which throw exception ***\n";
$db = new LevelDB($leveldb_path, array('comparator' => array('CustomFunc', 'willException')));
try {
$db->set("Hi", "guys");
var_dump($db->get("Hi"));
} catch(Exception $e) {
echo $e->getMessage() . "\n";
}
// reverse DESC
function custom_comparator($a, $b) {
if ($a == $b) {
return 0;
}
return ($a > $b) ? -1 : 1;
}
class CustomFunc {
public static function willException($a, $b) {
throw new Exception("Oops!");
}
}
?>
==DONE==
--CLEAN--
<?php
$leveldb_path = dirname(__FILE__) . '/leveldb-comparator.test-db';
LevelDB::destroy($leveldb_path);
?>
--EXPECTF--
*** could not use invalid custom comparator ***
Invalid open option: comparator, invaid_func() is not callable
*** valid custom comparator ***
6
5
4
3
2
1
*** custom comparator can only open with the same comparator again ***
Invalid argument: php_leveldb.custom_comparator%s leveldb.BytewiseComparator
bool(true)
*** custom comparator which throw exception ***
Oops!
==DONE==
tests/skipif.inc 0000644 00000000132 15041322104 0007652 0 ustar 00 <?php
if (!extension_loaded('leveldb')) die("skip leveldb extension not available\n");
?>