Skip to content
Open
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
2 changes: 1 addition & 1 deletion .github/scripts/random-tests-config.txt
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
API
AutoReview
Autoloader
# Cache
Cache
CLI
Commands
Config
Expand Down
2 changes: 1 addition & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
"psr/log": "^3.0"
},
"require-dev": {
"boundwize/structarmed": "0.14.15",
"boundwize/structarmed": "0.14.16",
"codeigniter/phpstan-codeigniter": "^2.1",
"fakerphp/faker": "^1.24",
"kint-php/kint": "^6.1",
Expand Down
26 changes: 12 additions & 14 deletions tests/system/Cache/Handlers/ApcuHandlerTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -27,30 +27,28 @@
#[RequiresPhpExtension('apcu')]
final class ApcuHandlerTest extends AbstractHandlerTestCase
{
/**
* @return list<string>
*/
private static function getKeyArray(): array
{
return [
self::$key1,
self::$key2,
self::$key3,
];
}

protected function setUp(): void
{
parent::setUp();

if (! function_exists('apcu_enabled') || ! apcu_enabled()) {
$this->markTestSkipped('APCu extension is not loaded or not enabled in CLI.');
}

$this->handler = CacheFactory::getHandler(new Cache(), 'apcu');
}

protected function tearDown(): void
{
foreach (self::getKeyArray() as $key) {
$this->handler->delete($key);
if (! isset($this->handler)) {
parent::tearDown();

return;
}

$this->handler->clean();
Comment on lines +43 to +49

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should we also call parent::tearDown()?


parent::tearDown();
}

public function testNew(): void
Expand Down
25 changes: 3 additions & 22 deletions tests/system/Cache/Handlers/FileHandlerTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -31,18 +31,6 @@ final class FileHandlerTest extends AbstractHandlerTestCase
private static string $directory = 'FileHandler';
private Cache $config;

/**
* @return list<string>
*/
private static function getKeyArray(): array
{
return [
self::$key1,
self::$key2,
self::$key3,
];
}

protected function setUp(): void
{
parent::setUp();
Expand All @@ -69,15 +57,8 @@ protected function tearDown(): void
if (is_dir($this->config->file['storePath'])) {
chmod($this->config->file['storePath'], 0777);

foreach (self::getKeyArray() as $key) {
if (is_file($this->config->file['storePath'] . DIRECTORY_SEPARATOR . $key)) {
chmod($this->config->file['storePath'] . DIRECTORY_SEPARATOR . $key, 0777);
unlink($this->config->file['storePath'] . DIRECTORY_SEPARATOR . $key);
}
if (is_file($this->config->file['storePath'] . DIRECTORY_SEPARATOR . $this->config->prefix . $key)) {
chmod($this->config->file['storePath'] . DIRECTORY_SEPARATOR . $this->config->prefix . $key, 0777);
unlink($this->config->file['storePath'] . DIRECTORY_SEPARATOR . $this->config->prefix . $key);
}
if (isset($this->handler)) {
$this->handler->clean();
}

rmdir($this->config->file['storePath']);
Expand Down Expand Up @@ -118,7 +99,7 @@ public function testSetDefaultPath(): void
*/
public function testGet(): void
{
$this->handler->save(self::$key1, 'value', 2);
$this->assertTrue($this->handler->save(self::$key1, 'value', 2));

$this->assertSame('value', $this->handler->get(self::$key1));
$this->assertNull($this->handler->get(self::$dummy));
Expand Down
22 changes: 8 additions & 14 deletions tests/system/Cache/Handlers/MemcachedHandlerTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -26,18 +26,6 @@
#[Group('CacheLive')]
final class MemcachedHandlerTest extends AbstractHandlerTestCase
{
/**
* @return list<string>
*/
private static function getKeyArray(): array
{
return [
self::$key1,
self::$key2,
self::$key3,
];
}

protected function setUp(): void
{
parent::setUp();
Expand All @@ -51,9 +39,15 @@ protected function setUp(): void

protected function tearDown(): void
{
foreach (self::getKeyArray() as $key) {
$this->handler->delete($key);
if (! isset($this->handler)) {
parent::tearDown();

return;
}

$this->handler->clean();

parent::tearDown();
}

public function testNew(): void
Expand Down
22 changes: 8 additions & 14 deletions tests/system/Cache/Handlers/PredisHandlerTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -27,18 +27,6 @@ final class PredisHandlerTest extends AbstractHandlerTestCase
{
private Cache $config;

/**
* @return list<string>
*/
private static function getKeyArray(): array
{
return [
self::$key1,
self::$key2,
self::$key3,
];
}

protected function setUp(): void
{
parent::setUp();
Expand All @@ -49,9 +37,15 @@ protected function setUp(): void

protected function tearDown(): void
{
foreach (self::getKeyArray() as $key) {
$this->handler->delete($key);
if (! isset($this->handler)) {
parent::tearDown();

return;
}

$this->handler->clean();

parent::tearDown();
}

public function testNew(): void
Expand Down
22 changes: 8 additions & 14 deletions tests/system/Cache/Handlers/RedisHandlerTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -28,18 +28,6 @@ final class RedisHandlerTest extends AbstractHandlerTestCase
{
private Cache $config;

/**
* @return list<string>
*/
private static function getKeyArray(): array
{
return [
self::$key1,
self::$key2,
self::$key3,
];
}

protected function setUp(): void
{
parent::setUp();
Expand All @@ -54,9 +42,15 @@ protected function setUp(): void

protected function tearDown(): void
{
foreach (self::getKeyArray() as $key) {
$this->handler->delete($key);
if (! isset($this->handler)) {
parent::tearDown();

return;
}

$this->handler->clean();

parent::tearDown();
}

public function testNew(): void
Expand Down
Loading