Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 5 additions & 9 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -37,8 +37,8 @@
"homepage": "http://www.doctrine-project.org/",
"require": {
"php": "~8.1.0 || ~8.2.0 || ~8.3.0",
"composer-runtime-api": "^2.0",
"composer/semver": "^3.0",
"composer-runtime-api": "^2.0.0",
"composer/semver": "^3.0.0",
"doctrine/annotations": "^2.0.0",
"doctrine/cache": "^2.1.0",
"doctrine/collections": "^2.0.0",
Expand All @@ -52,7 +52,6 @@
"laminas/laminas-cache-storage-adapter-memory": "^2.1.0",
"laminas/laminas-eventmanager": "^3.5.0",
"laminas/laminas-form": "^3.4.1",
"laminas/laminas-modulemanager": "^2.12.0",
"laminas/laminas-mvc": "^3.3.5",
"laminas/laminas-paginator": "^2.13.0",
"laminas/laminas-servicemanager": "^3.17.0",
Expand All @@ -65,16 +64,13 @@
"doctrine/coding-standard": "^12.0.0",
"doctrine/mongodb-odm": "^2.7.1",
"doctrine/orm": "^2.20.1",
"jangregor/phpstan-prophecy": "^2",
"laminas/laminas-i18n": "^2.29.0",
"laminas/laminas-log": "^2.17.1",
"laminas/laminas-serializer": "^2.17.0",
"jangregor/phpstan-prophecy": "^2.0.0",
"laminas/laminas-modulemanager": "^2.12.0",
"laminas/laminas-session": "^2.22.1",
"phpdocumentor/guides-cli": "^1.5.0",
"phpstan/phpstan": "^2.0.4",
"phpstan/phpstan-phpunit": "^2.0.3",
"phpunit/phpunit": "^10.5.40",
"predis/predis": "^1.1.10"
"phpunit/phpunit": "^10.5.40"
},
"conflict": {
"doctrine/orm": "2.12.0"
Expand Down
4 changes: 1 addition & 3 deletions src/Module.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,10 @@

namespace DoctrineModule;

use Laminas\ModuleManager\Feature\ConfigProviderInterface;

/**
* Base module for integration of Doctrine projects with Laminas applications
*/
final class Module implements ConfigProviderInterface
final class Module
{
/** @return array<string, mixed> */
public function getConfig(): array
Expand Down
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);
}
}