Skip to content

Commit

Permalink
Updated tests for changes to route arguments
Browse files Browse the repository at this point in the history
  • Loading branch information
AlexStansfield committed Jul 10, 2015
1 parent 87d29d7 commit 0204d3e
Showing 1 changed file with 2 additions and 30 deletions.
32 changes: 2 additions & 30 deletions tests/AppTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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();
Expand Down

0 comments on commit 0204d3e

Please sign in to comment.