Skip to content

Commit

Permalink
qa: migrate to non-deprecated AbstractCommonAdapterTest
Browse files Browse the repository at this point in the history
Signed-off-by: Maximilian Bösing <2189546+boesing@users.noreply.github.com>
  • Loading branch information
boesing committed Aug 8, 2021
1 parent f6dca8b commit 30dfaf3
Showing 1 changed file with 10 additions and 18 deletions.
28 changes: 10 additions & 18 deletions test/unit/MemcachedTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,35 +10,27 @@
use Throwable;
use function random_int;

/**
* @group Laminas_Cache
* @covers Laminas\Cache\Storage\Adapter\Memcached<extended>
*/
class MemcachedTest extends CommonAdapterTest
final class MemcachedTest extends AbstractCommonAdapterTest
{
public function setUp(): void
{
if (! extension_loaded('memcached')) {
$this->markTestSkipped("Memcached extension is not loaded");
}

$this->_options = new Cache\Storage\Adapter\MemcachedOptions([
$this->options = new Cache\Storage\Adapter\MemcachedOptions([
'resource_id' => __CLASS__
]);

if (getenv('TESTS_LAMINAS_CACHE_MEMCACHED_HOST') && getenv('TESTS_LAMINAS_CACHE_MEMCACHED_PORT')) {
$this->_options->getResourceManager()->setServers(__CLASS__, [
$this->options->getResourceManager()->setServers(__CLASS__, [
[getenv('TESTS_LAMINAS_CACHE_MEMCACHED_HOST'), getenv('TESTS_LAMINAS_CACHE_MEMCACHED_PORT')]
]);
} elseif (getenv('TESTS_LAMINAS_CACHE_MEMCACHED_HOST')) {
$this->_options->getResourceManager()->setServers(__CLASS__, [
$this->options->getResourceManager()->setServers(__CLASS__, [
[getenv('TESTS_LAMINAS_CACHE_MEMCACHED_HOST')]
]);
}

$this->_storage = new Cache\Storage\Adapter\Memcached();
$this->_storage->setOptions($this->_options);
$this->_storage->flush();
$this->storage = new Cache\Storage\Adapter\Memcached();
$this->storage->setOptions($this->options);
$this->storage->flush();

parent::setUp();
}
Expand Down Expand Up @@ -243,7 +235,7 @@ public function testOptionPersistentId()

public function testExceptionCodeIsPassedToRuntimeExceptionWhenExceptionIsBeingDetectedByInternalMethod(): void
{
$memcached = new class($this->_options) extends Cache\Storage\Adapter\Memcached {
$memcached = new class($this->options) extends Cache\Storage\Adapter\Memcached {
/** @psalm-param positive-int $code */
public function createExceptionWithCode(int $code): Throwable
{
Expand Down Expand Up @@ -313,8 +305,8 @@ public function testExceptionCodeIsPassedToRuntimeExceptionWhenAvailableSpaceReq

public function tearDown(): void
{
if ($this->_storage) {
$this->_storage->flush();
if ($this->storage) {
$this->storage->flush();
}

parent::tearDown();
Expand Down

0 comments on commit 30dfaf3

Please sign in to comment.