Skip to content
This repository was archived by the owner on Aug 17, 2025. It is now read-only.
This repository was archived by the owner on Aug 17, 2025. It is now read-only.

Allow App To Be Run Without Sending Response #13

@bradley-holt

Description

@bradley-holt

The last line of the \Phlyty\App::run() method sends the response:

$this->response()->send();

The resultant output makes it difficult to perform functional testing. Take the following test case as an example:

public function testGetRootUri()
{
    $request = new \Zend\Http\PhpEnvironment\Request;
    $request->setMethod('GET');
    $request->setUri('/');
    $this->app->setRequest($request);
    $this->app->run();
    $response = $this->app->response();
    $this->assertEquals(200, $response->getStatusCode());
}

Without using output buffering, the body of the response will be output to the terminal when running the test.

It would be great if the \Phlyty\App::run() method included a parameter to send the response (which defaults to true for backwards compatibility). When this parameter is set to false, the $this->response()->send() line would not be called. This would allow me to run the app without sending the response output by simply calling $this->app->run(false). For bonus points, it would be nice if a) the \Phlyty\App::run() method returned the response object and b) I could pass a more generic version of the request object to the app for functional testing purposes.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions