Completed
Pull Request — master (#912)
by
unknown
07:49
created

TextRendererTest::rendering()   B

Complexity

Conditions 1
Paths 1

Size

Total Lines 25
Code Lines 11

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 25
rs 8.8571
c 0
b 0
f 0
cc 1
eloc 11
nc 1
nop 0
1
<?php
2
/**
3
 * this file is part of magerun
4
 *
5
 * @author Tom Klingenberg <https://github.com/ktomk>
6
 */
7
8
namespace N98\Util\Console\Helper\Table\Renderer;
9
10
use Symfony\Component\Console\Output\StreamOutput;
11
12
/**
13
 * Class TextRendererTest
14
 *
15
 * @covers  N98\Util\Console\Helper\Table\Renderer\TextRenderer
16
 * @package N98\Util\Console\Helper\Table\Renderer
17
 */
18
class TextRendererTest extends TestCase
19
{
20
    /**
21
     * @test
22
     */
23 View Code Duplication
    public function creation()
0 ignored issues
show
Duplication introduced by
This method 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...
24
    {
25
        $renderer = new TextRenderer();
26
        $this->assertInstanceOf(__NAMESPACE__ . '\\TextRenderer', $renderer);
27
28
        $renderFactory = new RendererFactory();
29
30
        $renderer = $renderFactory->create('text');
31
        $this->assertInstanceOf(__NAMESPACE__ . '\\TextRenderer', $renderer);
32
    }
33
34
    /**
35
     * @test
36
     */
37
    public function rendering()
38
    {
39
        $renderer = new TextRenderer();
40
        $output = new StreamOutput(fopen('php://memory', 'w', false));
41
42
        $rows = array(
43
            array('Column1' => 'Value A1', 'Column2' => 'A2 is another value that there is'),
44
            array(1, "multi\nline\nftw"),
45
            array("C1 cell here!", new \SimpleXMLElement('<r>PHP Magic->toString() test</r>')),
46
        );
47
48
        $expected = '+---------------+-----------------------------------+
49
| Column1       | Column2                           |
50
+---------------+-----------------------------------+
51
| Value A1      | A2 is another value that there is |
52
| 1             | multi                             |
53
|               | line                              |
54
|               | ftw                               |
55
| C1 cell here! | PHP Magic->toString() test        |
56
+---------------+-----------------------------------+' . "\n";
57
58
        $renderer->render($output, $rows);
59
60
        $this->assertEquals($expected, $this->getOutputBuffer($output));
61
    }
62
}
63