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

Commit d0bfba1

Browse files
committed
Removes the path() method from the MiddlewareFactory
This is better accomplished using `Zend\Stratigility\path()` + the factory.
1 parent 5a14304 commit d0bfba1

File tree

2 files changed

+0
-65
lines changed

2 files changed

+0
-65
lines changed

src/MiddlewareFactory.php

Lines changed: 0 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,6 @@
1313
use Psr\Http\Server\MiddlewareInterface;
1414
use Zend\Stratigility\MiddlewarePipe;
1515
use Zend\Stratigility\Middleware\CallableMiddlewareDecorator;
16-
use Zend\Stratigility\Middleware\PathMiddlewareDecorator;
1716

1817
/**
1918
* Marshal middleware for use in the application.
@@ -121,20 +120,4 @@ public function pipeline(...$middleware) : MiddlewarePipe
121120
}
122121
return $pipeline;
123122
}
124-
125-
/**
126-
* Segregate one or more middleware by path.
127-
*
128-
* Creates and returns a PathMiddlewareDecorator instance after first
129-
* passing the $middleware argument to prepare().
130-
*
131-
* @param string|array|MiddlewareInterface $middleware
132-
*/
133-
public function path(string $path, $middleware) : PathMiddlewareDecorator
134-
{
135-
return new PathMiddlewareDecorator(
136-
$path,
137-
$this->prepare($middleware)
138-
);
139-
}
140123
}

test/MiddlewareFactoryTest.php

Lines changed: 0 additions & 48 deletions
Original file line numberDiff line numberDiff line change
@@ -19,8 +19,6 @@
1919
use Zend\Expressive\Middleware\LazyLoadingMiddleware;
2020
use Zend\Stratigility\MiddlewarePipe;
2121
use Zend\Stratigility\Middleware\CallableMiddlewareDecorator;
22-
use Zend\Stratigility\Middleware\DoublePassMiddlewareDecorator;
23-
use Zend\Stratigility\Middleware\PathMiddlewareDecorator;
2422

2523
class MiddlewareFactoryTest extends TestCase
2624
{
@@ -196,50 +194,4 @@ public function testPipelineAllowsPipingArraysOfMiddlewareAndCastsThemToInternal
196194
$this->assertCallableMiddleware($callable, $received[0]);
197195
$this->assertSame($middleware, $received[1]);
198196
}
199-
200-
/**
201-
* @dataProvider validPrepareTypes
202-
* @param string|callable|MiddlewareInterface $middleware
203-
* @param mixed $expected Expected type or value for use with assertion
204-
*/
205-
public function testPathCreatesPathMiddlewareDecoratorUsingAnyMiddlewareTypeSupportedByPrepare(
206-
$middleware,
207-
string $assertion,
208-
$expected
209-
) {
210-
$decorator = $this->factory->path('/foo', $middleware);
211-
$this->assertInstanceOf(PathMiddlewareDecorator::class, $decorator);
212-
213-
$this->assertAttributeSame('/foo', 'prefix', $decorator);
214-
215-
$r = new ReflectionProperty($decorator, 'middleware');
216-
$r->setAccessible(true);
217-
$received = $r->getValue($decorator);
218-
219-
$this->{$assertion}($expected, $received);
220-
}
221-
222-
public function testPathCanAcceptAnArrayOfMiddleware()
223-
{
224-
$callable = function ($request, $handler) {
225-
};
226-
$middleware = new DispatchMiddleware();
227-
228-
$internalPipeline = [$callable, $middleware];
229-
230-
$decorator = $this->factory->path('/foo', $internalPipeline);
231-
232-
$this->assertInstanceOf(PathMiddlewareDecorator::class, $decorator);
233-
234-
$this->assertAttributeSame('/foo', 'prefix', $decorator);
235-
236-
$r = new ReflectionProperty($decorator, 'middleware');
237-
$r->setAccessible(true);
238-
$received = $r->getValue($decorator);
239-
240-
$received = $this->reflectPipeline($received);
241-
$this->assertCount(2, $received);
242-
$this->assertCallableMiddleware($callable, $received[0]);
243-
$this->assertSame($middleware, $received[1]);
244-
}
245197
}

0 commit comments

Comments
 (0)