Skip to content

Commit

Permalink
kw_cache - updated storage
Browse files Browse the repository at this point in the history
  • Loading branch information
alex-kalanis committed Aug 3, 2023
1 parent 07494dc commit f04746f
Show file tree
Hide file tree
Showing 6 changed files with 33 additions and 6 deletions.
8 changes: 4 additions & 4 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,14 +7,14 @@
"license": "BSD-3-Clause",
"type": "library",
"require": {
"alex-kalanis/kw_paths": ">=3.0",
"alex-kalanis/kw_semaphore": ">=1.0",
"alex-kalanis/kw_paths": ">=3.0 <4",
"alex-kalanis/kw_semaphore": ">=1.0 <2",
"ext-json": "*",
"php": ">=7.3"
},
"require-dev": {
"alex-kalanis/kw_storage": ">=3.3",
"alex-kalanis/kw_files": ">=3.3",
"alex-kalanis/kw_storage": ">=4.0 <5",
"alex-kalanis/kw_files": ">=3.3 <4",
"friendsofphp/php-cs-fixer": "^3.0",
"phpstan/phpstan": "^1.0",
"phpstan/phpstan-phpunit": "^1.0",
Expand Down
8 changes: 7 additions & 1 deletion php-tests/CacheTests/ACacheTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,13 +8,19 @@
use kalanis\kw_storage\Interfaces\IStorage;
use kalanis\kw_storage\Interfaces\ITarget;
use kalanis\kw_storage\Storage as XStorage;
use kalanis\kw_storage\StorageException;


abstract class ACacheTest extends \CommonTestClass
{
/**
* @param ITarget $mockStorage
* @throws StorageException
* @return IStorage
*/
protected function getStorage(ITarget $mockStorage): IStorage
{
XStorage\Key\DirKey::setDir(__DIR__ . DIRECTORY_SEPARATOR . '..' . DIRECTORY_SEPARATOR . 'data' . DIRECTORY_SEPARATOR);
XStorage\Key\StaticPrefixKey::setPrefix(__DIR__ . DIRECTORY_SEPARATOR . '..' . DIRECTORY_SEPARATOR . 'data' . DIRECTORY_SEPARATOR);
$storage = new XStorage\Factory(new XStorage\Key\Factory(), new XStorage\Target\Factory());
return $storage->getStorage($mockStorage);
}
Expand Down
5 changes: 5 additions & 0 deletions php-tests/CacheTests/SemaphoreTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,13 +9,15 @@
use kalanis\kw_semaphore\Semaphore;
use kalanis\kw_semaphore\SemaphoreException;
use kalanis\kw_storage\Interfaces\IStorage;
use kalanis\kw_storage\StorageException;


class SemaphoreTest extends ACacheTest
{
/**
* @throws CacheException
* @throws SemaphoreException
* @throws StorageException
*/
public function testRun(): void
{
Expand All @@ -39,6 +41,7 @@ public function testRun(): void

/**
* @throws CacheException
* @throws StorageException
*/
public function testNotSet(): void
{
Expand All @@ -54,6 +57,7 @@ public function testNotSet(): void

/**
* @throws CacheException
* @throws StorageException
*/
public function testFailExists(): void
{
Expand All @@ -69,6 +73,7 @@ public function testFailExists(): void
/**
* @throws CacheException
* @throws SemaphoreException
* @throws StorageException
*/
public function testFailSet(): void
{
Expand Down
4 changes: 3 additions & 1 deletion php-tests/StorageTests/AStorageTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,17 +6,19 @@
use kalanis\kw_storage\Interfaces\IStorage;
use kalanis\kw_storage\Interfaces\ITarget;
use kalanis\kw_storage\Storage as XStorage;
use kalanis\kw_storage\StorageException;


abstract class AStorageTest extends \CommonTestClass
{
/**
* @param ITarget|string $mockStorage
* @throws StorageException
* @return IStorage
*/
protected function getStorage($mockStorage): IStorage
{
XStorage\Key\DirKey::setDir(__DIR__ . DIRECTORY_SEPARATOR . '..' . DIRECTORY_SEPARATOR . 'data' . DIRECTORY_SEPARATOR);
XStorage\Key\StaticPrefixKey::setPrefix(__DIR__ . DIRECTORY_SEPARATOR . '..' . DIRECTORY_SEPARATOR . 'data' . DIRECTORY_SEPARATOR);
$storage = new XStorage\Factory(new XStorage\Key\Factory(), new XStorage\Target\Factory());
return $storage->getStorage($mockStorage);
}
Expand Down
6 changes: 6 additions & 0 deletions php-tests/StorageTests/BasicTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,14 @@

use kalanis\kw_cache\CacheException;
use kalanis\kw_cache\Storage;
use kalanis\kw_storage\StorageException;


class BasicTest extends AStorageTest
{
/**
* @throws CacheException
* @throws StorageException
*/
public function testRun(): void
{
Expand All @@ -28,6 +30,7 @@ public function testRun(): void

/**
* @throws CacheException
* @throws StorageException
*/
public function testNotExists(): void
{
Expand All @@ -39,6 +42,7 @@ public function testNotExists(): void

/**
* @throws CacheException
* @throws StorageException
*/
public function testNotSet(): void
{
Expand All @@ -50,6 +54,7 @@ public function testNotSet(): void

/**
* @throws CacheException
* @throws StorageException
*/
public function testNotGet(): void
{
Expand All @@ -61,6 +66,7 @@ public function testNotGet(): void

/**
* @throws CacheException
* @throws StorageException
*/
public function testNotClear(): void
{
Expand Down
8 changes: 8 additions & 0 deletions php-tests/StorageTests/SemaphoreTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,13 +8,15 @@
use kalanis\kw_semaphore\Semaphore;
use kalanis\kw_semaphore\SemaphoreException;
use kalanis\kw_storage\Interfaces\IStorage;
use kalanis\kw_storage\StorageException;


class SemaphoreTest extends AStorageTest
{
/**
* @throws CacheException
* @throws SemaphoreException
* @throws StorageException
*/
public function testRun(): void
{
Expand All @@ -39,6 +41,7 @@ public function testRun(): void

/**
* @throws CacheException
* @throws StorageException
*/
public function testNotSet(): void
{
Expand All @@ -55,6 +58,7 @@ public function testNotSet(): void

/**
* @throws CacheException
* @throws StorageException
*/
public function testFailExists(): void
{
Expand All @@ -68,6 +72,7 @@ public function testFailExists(): void

/**
* @throws CacheException
* @throws StorageException
*/
public function testCannotSet(): void
{
Expand All @@ -80,6 +85,7 @@ public function testCannotSet(): void

/**
* @throws CacheException
* @throws StorageException
*/
public function testNotGet(): void
{
Expand All @@ -92,6 +98,7 @@ public function testNotGet(): void

/**
* @throws CacheException
* @throws StorageException
*/
public function testNotClear(): void
{
Expand All @@ -105,6 +112,7 @@ public function testNotClear(): void
/**
* @throws CacheException
* @throws SemaphoreException
* @throws StorageException
*/
public function testFailSet(): void
{
Expand Down

0 comments on commit f04746f

Please sign in to comment.