Skip to content

Commit

Permalink
Merge pull request #46 from boesing/bugfix/add-missing-adapter-plugin…
Browse files Browse the repository at this point in the history
…manager-to-config-provider

Add missing `AdapterPluginManager` service to `ConfigProvider`
  • Loading branch information
boesing authored Sep 13, 2023
2 parents 0aba33d + 50139b3 commit 63f0a14
Show file tree
Hide file tree
Showing 4 changed files with 52 additions and 5 deletions.
2 changes: 1 addition & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@
},
"require-dev": {
"laminas/laminas-coding-standard": "~2.4.0",
"laminas/laminas-math": "~3.6.0",
"laminas/laminas-math": "^3.6",
"laminas/laminas-servicemanager": "~3.19.0",
"phpunit/phpunit": "~9.6.0"
},
Expand Down
2 changes: 1 addition & 1 deletion composer.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

18 changes: 15 additions & 3 deletions src/ConfigProvider.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,11 @@

use Laminas\Serializer\Adapter\AdapterInterface;
use Laminas\Serializer\Adapter\PhpSerialize;
use Psr\Container\ContainerInterface;

/**
* @see ContainerInterface
*/
class ConfigProvider
{
/**
Expand All @@ -28,16 +32,24 @@ public function __invoke()
/**
* Return dependency mappings for this component.
*
* @return array
* @return array{
* factories: array<
* string,
* callable(ContainerInterface,?string,?array<mixed>|null):object
* >,
* aliases: array<never,never>
* }
*/
// @phpcs:ignore SlevomatCodingStandard.TypeHints.ReturnTypeHint.MissingAnyTypeHint
public function getDependencyConfig()
{
return [
// Legacy Zend Framework aliases
'aliases' => [],
'factories' => [
'SerializerAdapterManager' => AdapterPluginManagerFactory::class,
AdapterInterface::class => new GenericSerializerFactory(PhpSerialize::class),
'SerializerAdapterManager' => AdapterPluginManagerFactory::class,
AdapterPluginManager::class => AdapterPluginManagerFactory::class,
AdapterInterface::class => new GenericSerializerFactory(PhpSerialize::class),
],
];
}
Expand Down
35 changes: 35 additions & 0 deletions test/ConfigProviderTest.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
<?php

declare(strict_types=1);

namespace LaminasTest\Serializer;

use Laminas\Serializer\Adapter\AdapterInterface;
use Laminas\Serializer\AdapterPluginManager;
use Laminas\Serializer\ConfigProvider;
use PHPUnit\Framework\TestCase;

final class ConfigProviderTest extends TestCase
{
/**
* @param non-empty-string $serviceName
* @dataProvider factoryServiceNames
*/
public function testHasExpectedServiceNames(string $serviceName): void
{
$dependencies = (new ConfigProvider())->getDependencyConfig();
self::assertArrayHasKey($serviceName, $dependencies['factories']);
}

/**
* @return iterable<non-empty-string,array{0:non-empty-string}>
*/
public static function factoryServiceNames(): iterable
{
return [
'SerializerAdapterManager' => ['SerializerAdapterManager'],
AdapterPluginManager::class => [AdapterPluginManager::class],
AdapterInterface::class => [AdapterInterface::class],
];
}
}

0 comments on commit 63f0a14

Please sign in to comment.