diff --git a/tests/AppTest.php b/tests/AppTest.php index d3d77f58b..13ffe0073 100644 --- a/tests/AppTest.php +++ b/tests/AppTest.php @@ -236,7 +236,7 @@ public function testInvokeWithMatchingRouteWithAttribute() { $app = new App(); $app->get('/foo/bar', function ($req, $res, $args) { - return $res->write("Hello {$args['attribute']}"); + return $res->write("Hello {$req->getAttribute('attribute')}"); })->setAttribute('attribute', 'world!'); // Prepare request and response objects @@ -264,7 +264,7 @@ public function testInvokeWithMatchingRouteWithAttributes() { $app = new App(); $app->get('/foo/bar', function ($req, $res, $args) { - return $res->write("Hello {$args['attribute1']} {$args['attribute2']}"); + return $res->write("Hello {$req->getAttribute('attribute1')} {$req->getAttribute('attribute2')}"); })->setAttributes(['attribute1' => 'there', 'attribute2' => 'world!']); // Prepare request and response objects @@ -349,34 +349,6 @@ public function testInvokeWithMatchingRouteWithNamedParameterRequestResponseArgS $this->assertEquals('Hello test!', (string)$res->getBody()); } - public function testInvokeWithMatchingRouteWithNamedParameterOverwritesAttribute() - { - $app = new App(); - $app->get('/foo/{name}', function ($req, $res, $args) { - return $res->write("Hello {$args['extra']} {$args['name']}"); - })->setAttributes(['extra' => 'there', 'name' => 'world!']); - - // Prepare request and response objects - $env = Environment::mock([ - 'SCRIPT_NAME' => '/index.php', - 'REQUEST_URI' => '/foo/test!', - 'REQUEST_METHOD' => 'GET', - ]); - $uri = Uri::createFromEnvironment($env); - $headers = Headers::createFromEnvironment($env); - $cookies = []; - $serverParams = $env->all(); - $body = new Body(fopen('php://temp', 'r+')); - $req = new Request('GET', $uri, $headers, $cookies, $serverParams, $body); - $res = new Response(); - - // Invoke app - $resOut = $app($req, $res); - - $this->assertInstanceOf('\Psr\Http\Message\ResponseInterface', $resOut); - $this->assertEquals('Hello there test!', (string)$res->getBody()); - } - public function testInvokeWithoutMatchingRoute() { $app = new App();