Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
39 changes: 19 additions & 20 deletions bin/ci/run_tests.php
Original file line number Diff line number Diff line change
@@ -1,72 +1,71 @@
<?php
/**
*
* This file is part of Phpfastcache.
*
* @license MIT License (MIT)
*
* For full copyright and license information, please see the docs/CREDITS.txt and LICENCE files.
*
* @author Georges.L (Geolim4) <contact@geolim4.com>
* @author Contributors https://github.com/PHPSocialNetwork/phpfastcache/graphs/contributors
*/
declare(strict_types=1);
require __DIR__ . '/../../vendor/autoload.php';

define('PFC_TEST_DIR', \realpath(__DIR__ . DIRECTORY_SEPARATOR . '..' . DIRECTORY_SEPARATOR . '..' . DIRECTORY_SEPARATOR . 'tests'));
define('PFC_TEST_DIR', realpath(__DIR__ . \DIRECTORY_SEPARATOR . '..' . \DIRECTORY_SEPARATOR . '..' . \DIRECTORY_SEPARATOR . 'tests'));

$timestamp = microtime(true);
$climate = new League\CLImate\CLImate;
$climate = new League\CLImate\CLImate();
$climate->forceAnsiOn();
$phpBinPath = 'php ';
$status = 0;
$dir = __DIR__;
$projectDir = dirname($dir, 2);
$driver = $argv[ 1 ] ?? 'Files';
$driver = $argv[1] ?? 'Files';
$phpBinPath = $_SERVER['PHP_BIN_PATH'] ?? 'php';
$failedTests = [];
$skippedTests = [];

/**
* @param string $pattern
* @param int $flags
*
* @return array
*/
$globCallback = static function (string $pattern, int $flags = 0) use (&$globCallback): array {
$files = \glob($pattern, $flags);
$files = glob($pattern, $flags);
$subFiles = [];

foreach (\glob(\dirname($pattern) . '/*', GLOB_ONLYDIR | GLOB_NOSORT) as $dir) {
$subFiles[] = $globCallback($dir . '/' . \basename($pattern), $flags);
foreach (glob(dirname($pattern) . '/*', \GLOB_ONLYDIR | \GLOB_NOSORT) as $dir) {
$subFiles[] = $globCallback($dir . '/' . basename($pattern), $flags);
}

return \array_merge(...$subFiles, ...[$files]);
return array_merge(...$subFiles, ...[$files]);
};

foreach ($globCallback(PFC_TEST_DIR . DIRECTORY_SEPARATOR . '*.test.php') as $filename) {
foreach ($globCallback(PFC_TEST_DIR . \DIRECTORY_SEPARATOR . '*.test.php') as $filename) {
$climate->backgroundLightYellow()->blue()->out('---');
$command = "{$phpBinPath} -f {$filename} {$driver}";
$shortCommand = str_replace(dirname(PFC_TEST_DIR), '~', $command);

$climate->out("<yellow>phpfastcache@unit-tests</yellow> <blue>{$projectDir}</blue> <green>#</green> <red>$shortCommand</red>");

\exec($command, $output, $return_var);
exec($command, $output, $return_var);
$climate->out('=====================================');
$climate->out(\implode("\n", $output));
$climate->out(implode("\n", $output));
$climate->out('=====================================');
if ($return_var === 0) {
$climate->green("Test finished successfully");
} elseif ($return_var === 2) {
$climate->yellow("Test skipped due to unmeet dependencies");
if (0 === $return_var) {
$climate->green('Test finished successfully');
} elseif (2 === $return_var) {
$climate->yellow('Test skipped due to unmeet dependencies');
$skippedTests[] = basename($filename);
} else {
$climate->red("Test finished with a least one error");
$climate->red('Test finished with a least one error');
$status = 1;
$failedTests[] = basename($filename);
}

$climate->out('');
/**
/*
* Reset $output to prevent override effects
*/
unset($output);
Expand All @@ -79,11 +78,11 @@
$climate->backgroundGreen()->white()->flank('[OK] The build has passed successfully', '#')->out('');
} else {
$climate->backgroundRed()->white()->flank('[KO] The build has failed miserably', '~')->out('');
$climate->red()->out('[TESTS FAILED] ' . PHP_EOL . '- '. implode(PHP_EOL . '- ', $failedTests))->out('');
$climate->red()->out('[TESTS FAILED] ' . \PHP_EOL . '- ' . implode(\PHP_EOL . '- ', $failedTests))->out('');
}

if ($skippedTests) {
$climate->yellow()->out('[TESTS SKIPPED] ' . PHP_EOL . '- '. implode(PHP_EOL . '- ', $skippedTests))->out('');
$climate->yellow()->out('[TESTS SKIPPED] ' . \PHP_EOL . '- ' . implode(\PHP_EOL . '- ', $skippedTests))->out('');
}

exit($status);
111 changes: 49 additions & 62 deletions bin/stubs/leveldb/stub.php
Original file line number Diff line number Diff line change
@@ -1,53 +1,48 @@
<?php

declare(strict_types=1);

/**
* LevelDB extension stub file for code completion purposes
*
* WARNING: Do not include this file
*
*/

define("LEVELDB_NO_COMPRESSION", 0);

define("LEVELDB_SNAPPY_COMPRESSION", 1);
define('LEVELDB_NO_COMPRESSION', 0);

define('LEVELDB_SNAPPY_COMPRESSION', 1);

class LevelDB
{

/**
* @param string $name Path to database
* @param array $options
* @param array $read_options
* @param array $write_options
*/
public function __construct(
$name, array $options = [
'create_if_missing' => true, // if the specified database does not exist will create a new one
'error_if_exists' => false, // if the opened database exists will throw exception
'paranoid_checks' => false,
'block_cache_size' => 8 * (2 << 20),
'write_buffer_size' => 4 << 20,
'block_size' => 4096,
'max_open_files' => 1000,
'block_restart_interval' => 16,
'compression' => LEVELDB_SNAPPY_COMPRESSION,
'comparator' => null, // any callable parameter return 0, -1, 1
], array $read_options = [
'verify_check_sum' => false,
//may be set to true to force checksum verification of all data that is read from the file system on behalf of a particular read. By default, no such verification is done.
'fill_cache' => true,
//When performing a bulk read, the application may set this to false to disable the caching so that the data processed by the bulk read does not end up displacing most of the cached contents.
], array $write_options = [
//Only one element named sync in the write option array. By default, each write to leveldb is asynchronous.
'sync' => false,
]
'create_if_missing' => true, // if the specified database does not exist will create a new one
'error_if_exists' => false, // if the opened database exists will throw exception
'paranoid_checks' => false,
'block_cache_size' => 8 * (2 << 20),
'write_buffer_size' => 4 << 20,
'block_size' => 4096,
'max_open_files' => 1000,
'block_restart_interval' => 16,
'compression' => LEVELDB_SNAPPY_COMPRESSION,
'comparator' => null, // any callable parameter return 0, -1, 1
], array $read_options = [
'verify_check_sum' => false,
//may be set to true to force checksum verification of all data that is read from the file system on behalf of a particular read. By default, no such verification is done.
'fill_cache' => true,
//When performing a bulk read, the application may set this to false to disable the caching so that the data processed by the bulk read does not end up displacing most of the cached contents.
], array $write_options = [
//Only one element named sync in the write option array. By default, each write to leveldb is asynchronous.
'sync' => false,
]
) {
}

/**
* @param string $key
* @param array $read_options
*
* @return string|bool
*/
Expand All @@ -60,24 +55,21 @@ public function get($key, array $read_options = [])
*
* @param string $key
* @param string $value
* @param array $write_options
*/
public function set($key, $value, array $write_options = [])
public function set($key, $value, array $write_options = []): void
{
}

/**
* @param string $key
* @param string $value
* @param array $write_options
*/
public function put($key, $value, array $write_options = [])
public function put($key, $value, array $write_options = []): void
{
}

/**
* @param string $key
* @param array $write_options
*
* @return bool
*/
Expand All @@ -87,11 +79,8 @@ public function delete($key, array $write_options = [])

/**
* Executes all of the operations added in the write batch.
*
* @param LevelDBWriteBatch $batch
* @param array $write_options
*/
public function write(LevelDBWriteBatch $batch, array $write_options = [])
public function write(LevelDBWriteBatch $batch, array $write_options = []): void
{
}

Expand All @@ -109,11 +98,11 @@ public function getProperty($name)
{
}

public function getApproximateSizes($start, $limit)
public function getApproximateSizes($start, $limit): void
{
}

public function compactRange($start, $limit)
public function compactRange($start, $limit): void
{
}

Expand All @@ -125,8 +114,6 @@ public function close()
}

/**
* @param array $options
*
* @return LevelDBIterator
*/
public function getIterator(array $options = [])
Expand All @@ -141,67 +128,69 @@ public function getSnapshot()
}

/**
* @param mixed $name
*
* @return bool
*/
static public function destroy($name, array $options = [])
public static function destroy($name, array $options = [])
{
}

/**
* @param mixed $name
*
* @return bool
*/
static public function repair($name, array $options = [])
public static function repair($name, array $options = [])
{
}
}

class LevelDBIterator implements Iterator
{

public function __construct(LevelDB $db, array $read_options = [])
{
}

public function valid()
public function valid(): void
{
}

public function rewind()
public function rewind(): void
{
}

public function last()
public function last(): void
{
}

public function seek($key)
public function seek($key): void
{
}

public function next()
public function next(): void
{
}

public function prev()
public function prev(): void
{
}

public function key()
public function key(): void
{
}

public function current()
public function current(): void
{
}

public function getError()
public function getError(): void
{
}

public function destroy()
public function destroy(): void
{
}

}

class LevelDBWriteBatch
Expand All @@ -210,19 +199,19 @@ public function __construct($name, array $options = [], array $read_options = []
{
}

public function set($key, $value, array $write_options = [])
public function set($key, $value, array $write_options = []): void
{
}

public function put($key, $value, array $write_options = [])
public function put($key, $value, array $write_options = []): void
{
}

public function delete($key, array $write_options = [])
public function delete($key, array $write_options = []): void
{
}

public function clear()
public function clear(): void
{
}
}
Expand All @@ -233,13 +222,11 @@ public function __construct(LevelDB $db)
{
}

public function release()
public function release(): void
{
}

}

class LevelDBException extends Exception
{

}
Loading