Skip to content

Commit a780569

Browse files
committed
:octocat: reverse priority order
1 parent 4f0bd65 commit a780569

File tree

2 files changed

+6
-6
lines changed

2 files changed

+6
-6
lines changed

src/Psr15/PriorityQueueRequestHandler.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@ public function add(MiddlewareInterface $middleware):QueueRequestHandler{
6363
*/
6464
protected function sortMiddleware():void{
6565
\usort($this->middlewareStack, function(PriorityMiddlewareInterface $a, PriorityMiddlewareInterface $b){
66-
return $a->getPriority() > $b->getPriority();
66+
return $a->getPriority() < $b->getPriority();
6767
});
6868
}
6969

tests/Psr15/PriorityQueueRequestHandlerTest.php

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,8 @@
1212

1313
namespace chillerlan\HTTPTest\Psr15;
1414

15-
use chillerlan\HTTP\Psr17;
16-
use chillerlan\HTTP\Psr15\{EmptyResponseHandler, PriorityQueueRequestHandler};
15+
use chillerlan\HTTP\{Psr15\QueueRunner, Psr17, Psr7};
16+
use chillerlan\HTTP\Psr15\PriorityQueueRequestHandler;
1717
use chillerlan\HTTP\Psr15\Middleware\{MiddlewareException, PriorityMiddleware};
1818
use PHPUnit\Framework\TestCase;
1919
use Psr\Http\Message\{ResponseInterface, ServerRequestInterface};
@@ -48,9 +48,9 @@ public function process(ServerRequestInterface $request, RequestHandlerInterface
4848
// execute it:
4949
$response = $handler->handle(Psr17\create_server_request_from_globals());
5050

51-
// highest priority shall go out first
51+
// highest priority shall be processed first and go out last
5252
$this->assertSame(
53-
['X-Priority-3', 'X-Priority-2', 'X-Priority-1', 'X-Priority-none1', 'X-Priority-none0'],
53+
['X-Priority-none1', 'X-Priority-none0', 'X-Priority-1', 'X-Priority-2', 'X-Priority-3'],
5454
array_keys($response->getHeaders())
5555
);
5656
}
@@ -75,7 +75,7 @@ public function testNestedHandler(){
7575
$response = $handler->handle(Psr17\create_server_request_from_globals());
7676

7777
$this->assertSame(
78-
['X-Priority-4', 'X-Priority-3', 'X-Priority-33', 'X-Priority-22', 'X-Priority-11', 'X-Priority-1'],
78+
['X-Priority-1', 'X-Priority-11', 'X-Priority-22', 'X-Priority-33', 'X-Priority-3', 'X-Priority-4'],
7979
array_keys($response->getHeaders())
8080
);
8181
}

0 commit comments

Comments
 (0)