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