| @@ 13-55 (lines=43) @@ | ||
| 10 | /** |
|
| 11 | * @author Guillaume Cavana <[email protected]> |
|
| 12 | */ |
|
| 13 | class CsvRendererTest extends \PHPUnit_Framework_TestCase |
|
| 14 | { |
|
| 15 | /** |
|
| 16 | * @var BufferedIO |
|
| 17 | */ |
|
| 18 | private $io; |
|
| 19 | ||
| 20 | protected function setUp() |
|
| 21 | { |
|
| 22 | $this->io = new BufferedIO(); |
|
| 23 | } |
|
| 24 | ||
| 25 | /** |
|
| 26 | * testTableRenderer. |
|
| 27 | */ |
|
| 28 | public function testTableRenderer() |
|
| 29 | { |
|
| 30 | $renderer = RendererFactory::create('csv', $this->io); |
|
| 31 | $renderer->render($this->createResultCollection()); |
|
| 32 | ||
| 33 | $output = <<<TABLE |
|
| 34 | "Global Status","Status Code",Name,"Reponse Time" |
|
| 35 | OK,200,Example,0.42 |
|
| 36 | ||
| 37 | TABLE; |
|
| 38 | ||
| 39 | $this->assertInstanceOf(RendererInterface::class, $renderer); |
|
| 40 | $this->assertSame($output, $this->io->fetchOutput()); |
|
| 41 | } |
|
| 42 | ||
| 43 | /** |
|
| 44 | * createResultCollection. |
|
| 45 | */ |
|
| 46 | public function createResultCollection() |
|
| 47 | { |
|
| 48 | $result = new Result('Example', 200, 0.42, 200); |
|
| 49 | ||
| 50 | $resultCollection = new ResultCollection(); |
|
| 51 | $resultCollection->append($result); |
|
| 52 | ||
| 53 | return $resultCollection; |
|
| 54 | } |
|
| 55 | } |
|
| 56 | ||
| @@ 13-54 (lines=42) @@ | ||
| 10 | /** |
|
| 11 | * @author Guillaume Cavana <[email protected]> |
|
| 12 | */ |
|
| 13 | class ListRendererTest extends \PHPUnit_Framework_TestCase |
|
| 14 | { |
|
| 15 | /** |
|
| 16 | * @var BufferedIO |
|
| 17 | */ |
|
| 18 | private $io; |
|
| 19 | ||
| 20 | protected function setUp() |
|
| 21 | { |
|
| 22 | $this->io = new BufferedIO(); |
|
| 23 | } |
|
| 24 | ||
| 25 | /** |
|
| 26 | * testTableRenderer. |
|
| 27 | */ |
|
| 28 | public function testListRenderer() |
|
| 29 | { |
|
| 30 | $renderer = RendererFactory::create('list', $this->io); |
|
| 31 | $renderer->render($this->createResultCollection()); |
|
| 32 | ||
| 33 | $output = <<<TABLE |
|
| 34 | [FAIL][200] Example - 0.42 |
|
| 35 | ||
| 36 | TABLE; |
|
| 37 | ||
| 38 | $this->assertInstanceOf(RendererInterface::class, $renderer); |
|
| 39 | $this->assertSame($output, $this->io->fetchOutput()); |
|
| 40 | } |
|
| 41 | ||
| 42 | /** |
|
| 43 | * createResultCollection. |
|
| 44 | */ |
|
| 45 | public function createResultCollection() |
|
| 46 | { |
|
| 47 | $result = new Result('Example', 200, 0.42, 404); |
|
| 48 | ||
| 49 | $resultCollection = new ResultCollection(); |
|
| 50 | $resultCollection->append($result); |
|
| 51 | ||
| 52 | return $resultCollection; |
|
| 53 | } |
|
| 54 | } |
|
| 55 | ||
| @@ 13-57 (lines=45) @@ | ||
| 10 | /** |
|
| 11 | * @author Guillaume Cavana <[email protected]> |
|
| 12 | */ |
|
| 13 | class TableRendererTest extends \PHPUnit_Framework_TestCase |
|
| 14 | { |
|
| 15 | /** |
|
| 16 | * @var BufferedIO |
|
| 17 | */ |
|
| 18 | private $io; |
|
| 19 | ||
| 20 | protected function setUp() |
|
| 21 | { |
|
| 22 | $this->io = new BufferedIO(); |
|
| 23 | } |
|
| 24 | ||
| 25 | /** |
|
| 26 | * testTableRenderer. |
|
| 27 | */ |
|
| 28 | public function testTableRenderer() |
|
| 29 | { |
|
| 30 | $renderer = RendererFactory::create('table', $this->io); |
|
| 31 | $renderer->render($this->createResultCollection()); |
|
| 32 | ||
| 33 | $output = <<<TABLE |
|
| 34 | +---------------+-------------+---------+---------------+ |
|
| 35 | | Global Status | Status Code | Name | Response Time | |
|
| 36 | +---------------+-------------+---------+---------------+ |
|
| 37 | | FAIL | 200 | Example | 0.42 | |
|
| 38 | +---------------+-------------+---------+---------------+ |
|
| 39 | ||
| 40 | TABLE; |
|
| 41 | $this->assertInstanceOf(RendererInterface::class, $renderer); |
|
| 42 | $this->assertSame($output, $this->io->fetchOutput()); |
|
| 43 | } |
|
| 44 | ||
| 45 | /** |
|
| 46 | * createResultCollection. |
|
| 47 | */ |
|
| 48 | public function createResultCollection() |
|
| 49 | { |
|
| 50 | $result = new Result('Example', 200, 0.42, 404); |
|
| 51 | ||
| 52 | $resultCollection = new ResultCollection(); |
|
| 53 | $resultCollection->append($result); |
|
| 54 | ||
| 55 | return $resultCollection; |
|
| 56 | } |
|
| 57 | } |
|
| 58 | ||