-
-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #68 from TheDragonCode/3.x
Added `Cache::call()` method
- Loading branch information
Showing
4 changed files
with
136 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
namespace Tests\Cache\NotWhen\Simple; | ||
|
||
use DragonCode\Cache\Services\Cache; | ||
use Tests\Cache\NotWhen\Base; | ||
|
||
class ChainTest extends Base | ||
{ | ||
protected $cache = 'redis'; | ||
|
||
public function testMain() | ||
{ | ||
$this->assertTrue($this->cache()->doesntHave()); | ||
|
||
$this->cache()->put($this->value); | ||
|
||
$this->cache() | ||
->call(fn (Cache $cache) => $this->assertTrue($cache->doesntHave())) | ||
->forget() | ||
->call(fn (Cache $cache) => $this->assertTrue($cache->doesntHave())); | ||
} | ||
|
||
public function testWhen() | ||
{ | ||
$this->assertTrue($this->cache()->doesntHave()); | ||
|
||
$this->cache()->put($this->value); | ||
|
||
$this->cache() | ||
->call(fn (Cache $cache) => $this->assertTrue(false), false) | ||
->call(fn (Cache $cache) => $this->assertTrue(false), fn () => false) | ||
->call(fn (Cache $cache) => $this->assertTrue(false), 0) | ||
->call(fn (Cache $cache) => $this->assertTrue(false), fn () => 0); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
namespace Tests\Cache\When\Simple; | ||
|
||
use DragonCode\Cache\Services\Cache; | ||
use Tests\Cache\When\Base; | ||
|
||
class ChainTest extends Base | ||
{ | ||
protected $cache = 'redis'; | ||
|
||
public function testMain() | ||
{ | ||
$this->assertTrue($this->cache()->doesntHave()); | ||
|
||
$this->cache()->put($this->value); | ||
|
||
$this->cache() | ||
->call(fn (Cache $cache) => $this->assertTrue($cache->has())) | ||
->forget() | ||
->call(fn (Cache $cache) => $this->assertTrue($cache->doesntHave())); | ||
} | ||
|
||
public function testWhen() | ||
{ | ||
$this->assertTrue($this->cache()->doesntHave()); | ||
|
||
$this->cache()->put($this->value); | ||
|
||
$this->cache() | ||
->call(fn (Cache $cache) => $this->assertTrue(false), false) | ||
->call(fn (Cache $cache) => $this->assertTrue(false), fn () => false) | ||
->call(fn (Cache $cache) => $this->assertTrue(false), 0) | ||
->call(fn (Cache $cache) => $this->assertTrue(false), fn () => 0); | ||
} | ||
} |