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

Commit

Permalink
ApplicationConfigInjectionDelegator works also with ArrayObject config
Browse files Browse the repository at this point in the history
Fixes #611
  • Loading branch information
michalbundyra committed Apr 10, 2018
1 parent 99feabe commit 09d8b31
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 2 deletions.
4 changes: 2 additions & 2 deletions src/Container/ApplicationConfigInjectionDelegator.php
Original file line number Diff line number Diff line change
Expand Up @@ -58,8 +58,8 @@ public function __invoke(ContainerInterface $container, string $serviceName, cal
return $application;
}

self::injectPipelineFromConfig($application, $config);
self::injectRoutesFromConfig($application, $config);
self::injectPipelineFromConfig($application, (array) $config);
self::injectRoutesFromConfig($application, (array) $config);

return $application;
}
Expand Down
24 changes: 24 additions & 0 deletions test/Container/ApplicationConfigInjectionDelegatorTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@

namespace ZendTest\Expressive\Container;

use ArrayObject;
use PHPUnit\Framework\Assert;
use PHPUnit\Framework\TestCase;
use Prophecy\Prophecy\ObjectProphecy;
Expand Down Expand Up @@ -449,4 +450,27 @@ public function testInjectPipelineFromConfigRaisesExceptionForSpecsOmittingMiddl
$this->expectExceptionMessage('Invalid pipeline specification received');
ApplicationConfigInjectionDelegator::injectPipelineFromConfig($app, $config);
}

public function testConfigCanBeArrayObject()
{
$config = new ArrayObject([
'routes' => [
'home' => [
'name' => 'homepage',
'path' => '/',
'middleware' => new TestAsset\InteropMiddleware(),
],
],
]);

$this->container->has('config')->willReturn(true);
$this->container->get('config')->willReturn($config);

$delegator = new ApplicationConfigInjectionDelegator();
$application = $delegator($this->container->reveal(), '', function () {
return $this->createApplication();
});

$this->assertCount(1, $application->getRoutes());
}
}

0 comments on commit 09d8b31

Please sign in to comment.