public function testRunApplication() { $_SERVER['REQUEST_URI'] = '/some/prefix/response/set-body/custom.php?some-params'; $this->application->start(); self::assertTrue($this->response->hasBody()); self::assertEquals('foobar', $this->response->getBody()); }
public function testModifiingBody() { self::assertNull($this->response->getBody()); $this->response->appendToBody('foo'); self::assertEquals('foo', $this->response->getBody()); $this->response->appendToBody('bar'); self::assertEquals('foobar', $this->response->getBody()); $this->response->setBody('baz'); self::assertEquals('baz', $this->response->getBody()); }
public function update(\Nano\Controller\Response $response) { $contents = $response->getBody(); $response->setBody('<h1>Unexpected Error</h1>'); $response->appendToBody($contents); }
/** * @return \Nano\Controller\Redirect */ public function permanent() { $this->response->setStatus(301); return $this; }
public function testSendShouldDoNothing() { $this->response->send(); self::assertEquals(null, $this->getActualOutput()); }
protected function appendOutput(\Nano\Controller\Response $response, $buffer) { if (0 != strLen($buffer)) { $response->appendToBody('<hr />' . PHP_EOL); $response->appendToBody('Generated output: <pre>' . htmlSpecialChars($buffer) . '</pre>'); } }