Skip to content

Commit

Permalink
removed unused tests related to doctrine/cache 1.x
Browse files Browse the repository at this point in the history
  • Loading branch information
driehle committed Dec 29, 2024
1 parent 62c49bb commit d68eba7
Showing 1 changed file with 0 additions and 99 deletions.
99 changes: 0 additions & 99 deletions tests/Service/CacheFactoryTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,56 +4,18 @@

namespace DoctrineModuleTest\Service;

use Composer\InstalledVersions;
use Composer\Semver\VersionParser;
use Doctrine\Common\Cache\ArrayCache;
use Doctrine\Common\Cache\ChainCache;
use Doctrine\Common\Cache\PredisCache;
use DoctrineModule\Cache\LaminasStorageCache;
use DoctrineModule\Service\CacheFactory;
use Laminas\Cache\ConfigProvider;
use Laminas\Cache\Storage\Adapter\Memory;
use Laminas\ServiceManager\ServiceManager;
use PHPUnit\Framework\TestCase as BaseTestCase;
use Predis\ClientInterface;

use function assert;

/**
* Test for {@see \DoctrineModule\Service\CacheFactory}
*/
class CacheFactoryTest extends BaseTestCase
{
/** @covers \DoctrineModule\Service\CacheFactory::__invoke */
public function testWillSetNamespace(): void
{
if (! InstalledVersions::satisfies(new VersionParser(), 'doctrine/cache', '^1.0.0')) {
$this->markTestSkipped('This test requires doctrine/cache:^1.0, which is not installed.');
}

$factory = new CacheFactory('foo');
$serviceManager = new ServiceManager();
$serviceManager->setService(
'config',
[
'doctrine' => [
'cache' => [
'foo' => [
'class' => ArrayCache::class,
'namespace' => 'bar',
],
],
],
],
);

$service = $factory->__invoke($serviceManager, ArrayCache::class);
assert($service instanceof ArrayCache);

$this->assertInstanceOf(ArrayCache::class, $service);
$this->assertSame('bar', $service->getNamespace());
}

/**
* @covers \DoctrineModule\Service\CacheFactory::__invoke
* @group 547
Expand Down Expand Up @@ -85,65 +47,4 @@ public function testCreateLaminasCache(): void

$this->assertInstanceOf(LaminasStorageCache::class, $cache);
}

public function testCreatePredisCache(): void
{
if (! InstalledVersions::satisfies(new VersionParser(), 'doctrine/cache', '^1.0.0')) {
$this->markTestSkipped('This test requires doctrine/cache:^1.0, which is not installed.');
}

$factory = new CacheFactory('predis');
$serviceManager = new ServiceManager();
$serviceManager->setService(
'config',
[
'doctrine' => [
'cache' => [
'predis' => [
'class' => PredisCache::class,
'instance' => 'my_predis_alias',
'namespace' => 'DoctrineModule',
],
],
],
],
);
$serviceManager->setService(
'my_predis_alias',
$this->createMock(ClientInterface::class),
);
$cache = $factory->__invoke($serviceManager, PredisCache::class);

$this->assertInstanceOf(PredisCache::class, $cache);
}

public function testUseServiceFactory(): void
{
if (! InstalledVersions::satisfies(new VersionParser(), 'doctrine/cache', '^1.0.0')) {
$this->markTestSkipped('This test requires doctrine/cache:^1.0, which is not installed.');
}

$factory = new CacheFactory('chain');
$serviceManager = new ServiceManager();
$serviceManager->setService(
'config',
[
'doctrine' => [
'cache' => [
'chain' => [
'class' => ChainCache::class,
],
],
],
],
);

$mock = $this->createMock(ChainCache::class);

$serviceManager->setFactory(ChainCache::class, static fn () => $mock);

$cache = $factory->__invoke($serviceManager, ChainCache::class);

$this->assertSame($mock, $cache);
}
}

0 comments on commit d68eba7

Please sign in to comment.