forked from dgreda/cache-factory
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[WMS-1703] Base class for adapters tests
- Loading branch information
1 parent
e39c991
commit 8306da5
Showing
3 changed files
with
60 additions
and
60 deletions.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,58 @@ | ||
<?php | ||
|
||
use Cache\Factory\Config\Adapter\AdapterInterface as Config; | ||
use Cache\Factory\Config\Loader; | ||
|
||
abstract class BaseAdapterTests extends PHPUnit_Framework_TestCase | ||
{ | ||
/** | ||
* @var string Name of the adapter in the configuration | ||
*/ | ||
protected $adapterName; | ||
|
||
/** | ||
* @var string Type of the cache pool adapter | ||
*/ | ||
protected $adapterType; | ||
|
||
/** | ||
* @var string Path to the config file | ||
*/ | ||
protected $configFile; | ||
|
||
/** | ||
* @var array | ||
*/ | ||
protected $config; | ||
|
||
/** | ||
* Sets the config file | ||
*/ | ||
protected function setUp() | ||
{ | ||
if (!isset($this->adapterName)) { | ||
throw new Exception( | ||
sprintf('Provide $adapterName in %s', (new ReflectionClass($this))->getFileName()) | ||
); | ||
} elseif (!isset($this->adapterType)) { | ||
throw new Exception( | ||
sprintf('Provide $adapterType in %s', (new ReflectionClass($this))->getFileName()) | ||
); | ||
} | ||
|
||
$this->configFile = __DIR__ . '/../cache.yml'; | ||
|
||
$configLoader = new Loader(); | ||
$config = $configLoader->load($this->configFile); | ||
|
||
$configLoader->setAdapterName($this->adapterType); | ||
|
||
$processedConfiguration = $configLoader->process($this->adapterName, $config); | ||
$this->config = $processedConfiguration[Config::INDEX_ADAPTER][$this->adapterName]; | ||
} | ||
|
||
/** | ||
* Tests creation of the filesystem cache item pool | ||
*/ | ||
abstract public function testMake(); | ||
} |
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 |
---|---|---|
@@ -1,10 +1,8 @@ | ||
<?php | ||
|
||
use Cache\Factory\Adapter\PHPArray; | ||
use Cache\Factory\Config\Adapter\AdapterInterface as Config; | ||
use Cache\Factory\Config\Loader; | ||
|
||
class PHPArrayAdapterTests extends PHPUnit_Framework_TestCase | ||
class PHPArrayAdapterTests extends BaseAdapterTests | ||
{ | ||
/** | ||
* @var string Name of the adapter in the configuration | ||
|
@@ -16,36 +14,8 @@ class PHPArrayAdapterTests extends PHPUnit_Framework_TestCase | |
*/ | ||
protected $adapterType = 'PHPArray'; | ||
|
||
/** | ||
* @var string Path to the config file | ||
*/ | ||
protected $configFile; | ||
|
||
/** | ||
* @var array | ||
*/ | ||
protected $config; | ||
|
||
/** | ||
* Sets the config file | ||
*/ | ||
protected function setUp() | ||
{ | ||
$this->configFile = __DIR__ . '/../cache.yml'; | ||
|
||
$configLoader = new Loader(); | ||
$config = $configLoader->load($this->configFile); | ||
|
||
$configLoader->setAdapterName($this->adapterType); | ||
|
||
$processedConfiguration = $configLoader->process($this->adapterName, $config); | ||
$this->config = $processedConfiguration[Config::INDEX_ADAPTER][$this->adapterName]; | ||
} | ||
|
||
/** | ||
* Tests creation of the filesystem cache item pool | ||
* | ||
* @author Damian Gręda <[email protected]> | ||
*/ | ||
public function testMake() | ||
{ | ||
|