Skip to content
This repository was archived by the owner on Jan 29, 2020. It is now read-only.

Commit 09d8b31

Browse files
committed
ApplicationConfigInjectionDelegator works also with ArrayObject config
Fixes #611
1 parent 99feabe commit 09d8b31

File tree

2 files changed

+26
-2
lines changed

2 files changed

+26
-2
lines changed

src/Container/ApplicationConfigInjectionDelegator.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -58,8 +58,8 @@ public function __invoke(ContainerInterface $container, string $serviceName, cal
5858
return $application;
5959
}
6060

61-
self::injectPipelineFromConfig($application, $config);
62-
self::injectRoutesFromConfig($application, $config);
61+
self::injectPipelineFromConfig($application, (array) $config);
62+
self::injectRoutesFromConfig($application, (array) $config);
6363

6464
return $application;
6565
}

test/Container/ApplicationConfigInjectionDelegatorTest.php

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99

1010
namespace ZendTest\Expressive\Container;
1111

12+
use ArrayObject;
1213
use PHPUnit\Framework\Assert;
1314
use PHPUnit\Framework\TestCase;
1415
use Prophecy\Prophecy\ObjectProphecy;
@@ -449,4 +450,27 @@ public function testInjectPipelineFromConfigRaisesExceptionForSpecsOmittingMiddl
449450
$this->expectExceptionMessage('Invalid pipeline specification received');
450451
ApplicationConfigInjectionDelegator::injectPipelineFromConfig($app, $config);
451452
}
453+
454+
public function testConfigCanBeArrayObject()
455+
{
456+
$config = new ArrayObject([
457+
'routes' => [
458+
'home' => [
459+
'name' => 'homepage',
460+
'path' => '/',
461+
'middleware' => new TestAsset\InteropMiddleware(),
462+
],
463+
],
464+
]);
465+
466+
$this->container->has('config')->willReturn(true);
467+
$this->container->get('config')->willReturn($config);
468+
469+
$delegator = new ApplicationConfigInjectionDelegator();
470+
$application = $delegator($this->container->reveal(), '', function () {
471+
return $this->createApplication();
472+
});
473+
474+
$this->assertCount(1, $application->getRoutes());
475+
}
452476
}

0 commit comments

Comments
 (0)