Skip to content

Commit

Permalink
Fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
RobiNN1 committed Oct 28, 2023
1 parent 94d77c1 commit ab7c7e6
Show file tree
Hide file tree
Showing 4 changed files with 32 additions and 36 deletions.
2 changes: 1 addition & 1 deletion src/Admin.php
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ public function getDashboard(string $dashboard): DashboardInterface {

public function currentDashboard(): string {
$current = Http::get('dashboard', '');
$dashboards = $this->dashboards();
$dashboards = $this->dashboards;

return array_key_exists($current, $dashboards) ? $current : array_key_first($dashboards);
}
Expand Down
1 change: 1 addition & 0 deletions src/Dashboards/Redis/RedisTrait.php
Original file line number Diff line number Diff line change
Expand Up @@ -283,6 +283,7 @@ private function form(): string {
Helpers::alert($this->template, $e->getMessage(), 'error');
$type = 'unknown';
}

$expire = $this->redis->ttl($key);
}

Expand Down
10 changes: 8 additions & 2 deletions tests/Clients/PredisTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@

namespace Tests\Clients;

use Iterator;
use PHPUnit\Framework\TestCase;
use RobiNN\Pca\Dashboards\DashboardException;
use RobiNN\Pca\Dashboards\Redis\Compatibility\Predis;
Expand All @@ -22,8 +23,13 @@ protected function setUp(): void {
/**
* @return array<int, array<string>>
*/
public static function keysProvider(): array {
return [['string'], ['set'], ['list'], ['zset'], ['hash'], ['stream']];
public static function keysProvider(): Iterator {
yield ['string'];
yield ['set'];
yield ['list'];
yield ['zset'];
yield ['hash'];
yield ['stream'];
}

/**
Expand Down
55 changes: 22 additions & 33 deletions tests/Dashboards/MemcachedTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@

namespace Tests\Dashboards;

use Iterator;
use RobiNN\Pca\Dashboards\DashboardException;
use RobiNN\Pca\Dashboards\Memcached\Compatibility\Memcache;
use RobiNN\Pca\Dashboards\Memcached\Compatibility\Memcached;
Expand Down Expand Up @@ -120,39 +121,27 @@ public function testGetServerStats(): void {
$this->assertArrayHasKey('version', $this->memcached->getServerStats());
}

/**
* @return array<string, array<int,string>>
*/
public static function commandDataProvider(): array {
return [
'test set' => ['STORED', 'set pu-test-rc-set 0 0 3\r\nidk'],
'test get' => ['VALUE pu-test-rc-set 0 3\r\nidk\r\nEND', 'get pu-test-rc-set'],
'test delete' => ['DELETED', 'delete pu-test-rc-set'],

'test add' => ['STORED', 'add pu-test-rc-add 0 0 3\r\nidk'],
'test replace' => ['STORED', 'replace pu-test-rc-add 0 0 4\r\ntest'],
'test replaced value' => ['VALUE pu-test-rc-add 0 4\r\ntest\r\nEND', 'get pu-test-rc-add'],
'test append' => ['STORED', 'append pu-test-rc-add 0 0 2\r\naa'],
'test appended value' => ['VALUE pu-test-rc-add 0 6\r\ntestaa\r\nEND', 'get pu-test-rc-add'],
'test prepend' => ['STORED', 'prepend pu-test-rc-add 0 0 2\r\npp'],
'test prepended value' => ['VALUE pu-test-rc-add 0 8\r\npptestaa\r\nEND', 'get pu-test-rc-add'],

'test gat' => ['VALUE pu-test-rc-add 0 8\r\npptestaa\r\nEND', 'gat 700 pu-test-rc-add'],

'test touch' => ['TOUCHED', 'touch pu-test-rc-add 0'],

'test set int' => ['STORED', 'set pu-test-rc-int 0 0 1\r\n1'],
'test set incr' => ['6', 'incr pu-test-rc-int 5'],
'test set decr' => ['3', 'decr pu-test-rc-int 3'],

'test ms' => ['HD', 'ms pu-test-rc-ms 1\r\n4'],
'test mg' => ['VA 1', 'mg pu-test-rc-ms v'],
'test ma' => ['HD', 'ma pu-test-rc-ms'],

'test cache_memlimit' => ['OK', 'cache_memlimit 100'],

'test flush_all' => ['OK', 'flush_all'],
];
public static function commandDataProvider(): Iterator {
yield 'test set' => ['STORED', 'set pu-test-rc-set 0 0 3\r\nidk'];
yield 'test get' => ['VALUE pu-test-rc-set 0 3\r\nidk\r\nEND', 'get pu-test-rc-set'];
yield 'test delete' => ['DELETED', 'delete pu-test-rc-set'];
yield 'test add' => ['STORED', 'add pu-test-rc-add 0 0 3\r\nidk'];
yield 'test replace' => ['STORED', 'replace pu-test-rc-add 0 0 4\r\ntest'];
yield 'test replaced value' => ['VALUE pu-test-rc-add 0 4\r\ntest\r\nEND', 'get pu-test-rc-add'];
yield 'test append' => ['STORED', 'append pu-test-rc-add 0 0 2\r\naa'];
yield 'test appended value' => ['VALUE pu-test-rc-add 0 6\r\ntestaa\r\nEND', 'get pu-test-rc-add'];
yield 'test prepend' => ['STORED', 'prepend pu-test-rc-add 0 0 2\r\npp'];
yield 'test prepended value' => ['VALUE pu-test-rc-add 0 8\r\npptestaa\r\nEND', 'get pu-test-rc-add'];
yield 'test gat' => ['VALUE pu-test-rc-add 0 8\r\npptestaa\r\nEND', 'gat 700 pu-test-rc-add'];
yield 'test touch' => ['TOUCHED', 'touch pu-test-rc-add 0'];
yield 'test set int' => ['STORED', 'set pu-test-rc-int 0 0 1\r\n1'];
yield 'test set incr' => ['6', 'incr pu-test-rc-int 5'];
yield 'test set decr' => ['3', 'decr pu-test-rc-int 3'];
yield 'test ms' => ['HD', 'ms pu-test-rc-ms 1\r\n4'];
yield 'test mg' => ['VA 1', 'mg pu-test-rc-ms v'];
yield 'test ma' => ['HD', 'ma pu-test-rc-ms'];
yield 'test cache_memlimit' => ['OK', 'cache_memlimit 100'];
yield 'test flush_all' => ['OK', 'flush_all'];
}

/**
Expand Down

0 comments on commit ab7c7e6

Please sign in to comment.