Skip to content

Commit

Permalink
Merge pull request #153 from ppi/fixing-app-run-test
Browse files Browse the repository at this point in the history
Switching app->run() to app->dispatch() on unit tests to avoid STDOUT output
  • Loading branch information
vitorbrandao committed Jan 11, 2016
2 parents a319ef7 + 42fe94f commit d8f31a7
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 6 deletions.
3 changes: 0 additions & 3 deletions src/App.php
Expand Up @@ -246,9 +246,6 @@ public function run(HttpRequest $request = null, HttpResponse $response = null)
$this->boot();
}

$request = $request ?: HttpRequest::createFromGlobals();
$response = $response ?: new HttpResponse();

$response = $this->dispatch($request, $response);
$response->send();

Expand Down
10 changes: 7 additions & 3 deletions tests/AppTest.php
Expand Up @@ -10,11 +10,12 @@

namespace PPI\FrameworkTest;

use PPI\Framework\Module\Controller\ControllerResolver;
use PPI\Framework\ServiceManager\ServiceManager;
use PPI\FrameworkTest\Fixtures\AppForDispatchTest;
use PPI\FrameworkTest\Fixtures\AppForTest;
use Symfony\Component\HttpFoundation\Response;
use PPI\Framework\Http\Request as HttpRequest;
use PPI\Framework\Http\Response as HttpResponse;

/**
* Class AppTest.
Expand Down Expand Up @@ -94,7 +95,7 @@ public function testGetName()
$this->assertEquals('testName', $app->getName());
}

public function testRun()
public function testDispatch()
{
$app = new AppForDispatchTest(array(
'environment' => 'test',
Expand Down Expand Up @@ -123,7 +124,10 @@ public function testRun()
$sm->set('ControllerResolver', $mockControllerResolver);
$app->setServiceManager($sm);

$response = $app->run();
$request = HttpRequest::createFromGlobals();
$response = new HttpResponse();

$response = $app->dispatch($request, $response);
$this->assertInstanceOf('\Symfony\Component\HttpFoundation\Response', $response);
$this->assertEquals($response->getContent(), 'Working Response');
}
Expand Down

0 comments on commit d8f31a7

Please sign in to comment.