created mocks for testing
This commit is contained in:
@@ -3,9 +3,11 @@
|
||||
namespace BSR\Webservice;
|
||||
|
||||
use BSR\Webservice\Formatter\Formatter;
|
||||
use PHPUnit\Framework\TestCase;
|
||||
|
||||
class Renderer {
|
||||
private static $statusMessages = array(
|
||||
class RendererTest extends TestCase
|
||||
{
|
||||
private $someData = array(
|
||||
200 => 'Ok',
|
||||
400 => 'Bad request',
|
||||
404 => 'Not Found',
|
||||
@@ -13,17 +15,15 @@ class Renderer {
|
||||
500 => 'Server Error',
|
||||
);
|
||||
|
||||
public function __construct() {
|
||||
public function testThatOutputBufferGetsInializedOnConstruction()
|
||||
{
|
||||
$text = 'This text should be captured by the renderers ob_start()';
|
||||
ob_start();
|
||||
}
|
||||
|
||||
public function render($status, $data) {
|
||||
header(sprintf('HTTP/1.0 %s %s', $status, self::$statusMessages[$status]));
|
||||
header("Access-Control-Allow-Origin: *");
|
||||
ob_clean();
|
||||
flush();
|
||||
|
||||
$formatter = Formatter::getFormatter();
|
||||
$formatter->render($data);
|
||||
echo 'Rubish text, that is not intended to be outputed';
|
||||
ob_get_clean();
|
||||
$renderer = new Renderer();
|
||||
echo $text;
|
||||
$obcontent = ob_get_clean();
|
||||
$this->assertSame($text, $obcontent);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user