Completed
Push — master ( aed5b3...caff4d )
by Michal
05:21
created

ReportsHelperTest::setUp()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 6
Code Lines 4

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
c 1
b 0
f 0
dl 0
loc 6
rs 9.4285
cc 1
eloc 4
nc 1
nop 0
1
<?php
2
/* vim: set expandtab sw=4 ts=4 sts=4: */
3
4
namespace App\Test\TestCase\View\Helper;
5
6
use App\View\Helper\ReportsHelper;
7
use Cake\TestSuite\TestCase;
8
use Cake\View\View;
9
10
class ReportsHelperTest extends TestCase
11
{
12
    public function setUp()
13
    {
14
        parent::setUp();
15
        $View = new View();
16
        $this->Reports = new ReportsHelper($View);
0 ignored issues
show
Bug introduced by
The property Reports does not exist. Did you maybe forget to declare it?

In PHP it is possible to write to properties without declaring them. For example, the following is perfectly valid PHP code:

class MyClass { }

$x = new MyClass();
$x->foo = true;

Generally, it is a good practice to explictly declare properties to avoid accidental typos and provide IDE auto-completion:

class MyClass {
    public $foo;
}

$x = new MyClass();
$x->foo = true;
Loading history...
17
    }
18
19
    /**
20
     * Provider for testLinkToReport
21
     *
22
     * @return array array data for testLinkToReport
23
     */
24 View Code Duplication
    public function providerForTestLinkToReport() {
25
        return array(
26
            array(
27
                array(
28
                    'id' => 116273,
29
                    'error_message' => 'TypeError: url is undefined',
30
                    'error_name' => null,
31
                    'pma_version' => '4.7.1',
32
                    'status' => 'new',
33
                    'location' => 'index.js',
34
                    'linenumber' => 154,
35
                    'sourceforge_bug_id' => null,
36
                    'related_to' => 12567,
37
                    'exception_type' => 'js'
38
                ),
39
                '<a href=/reports/view/116273>#116273</a>'
40
            ),
41
            array(
42
                array(
43
                    'id' => 1879,
44
                    'error_message' => 'TypeError: url is undefined',
45
                    'error_name' => null,
46
                    'pma_version' => '4.1.6',
47
                    'status' => 'new',
48
                    'location' => 'common.js',
49
                    'linenumber' => 154,
50
                    'sourceforge_bug_id' => null,
51
                    'related_to' => null,
52
                    'exception_type' => 'php'
53
                ),
54
                '<a href=/reports/view/1879>#1879</a>'
55
            )
56
        );
57
    }
58
59
    /**
60
     * @dataProvider providerForTestLinkToReport
61
     */
62
    public function testLinkToReport($report, $expected)
63
    {
64
        $link = $this->Reports->linkToReport($report);
65
66
        $this->assertEquals(
67
            $expected,
68
            $link
69
        );
70
    }
71
72
    /**
73
     * Provider for testCreateReportsLinks
74
     *
75
     * return array array data to testCreateReportsLinks
76
     */
77 View Code Duplication
    public function providerForTestCreateReportsLinks()
78
    {
79
        return array(
80
            array(
81
                array(
82
                    array(
83
                        'id' => 116273,
84
                        'error_message' => 'TypeError: url is undefined',
85
                        'error_name' => null,
86
                        'pma_version' => '4.7.1',
87
                        'status' => 'new',
88
                        'location' => 'index.js',
89
                        'linenumber' => 154,
90
                        'sourceforge_bug_id' => null,
91
                        'related_to' => 12567,
92
                        'exception_type' => 'js'
93
                    ),
94
                    array(
95
                        'id' => 1879,
96
                        'error_message' => 'TypeError: url is undefined',
97
                        'error_name' => null,
98
                        'pma_version' => '4.1.6',
99
                        'status' => 'new',
100
                        'location' => 'common.js',
101
                        'linenumber' => 154,
102
                        'sourceforge_bug_id' => null,
103
                        'related_to' => null,
104
                        'exception_type' => 'php'
105
                    ),
106
                ),
107
                '<a href=/reports/view/116273>#116273</a>, '
108
                    . '<a href=/reports/view/1879>#1879</a>'
109
            )
110
        );
111
    }
112
113
114
    /**
115
     * @dataProvider providerForTestCreateReportsLinks
116
     */
117
    public function testCreateReportsLinks($reports, $expected)
118
    {
119
        $links_str = $this->Reports->createReportsLinks($reports);
120
121
        $this->assertEquals(
122
            $expected,
123
            $links_str
124
        );
125
    }
126
}
127