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

Commit 434c4c5

Browse files
committed
Added tests to pass configuration as array and as ArrayObject
1 parent 235efb9 commit 434c4c5

File tree

1 file changed

+31
-2
lines changed

1 file changed

+31
-2
lines changed

test/Container/ApplicationFactoryIntegrationTest.php

Lines changed: 31 additions & 2 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_TestCase as TestCase;
1314
use Prophecy\Argument;
1415
use Psr\Http\Message\ServerRequestInterface;
@@ -50,7 +51,12 @@ public function setUp()
5051
$this->injectServiceInContainer($this->container, EmitterInterface::class, $this->emitter->reveal());
5152
}
5253

53-
public function testConfiguredErrorMiddlewarePipeIsExecutedWhenMiddlewareCallsNextWithError()
54+
/**
55+
* @dataProvider configType
56+
*
57+
* @param string $type
58+
*/
59+
public function testConfiguredErrorMiddlewarePipeIsExecutedWhenMiddlewareCallsNextWithError($type)
5460
{
5561
$always = function ($request, $response, $next) {
5662
$response = $next($request, $response);
@@ -121,6 +127,11 @@ public function testConfiguredErrorMiddlewarePipeIsExecutedWhenMiddlewareCallsNe
121127
],
122128
],
123129
];
130+
131+
if ($type !== 'array') {
132+
$config = new $type($config);
133+
}
134+
124135
$this->injectServiceInContainer($this->container, 'config', $config);
125136

126137
$app = $this->factory->__invoke($this->container->reveal());
@@ -139,7 +150,12 @@ public function testConfiguredErrorMiddlewarePipeIsExecutedWhenMiddlewareCallsNe
139150
$this->assertEquals('Error middleware called', (string) $response->getBody());
140151
}
141152

142-
public function testConfiguredErrorMiddlewareIsExecutedWhenMiddlewareCallsNextWithError()
153+
/**
154+
* @dataProvider configType
155+
*
156+
* @param string $type
157+
*/
158+
public function testConfiguredErrorMiddlewareIsExecutedWhenMiddlewareCallsNextWithError($type)
143159
{
144160
$always = function ($request, $response, $next) {
145161
$response = $next($request, $response);
@@ -209,6 +225,11 @@ public function testConfiguredErrorMiddlewareIsExecutedWhenMiddlewareCallsNextWi
209225
],
210226
],
211227
];
228+
229+
if ($type !== 'array') {
230+
$config = new $type($config);
231+
}
232+
212233
$this->injectServiceInContainer($this->container, 'config', $config);
213234

214235
$app = $this->factory->__invoke($this->container->reveal());
@@ -226,4 +247,12 @@ public function testConfiguredErrorMiddlewareIsExecutedWhenMiddlewareCallsNextWi
226247
$this->assertEquals('needs-auth', $response->getHeaderLine('X-Route-Result'));
227248
$this->assertEquals('Error middleware called', (string) $response->getBody());
228249
}
250+
251+
public function configType()
252+
{
253+
return [
254+
[ArrayObject::class],
255+
['array'],
256+
];
257+
}
229258
}

0 commit comments

Comments
 (0)