Completed
Push — master ( b829e8...5d217f )
by Guillaume
02:31
created

CsvRendererTest::testTableRenderer()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 14
Code Lines 8

Duplication

Lines 14
Ratio 100 %

Importance

Changes 1
Bugs 0 Features 1
Metric Value
c 1
b 0
f 1
dl 14
loc 14
rs 9.4286
cc 1
eloc 8
nc 1
nop 0
1
<?php
2
3
namespace Hogosha\Monitor\Renderer;
4
5
use Hogosha\Monitor\Model\Result;
6
use Hogosha\Monitor\Model\ResultCollection;
7
use Hogosha\Monitor\Renderer\RendererFactory;
8
use Hogosha\Monitor\Renderer\RendererInterface;
9
use Hogosha\Monitor\Renderer\CsvRenderer;
10
use Webmozart\Console\Api\IO\IO;
11
use Webmozart\Console\IO\BufferedIO;
12
13
/**
14
 * @author Guillaume Cavana <[email protected]>
15
 */
16 View Code Duplication
class CsvRendererTest extends \PHPUnit_Framework_TestCase
0 ignored issues
show
Duplication introduced by
This class seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
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