Code Duplication    Length = 56-59 lines in 3 locations

tests/Renderer/CsvRendererTest.php 1 location

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

tests/Renderer/ListRendererTest.php 1 location

@@ 14-69 (lines=56) @@
11
/**
12
 * @author Guillaume Cavana <[email protected]>
13
 */
14
class ListRendererTest extends \PHPUnit_Framework_TestCase
15
{
16
    /**
17
     * @var BufferedIO
18
     */
19
    private $io;
20
21
    protected function setUp()
22
    {
23
        $this->io = new BufferedIO();
24
    }
25
26
    /**
27
     * testTableRenderer.
28
     */
29
    public function testListRenderer()
30
    {
31
        $renderer = RendererFactory::create('list', $this->io);
32
        $renderer->render($this->createResultCollection());
33
34
        $output = <<<TABLE
35
[FAIL][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($this->createUrlInfo(), 200, 0.42);
49
50
        $resultCollection = new ResultCollection();
51
        $resultCollection->append($result);
52
53
        return $resultCollection;
54
    }
55
56
    private function createUrlInfo()
57
    {
58
        return new UrlInfo(
59
            'Example',
60
            'http://example.com',
61
            'GET',
62
            [],
63
            1,
64
            404,
65
            null,
66
            null
67
        );
68
    }
69
}
70

tests/Renderer/TableRendererTest.php 1 location

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