-
Notifications
You must be signed in to change notification settings - Fork 179
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 #569 from ivankayzer/settings-namespace-fix
[FIX] Apply cache namespace from settings
- Loading branch information
Showing
2 changed files
with
65 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,64 @@ | ||
<?php | ||
|
||
namespace Configuration\Cache; | ||
|
||
use Illuminate\Contracts\Cache\Factory; | ||
use Illuminate\Contracts\Cache\Repository; | ||
use LaravelDoctrine\ORM\Configuration\Cache\IlluminateCacheProvider; | ||
use Mockery as m; | ||
use PHPUnit\Framework\TestCase; | ||
|
||
class IlluminateCacheProviderTest extends TestCase | ||
{ | ||
/** | ||
* @var IlluminateCacheProvider | ||
*/ | ||
private $driver; | ||
|
||
/** | ||
* @var Repository|m\LegacyMockInterface|m\MockInterface | ||
*/ | ||
private $repository; | ||
|
||
protected function setUp(): void | ||
{ | ||
parent::setUp(); | ||
|
||
$this->repository = m::mock(Repository::class); | ||
$manager = m::mock(Factory::class); | ||
$manager->shouldReceive('store') | ||
->once() | ||
->andReturn($this->repository); | ||
|
||
$this->driver = new IlluminateCacheProvider($manager); | ||
} | ||
|
||
public function test_driver_returns_provided_namespace(): void | ||
{ | ||
$this->repository->shouldReceive('getMultiple') | ||
->withSomeOfArgs(['namespace_item']) | ||
->once(); | ||
|
||
$cache = $this->driver->resolve(['store' => 'redis', 'namespace' => 'namespace']); | ||
$cache->getItem('item'); | ||
|
||
$this->assertTrue(true); | ||
} | ||
|
||
public function test_driver_has_no_namespace_by_default(): void | ||
{ | ||
$this->repository->shouldReceive('getMultiple') | ||
->withSomeOfArgs(['item']) | ||
->once(); | ||
|
||
$cache = $this->driver->resolve(['store' => 'redis']); | ||
$cache->getItem('item'); | ||
|
||
$this->assertTrue(true); | ||
} | ||
|
||
public function tearDown(): void | ||
{ | ||
m::close(); | ||
} | ||
} |