Skip to content

Commit

Permalink
Update Zend\Mvc unit tests for changes
Browse files Browse the repository at this point in the history
- Fixed a couple of bugs exposed by the unit tests
- Zend\Mvc unit tests no longer expect Zend\Mvc\SendableResponse
- Remove leftover unit test files
  • Loading branch information
EvanDotPro committed Oct 31, 2011
1 parent 5d37c47 commit 06f76d1
Show file tree
Hide file tree
Showing 5 changed files with 22 additions and 161 deletions.
11 changes: 9 additions & 2 deletions library/Zend/Http/PhpEnvironment/Request.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@

use Zend\Http\Request as HttpRequest,
Zend\Uri\Http as HttpUri,
Zend\Http\Header\Cookie,
Zend\Stdlib\Parameters,
Zend\Stdlib\ParametersDescription;

Expand All @@ -16,13 +17,19 @@ public function __construct()
$this->setQuery(new Parameters($_GET));
$this->setServer(new Parameters($_SERVER));
if ($_COOKIE) {
$this->setCookies(new Parameters($_COOKIE));
$this->setCookies($_COOKIE);
}
if ($_FILES) {
$this->setFiles(new Parameters($_FILES));
$this->setFile(new Parameters($_FILES));
}
}

public function setCookies($cookie)
{
$this->headers()->addHeader(new Cookie((array) $cookie));
return $this;
}

/**
* Provide an alternate Parameter Container implementation for server parameters in this object, (this is NOT the
* primary API for value setting, for that see server())
Expand Down
23 changes: 13 additions & 10 deletions tests/Zend/Mvc/ApplicationTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
Zend\EventManager\EventManager,
Zend\EventManager\StaticEventManager,
Zend\Http\Request,
Zend\Http\Response,
Zend\Http\PhpEnvironment\Response,
Zend\Mvc\Application,
Zend\Mvc\Router,
Zend\Uri\UriFactory;
Expand Down Expand Up @@ -234,26 +234,26 @@ public function testAllowsReturningEarlyFromRouting()
});

$result = $app->run();
$this->assertSame($response, $result->getResponse());
$this->assertSame($response, $result);
}

public function testControllerIsDispatchedDuringRun()
{
$app = $this->setupPathController();

$response = $app->run()->getResponse();
$response = $app->run();
$this->assertContains('PathController', $response->getContent());
$this->assertContains('dispatch', $response->getContent());
$this->assertContains('dispatch', $response->toString());
}

public function testDefaultRequestObjectContainsPhpEnvironmentContainers()
{
$app = new Application();
$request = $app->getRequest();
$query = $request->query();
$this->assertInstanceOf('Zend\Mvc\PhpEnvironment\GetContainer', $query);
$this->assertInstanceOf('Zend\Stdlib\Parameters', $query);
$post = $request->post();
$this->assertInstanceOf('Zend\Mvc\PhpEnvironment\PostContainer', $post);
$this->assertInstanceOf('Zend\Stdlib\Parameters', $post);
}

public function testDefaultRequestObjectMirrorsEnvSuperglobal()
Expand Down Expand Up @@ -344,7 +344,10 @@ public function testDefaultRequestObjectRequestMethodMirrorsServerHttpMethodKey(

public function testDefaultRequestObjectContainsUriCreatedFromServerRequestUri()
{
$_SERVER['REQUEST_URI'] = 'http://framework.zend.com/api/zf-version?test=this';
$_SERVER['HTTP_HOST'] = 'framework.zend.com';
$_SERVER['REQUEST_URI'] = '/api/zf-version?test=this';
$_SERVER['QUERY_STRING'] = 'test=this';

$app = new Application();
$req = $app->getRequest();

Expand Down Expand Up @@ -378,7 +381,7 @@ public function testPostDispatchResultIsPassedByReferenceToEventListeners()
return $response;
});

$response = $app->run()->getResponse();
$response = $app->run();
$response = json_decode($response->getContent());
$this->assertTrue(isset($response->foo), var_export($response, 1));
$this->assertEquals('bar', $response->foo);
Expand Down Expand Up @@ -428,7 +431,7 @@ public function testFinishEventIsTriggeredAfterDispatching()
$app->events()->attach('finish', function($e) {
return $e->getResponse()->setContent($e->getResponse()->getBody() . 'foobar');
});
$this->assertContains('foobar', $app->run()->getResponse()->getBody(), 'The "finish" event was not triggered ("foobar" not in response)');
$this->assertContains('foobar', $app->run()->getBody(), 'The "finish" event was not triggered ("foobar" not in response)');
}

public function testCanProvideAlternateEventManagerToDisableDefaultRouteAndDispatchEventListeners()
Expand Down Expand Up @@ -561,6 +564,6 @@ public function testLocatorExceptionShouldTriggerDispatchError()
});

$result = $app->run();
$this->assertSame($response, $result->getResponse());
$this->assertSame($response, $result);
}
}
107 changes: 0 additions & 107 deletions tests/Zend/Mvc/PhpEnvironment/AbstractContainerTest.php

This file was deleted.

21 changes: 0 additions & 21 deletions tests/Zend/Mvc/PhpEnvironment/GetContainerTest.php

This file was deleted.

21 changes: 0 additions & 21 deletions tests/Zend/Mvc/PhpEnvironment/PostContainerTest.php

This file was deleted.

0 comments on commit 06f76d1

Please sign in to comment.