Skip to content
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
12 changes: 5 additions & 7 deletions .horde.yml
Original file line number Diff line number Diff line change
Expand Up @@ -33,13 +33,11 @@ dependencies:
horde/vfs: ^3
predis/predis: ^1.1
dev:
composer:
phpunit/phpunit: ^12
friendsofphp/php-cs-fixer: ^3
phpstan/phpstan: ^2
composer: {}
autoload-dev:
psr-4:
Horde\HashTable\Test\Unit\: test/unit
Horde\HashTable\Test\Memcache\: test/memcache
Horde\HashTable\Test\Redis\: test/redis
Horde\HashTable\Test\Lib\Unit\: test/lib/Unit
Horde\HashTable\Test\Lib\Integration\: test/lib/Integration
Horde\HashTable\Test\Src\Unit\: test/src/Unit
Horde\HashTable\Test\Src\Integration\: test/src/Integration
vendor: horde
13 changes: 5 additions & 8 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -17,11 +17,7 @@
"php": "^7.4 || ^8",
"horde/exception": "^3 || dev-FRAMEWORK_6_0"
},
"require-dev": {
"phpunit/phpunit": "^12",
"friendsofphp/php-cs-fixer": "^3",
"phpstan/phpstan": "^2"
},
"require-dev": {},
"suggest": {
"horde/log": "^3 || dev-FRAMEWORK_6_0",
"horde/memcache": "^3 || dev-FRAMEWORK_6_0",
Expand All @@ -38,9 +34,10 @@
},
"autoload-dev": {
"psr-4": {
"Horde\\HashTable\\Test\\Unit\\": "test/unit",
"Horde\\HashTable\\Test\\Memcache\\": "test/memcache",
"Horde\\HashTable\\Test\\Redis\\": "test/redis"
"Horde\\HashTable\\Test\\Lib\\Unit\\": "test/lib/Unit",
"Horde\\HashTable\\Test\\Lib\\Integration\\": "test/lib/Integration",
"Horde\\HashTable\\Test\\Src\\Unit\\": "test/src/Unit",
"Horde\\HashTable\\Test\\Src\\Integration\\": "test/src/Integration"
}
},
"config": {
Expand Down
9 changes: 2 additions & 7 deletions phpunit.xml.dist
Original file line number Diff line number Diff line change
Expand Up @@ -14,17 +14,12 @@
colors="true">
<testsuites>
<testsuite name="unit">
<directory>test/unit</directory>
<directory>test/src/Unit</directory>
<directory>test/lib/Unit</directory>
</testsuite>
<testsuite name="integration">
<directory>test/src/Integration</directory>
</testsuite>
<testsuite name="memcache">
<directory>test/memcache</directory>
</testsuite>
<testsuite name="redis">
<directory>test/redis</directory>
<directory>test/lib/Integration</directory>
</testsuite>
</testsuites>

Expand Down
61 changes: 61 additions & 0 deletions test/lib/Integration/MemcacheTest.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
<?php

declare(strict_types=1);

/**
* Copyright 2015-2026 Horde LLC (http://www.horde.org/)
*
* See the enclosed file LICENSE for license information (LGPL). If you
* did not receive this file, see http://www.horde.org/licenses/lgpl21.
*
* @author Jan Schneider <jan@horde.org>
* @category Horde
* @license http://www.horde.org/licenses/lgpl21 LGPL 2.1
* @package HashTable
* @subpackage UnitTests
*/

namespace Horde\HashTable\Test\Lib\Integration;

use Horde\HashTable\Test\Lib\Unit\TestBase;
use Horde_HashTable_Memcache;
use Horde_Memcache;
use PHPUnit\Framework\Attributes\CoversNothing;
use PHPUnit\Framework\Attributes\Group;

/**
* Tests for the legacy HashTable memcache storage driver (lib/).
*
* @author Jan Schneider <jan@horde.org>
* @category Horde
* @copyright 2015-2026 Horde LLC
* @license http://www.horde.org/licenses/lgpl21 LGPL 2.1
* @package HashTable
* @subpackage UnitTests
*/
#[CoversNothing]
#[Group('integration')]
class MemcacheTest extends TestBase
{
public static function setUpBeforeClass(): void
{
if ((!extension_loaded('memcache') && !extension_loaded('memcached'))) {
self::$_skip = 'memcache/memcached extension not available.';
return;
}

$config = self::getConfig('HASHTABLE_MEMCACHE_TEST_CONFIG', __DIR__ . '/..');
if (!$config || !isset($config['hashtable']['memcache'])) {
self::$_skip = 'Memcache configuration not available.';
return;
}

$memcache = new Horde_Memcache(
array_merge(
$config['hashtable']['memcache'],
['prefix' => 'horde_hashtable_memcachetest']
)
);
self::$_driver = new Horde_HashTable_Memcache(['memcache' => $memcache]);
}
}
56 changes: 56 additions & 0 deletions test/lib/Integration/PredisTest.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
<?php

declare(strict_types=1);

/**
* Copyright 2015-2026 Horde LLC (http://www.horde.org/)
*
* See the enclosed file LICENSE for license information (LGPL). If you
* did not receive this file, see http://www.horde.org/licenses/lgpl21.
*
* @author Jan Schneider <jan@horde.org>
* @category Horde
* @license http://www.horde.org/licenses/lgpl21 LGPL 2.1
* @package HashTable
* @subpackage UnitTests
*/

namespace Horde\HashTable\Test\Lib\Integration;

use Horde\HashTable\Test\Lib\Unit\TestBase;
use Horde_HashTable_Predis;
use PHPUnit\Framework\Attributes\CoversNothing;
use PHPUnit\Framework\Attributes\Group;
use Predis\Client;

/**
* Tests for the legacy HashTable Predis storage driver (lib/).
*
* @author Jan Schneider <jan@horde.org>
* @category Horde
* @copyright 2015-2026 Horde LLC
* @license http://www.horde.org/licenses/lgpl21 LGPL 2.1
* @package HashTable
* @subpackage UnitTests
*/
#[CoversNothing]
#[Group('integration')]
class PredisTest extends TestBase
{
public static function setUpBeforeClass(): void
{
if (!class_exists(Client::class)) {
self::$_skip = 'predis/predis not installed';
return;
}

$config = self::getConfig('HASHTABLE_PREDIS_TEST_CONFIG', __DIR__ . '/..');
if (!$config || !isset($config['hashtable']['predis'])) {
self::$_skip = 'Predis configuration not available.';
return;
}

$predis = new Client($config['hashtable']['predis']);
self::$_driver = new Horde_HashTable_Predis(['predis' => $predis]);
}
}
File renamed without changes.
13 changes: 8 additions & 5 deletions test/unit/MemoryTest.php → test/lib/Unit/MemoryTest.php
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
<?php

declare(strict_types=1);

/**
* Copyright 2013-2017 Horde LLC (http://www.horde.org/)
* Copyright 2013-2026 Horde LLC (http://www.horde.org/)
*
* See the enclosed file LICENSE for license information (LGPL). If you
* did not receive this file, see http://www.horde.org/licenses/lgpl21.
Expand All @@ -13,21 +15,22 @@
* @subpackage UnitTests
*/

namespace Horde\HashTable\Test\Unit;
namespace Horde\HashTable\Test\Lib\Unit;

use Horde_HashTable_Memory;
use PHPUnit\Framework\Attributes\CoversNothing;

/**
* Tests for the HashTable memory storage driver.
* Tests for the legacy HashTable memory storage driver (lib/).
*
* @author Michael Slusarz <slusarz@horde.org>
* @category Horde
* @copyright 2013-2016 Horde LLC
* @copyright 2013-2026 Horde LLC
* @license http://www.horde.org/licenses/lgpl21 LGPL 2.1
* @package HashTable
* @subpackage UnitTests
* @coversNothing
*/
#[CoversNothing]
class MemoryTest extends TestBase
{
public static function setUpBeforeClass(): void
Expand Down
41 changes: 32 additions & 9 deletions test/unit/TestBase.php → test/lib/Unit/TestBase.php
Original file line number Diff line number Diff line change
@@ -1,30 +1,31 @@
<?php

declare(strict_types=1);

/**
* Copyright 2013-2017 Horde LLC (http://www.horde.org/)
* Copyright 2013-2026 Horde LLC (http://www.horde.org/)
*
* See the enclosed file LICENSE for license information (LGPL). If you
* did not receive this file, see http://www.horde.org/licenses/lgpl21.
*
* @category Horde
* @copyright 2013 Horde LLC
* @copyright 2013-2026 Horde LLC
* @license http://www.horde.org/licenses/lgpl21 LGPL 2.1
* @package HashTable
* @subpackage UnitTests
*/

namespace Horde\HashTable\Test\Unit;
namespace Horde\HashTable\Test\Lib\Unit;

use PHPUnit\Framework\TestCase as TestCase;
use PHPUnit\Framework\Attribute\Depends;
use PHPUnit\Framework\Attributes\Depends;
use PHPUnit\Framework\TestCase;

/**
* Tests for the HashTable storage drivers.
* Base test class for legacy HashTable lib/ storage drivers.
*
* @author Michael Slusarz <slusarz@horde.org>
* @category Horde
* @copyright 2013 Horde LLC
* @ignore
* @copyright 2013-2026 Horde LLC
* @license http://www.horde.org/licenses/lgpl21 LGPL 2.1
* @package HashTable
* @subpackage UnitTests
Expand All @@ -42,6 +43,29 @@ public function setUp(): void
}
}

/**
* Load test configuration from environment variable or conf.php file.
*/
protected static function getConfig(string $env, ?string $path = null): ?array
{
$conf = [];
$config = getenv($env);
if ($config) {
$json = json_decode($config, true);
if ($json) {
return $json;
}
}

$configFile = ($path ?? __DIR__) . '/conf.php';
if (file_exists($configFile)) {
require $configFile;
return $conf;
}

return null;
}

public static function tearDownAfterClass(): void
{
if (self::$_driver) {
Expand Down Expand Up @@ -99,5 +123,4 @@ public function testDelete()
$this->assertTrue(self::$_driver->delete('foo3'));
$this->assertTrue(self::$_driver->delete('foo4'));
}

}
51 changes: 0 additions & 51 deletions test/memcache/MemcacheTest.php

This file was deleted.

45 changes: 0 additions & 45 deletions test/redis/PredisTest.php

This file was deleted.

Loading
Loading