Commit 66b964dd authored by webchick's avatar webchick

Issue #2400407 by DuaelFr: Ensure vendor stack/builder is on latest stable release

parent a8d4b648
......@@ -2003,16 +2003,16 @@
},
{
"name": "stack/builder",
"version": "v1.0.2",
"version": "v1.0.3",
"source": {
"type": "git",
"url": "https://github.com/stackphp/builder.git",
"reference": "b4af43e7b7f3f7fac919ff475b29f7c5dc7b23b7"
"reference": "c1f8a4693b55c563405024f708a76ef576c3b276"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/stackphp/builder/zipball/b4af43e7b7f3f7fac919ff475b29f7c5dc7b23b7",
"reference": "b4af43e7b7f3f7fac919ff475b29f7c5dc7b23b7",
"url": "https://api.github.com/repos/stackphp/builder/zipball/c1f8a4693b55c563405024f708a76ef576c3b276",
"reference": "c1f8a4693b55c563405024f708a76ef576c3b276",
"shasum": ""
},
"require": {
......@@ -2041,15 +2041,14 @@
"authors": [
{
"name": "Igor Wiedler",
"email": "igor@wiedler.ch",
"homepage": "http://wiedler.ch/igor/"
"email": "igor@wiedler.ch"
}
],
"description": "Builder for stack middlewares based on HttpKernelInterface.",
"keywords": [
"stack"
],
"time": "2014-01-28 19:42:24"
"time": "2014-11-23 20:37:11"
},
{
"name": "symfony-cmf/routing",
......
......@@ -39,58 +39,6 @@
"psr-3"
]
},
{
"name": "stack/builder",
"version": "v1.0.2",
"version_normalized": "1.0.2.0",
"source": {
"type": "git",
"url": "https://github.com/stackphp/builder.git",
"reference": "b4af43e7b7f3f7fac919ff475b29f7c5dc7b23b7"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/stackphp/builder/zipball/b4af43e7b7f3f7fac919ff475b29f7c5dc7b23b7",
"reference": "b4af43e7b7f3f7fac919ff475b29f7c5dc7b23b7",
"shasum": ""
},
"require": {
"php": ">=5.3.0",
"symfony/http-foundation": "~2.1",
"symfony/http-kernel": "~2.1"
},
"require-dev": {
"silex/silex": "~1.0"
},
"time": "2014-01-28 19:42:24",
"type": "library",
"extra": {
"branch-alias": {
"dev-master": "1.0-dev"
}
},
"installation-source": "dist",
"autoload": {
"psr-0": {
"Stack": "src"
}
},
"notification-url": "https://packagist.org/downloads/",
"license": [
"MIT"
],
"authors": [
{
"name": "Igor Wiedler",
"email": "igor@wiedler.ch",
"homepage": "http://wiedler.ch/igor/"
}
],
"description": "Builder for stack middlewares based on HttpKernelInterface.",
"keywords": [
"stack"
]
},
{
"name": "symfony-cmf/routing",
"version": "1.3.0",
......@@ -3484,5 +3432,56 @@
],
"description": "Library that helps with managing the version number of Git-hosted PHP projects",
"homepage": "https://github.com/sebastianbergmann/version"
},
{
"name": "stack/builder",
"version": "v1.0.3",
"version_normalized": "1.0.3.0",
"source": {
"type": "git",
"url": "https://github.com/stackphp/builder.git",
"reference": "c1f8a4693b55c563405024f708a76ef576c3b276"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/stackphp/builder/zipball/c1f8a4693b55c563405024f708a76ef576c3b276",
"reference": "c1f8a4693b55c563405024f708a76ef576c3b276",
"shasum": ""
},
"require": {
"php": ">=5.3.0",
"symfony/http-foundation": "~2.1",
"symfony/http-kernel": "~2.1"
},
"require-dev": {
"silex/silex": "~1.0"
},
"time": "2014-11-23 20:37:11",
"type": "library",
"extra": {
"branch-alias": {
"dev-master": "1.0-dev"
}
},
"installation-source": "dist",
"autoload": {
"psr-0": {
"Stack": "src"
}
},
"notification-url": "https://packagist.org/downloads/",
"license": [
"MIT"
],
"authors": [
{
"name": "Igor Wiedler",
"email": "igor@wiedler.ch"
}
],
"description": "Builder for stack middlewares based on HttpKernelInterface.",
"keywords": [
"stack"
]
}
]
......@@ -5,6 +5,7 @@ php:
- 5.3
- 5.4
- 5.5
- 5.6
- hhvm
before_script:
......
CHANGELOG
=========
* 1.0.2 (2014-xx-xx)
* 1.0.3 (2014-11-23)
* Only call Terminable middlewares once.
* 1.0.2 (2014-05-18)
* Validate missing arguments (@bajbnet).
......
......@@ -25,10 +25,13 @@ public function handle(Request $request, $type = HttpKernelInterface::MASTER_REQ
public function terminate(Request $request, Response $response)
{
$prevKernel = null;
foreach ($this->middlewares as $kernel) {
if ($kernel instanceof TerminableInterface) {
// if prev kernel was terminable we can assume this middleware has already been called
if (!$prevKernel instanceof TerminableInterface && $kernel instanceof TerminableInterface) {
$kernel->terminate($request, $response);
}
$prevKernel = $kernel;
}
}
}
......@@ -25,9 +25,9 @@ public function handleShouldDelegateToApp()
public function handleShouldStillDelegateToAppWithMiddlewares()
{
$app = $this->getHttpKernelMock(new Response('ok'));
$foo = $this->getHttpKernelMock(new Response('foo'));
$bar = $this->getHttpKernelMock(new Response('bar'));
$kernel = new StackedHttpKernel($app, array($app, $foo, $bar));
$foo = $this->getHttpKernelMock(new Response('foo'));
$kernel = new StackedHttpKernel($app, array($foo, $bar, $app));
$request = Request::create('/');
$response = $kernel->handle($request);
......@@ -38,14 +38,28 @@ public function handleShouldStillDelegateToAppWithMiddlewares()
/** @test */
public function terminateShouldDelegateToMiddlewares()
{
$app = $this->getTerminableMock(new Response('ok'));
$foo = $this->getTerminableMock();
$bar = $this->getTerminableMock();
$kernel = new StackedHttpKernel($app, array($app, $foo, $bar));
$first = new TerminableKernelSpy();
$second = new TerminableKernelSpy($first);
$third = new KernelSpy($second);
$fourth = new TerminableKernelSpy($third);
$fifth = new TerminableKernelSpy($fourth);
$kernel = new StackedHttpKernel($fifth, $middlewares = array($fifth, $fourth, $third, $second, $first));
$request = Request::create('/');
$response = $kernel->handle($request);
$kernel->terminate($request, $response);
$this->assertTerminablesCalledOnce($middlewares);
}
private function assertTerminablesCalledOnce(array $middlewares)
{
foreach ($middlewares as $kernel) {
if ($kernel instanceof TerminableInterface) {
$this->assertEquals(1, $kernel->terminateCallCount(), "Terminate was called {$kernel->terminateCallCount()} times");
}
}
}
private function getHttpKernelMock(Response $response)
......@@ -77,4 +91,65 @@ private function getTerminableMock(Response $response = null)
return $app;
}
private function getDelegatingTerminableMock(TerminableInterface $next)
{
$app = $this->getMock('Stack\TerminableHttpKernel');
$app->expects($this->once())
->method('terminate')
->with(
$this->isInstanceOf('Symfony\Component\HttpFoundation\Request'),
$this->isInstanceOf('Symfony\Component\HttpFoundation\Response')
)
->will($this->returnCallback(function ($request, $response) use ($next) {
$next->terminate($request, $response);
}));
return $app;
}
}
class KernelSpy implements HttpKernelInterface
{
private $handleCallCount = 0;
public function __construct(HttpKernelInterface $kernel = null)
{
$this->kernel = $kernel;
}
public function handle(Request $request, $type = HttpKernelInterface::MASTER_REQUEST, $catch = true)
{
$this->handleCallCount++;
if ($this->kernel) {
return $this->kernel->handle($request, $type, $catch);
}
return new Response('OK');
}
public function handleCallCount()
{
return $this->handleCallCount;
}
}
class TerminableKernelSpy extends KernelSpy implements TerminableInterface
{
private $terminateCallCount = 0;
public function terminate(Request $request, Response $response)
{
$this->terminateCallCount++;
if ($this->kernel && $this->kernel instanceof TerminableInterface) {
return $this->kernel->terminate($request, $response);
}
}
public function terminateCallCount()
{
return $this->terminateCallCount;
}
}
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment