Skip to content

Commit

Permalink
Merge branch '1.5' into 1.6
Browse files Browse the repository at this point in the history
  • Loading branch information
eigan committed Mar 8, 2020
2 parents 6f8085a + d2943d1 commit 3902b4a
Show file tree
Hide file tree
Showing 3 changed files with 64 additions and 1 deletion.
2 changes: 1 addition & 1 deletion config/doctrine.php
Original file line number Diff line number Diff line change
Expand Up @@ -156,7 +156,7 @@
| Configure meta-data, query and result caching here.
| Optionally you can enable second level caching.
|
| Available: apc|array|file|memcached|redis|void
| Available: apc|array|file|memcached|php_file|redis|void
|
*/
'cache' => [
Expand Down
36 changes: 36 additions & 0 deletions src/Configuration/Cache/PhpFileCacheProvider.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
<?php

namespace LaravelDoctrine\ORM\Configuration\Cache;

use Doctrine\Common\Cache\PhpFileCache;
use Illuminate\Contracts\Config\Repository;
use LaravelDoctrine\ORM\Configuration\Driver;
use function storage_path;

class PhpFileCacheProvider implements Driver
{
/**
* @var Repository
*/
protected $config;

/**
* @param Repository $config
*/
public function __construct(Repository $config)
{
$this->config = $config;
}

/**
* @param array $settings
*
* @return PhpFileCache
*/
public function resolve(array $settings = [])
{
return new PhpFileCache(
$this->config->get('cache.stores.file.path', storage_path('framework/cache'))
);
}
}
27 changes: 27 additions & 0 deletions tests/Configuration/Cache/PhpFileCacheProviderTest.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
<?php

use Doctrine\Common\Cache\PhpFileCache;
use Illuminate\Contracts\Config\Repository;
use LaravelDoctrine\ORM\Configuration\Cache\PhpFileCacheProvider;
use Mockery as m;

class PhpFileCacheProviderTest extends AbstractCacheProviderTest
{
public function getProvider()
{
$config = m::mock(Repository::class);
$config->shouldReceive('get')
->with('cache.stores.file.path', __DIR__ . DIRECTORY_SEPARATOR . '../../Stubs/storage/framework/cache')
->once()
->andReturn('/tmp');

return new PhpFileCacheProvider(
$config
);
}

public function getExpectedInstance()
{
return PhpFileCache::class;
}
}

0 comments on commit 3902b4a

Please sign in to comment.