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

Commit 8de32b9

Browse files
committed
Merge branch 'feature/34-config-provider' into release-3.0.0
Close #34
2 parents cb272e0 + 493d3f7 commit 8de32b9

File tree

6 files changed

+99
-4
lines changed

6 files changed

+99
-4
lines changed

CHANGELOG.md

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,14 +2,18 @@
22

33
All notable changes to this project will be documented in this file, in reverse chronological order by release.
44

5-
## 3.0.0alpha1 - TBD
5+
## 3.0.0alpha1 - 2018-02-06
66

77
### Added
88

99
- [#30](https://github.com/zendframework/zend-expressive-zendrouter/pull/30) and
10-
- [#35](https://github.com/zendframework/zend-expressive-zendrouter/pull/35) add
10+
[#35](https://github.com/zendframework/zend-expressive-zendrouter/pull/35) add
1111
support for the zend-expressive-router 3.0 series.
1212

13+
- [#34](https://github.com/zendframework/zend-expressive-zendrouter/pull/34)
14+
adds `Zend\Expressive\Router\ZendRouter\ConfigProvider` and exposes it as a
15+
config provider within the package definition.
16+
1317
### Changed
1418

1519
- Nothing.

LICENSE.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
Copyright (c) 2015-2017, Zend Technologies USA, Inc.
1+
Copyright (c) 2015-2018, Zend Technologies USA, Inc.
22
All rights reserved.
33

44
Redistribution and use in source and binary forms, with or without modification,

composer.json

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,9 @@
5151
"dev-master": "2.1.x-dev",
5252
"dev-develop": "2.2.x-dev",
5353
"dev-release-3.0.0": "3.0.x-dev"
54+
},
55+
"zf": {
56+
"config-provider": "Zend\\Expressive\\Router\\ConfigProvider"
5457
}
5558
},
5659
"scripts": {

composer.lock

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/ZendRouter/ConfigProvider.php

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
<?php
2+
/**
3+
* @see https://github.com/zendframework/zend-expressive-zendrouter for the canonical source repository
4+
* @copyright Copyright (c) 2018 Zend Technologies USA Inc. (https://www.zend.com)
5+
* @license https://github.com/zendframework/zend-expressive-zendrouter/blob/master/LICENSE.md New BSD License
6+
*/
7+
8+
declare(strict_types=1);
9+
10+
namespace Zend\Expressive\Router\ZendRouter;
11+
12+
use Zend\Expressive\Router\RouterInterface;
13+
use Zend\Expressive\Router\ZendRouter;
14+
15+
class ConfigProvider
16+
{
17+
public function __invoke() : array
18+
{
19+
return [
20+
'dependencies' => $this->getDependencies(),
21+
];
22+
}
23+
24+
public function getDependencies() : array
25+
{
26+
return [
27+
'aliases' => [
28+
RouterInterface::class => ZendRouter::class,
29+
],
30+
'invokables' => [
31+
ZendRouter::class => ZendRouter::class,
32+
],
33+
];
34+
}
35+
}
Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
1+
<?php
2+
/**
3+
* @see https://github.com/zendframework/zend-expressive-zendrouter for the canonical source repository
4+
* @copyright Copyright (c) 2018 Zend Technologies USA Inc. (https://www.zend.com)
5+
* @license https://github.com/zendframework/zend-expressive-zendrouter/blob/master/LICENSE.md New BSD License
6+
*/
7+
8+
declare(strict_types=1);
9+
10+
namespace ZendTest\Expressive\Router\ZendRouter;
11+
12+
use PHPUnit\Framework\TestCase;
13+
use Zend\Expressive\Router\RouterInterface;
14+
use Zend\Expressive\Router\ZendRouter;
15+
use Zend\Expressive\Router\ZendRouter\ConfigProvider;
16+
17+
class ConfigProviderTest extends TestCase
18+
{
19+
/**
20+
* @var ConfigProvider
21+
*/
22+
private $provider;
23+
24+
protected function setUp() : void
25+
{
26+
$this->provider = new ConfigProvider();
27+
}
28+
29+
public function testInvocationReturnsArray() : array
30+
{
31+
$config = ($this->provider)();
32+
$this->assertInternalType('array', $config);
33+
34+
return $config;
35+
}
36+
37+
/**
38+
* @depends testInvocationReturnsArray
39+
*/
40+
public function testReturnedArrayContainsDependencies(array $config) : void
41+
{
42+
$this->assertArrayHasKey('dependencies', $config);
43+
$this->assertInternalType('array', $config['dependencies']);
44+
45+
$this->assertArrayHasKey('aliases', $config['dependencies']);
46+
$this->assertInternalType('array', $config['dependencies']['aliases']);
47+
$this->assertArrayHasKey(RouterInterface::class, $config['dependencies']['aliases']);
48+
49+
$this->assertArrayHasKey('invokables', $config['dependencies']);
50+
$this->assertInternalType('array', $config['dependencies']['invokables']);
51+
$this->assertArrayHasKey(ZendRouter::class, $config['dependencies']['invokables']);
52+
}
53+
}

0 commit comments

Comments
 (0)