|
1
|
|
|
<?php |
|
2
|
|
|
|
|
3
|
|
|
namespace Kint\Test; |
|
4
|
|
|
|
|
5
|
|
|
use Kint; |
|
6
|
|
|
use Kint\Object\BlobObject; |
|
7
|
|
|
use PHPUnit_Framework_AssertionFailedError; |
|
8
|
|
|
use PHPUnit_Framework_Exception; |
|
9
|
|
|
|
|
10
|
|
|
class IntegrationTest extends KintTestCase |
|
11
|
|
|
{ |
|
12
|
|
|
/** |
|
13
|
|
|
* @covers \d |
|
14
|
|
|
* @covers \s |
|
15
|
|
|
* @covers \Kint::dump |
|
16
|
|
|
*/ |
|
17
|
|
|
public function testBasicDumps() |
|
18
|
|
|
{ |
|
19
|
|
|
$testdata = array( |
|
20
|
|
|
1234, |
|
21
|
|
|
(object) array('abc' => 'def'), |
|
22
|
|
|
1234.5678, |
|
23
|
|
|
'Good news everyone! I\'ve got some bad news!', |
|
24
|
|
|
null, |
|
25
|
|
|
); |
|
26
|
|
|
|
|
27
|
|
|
$testdata[] = &$testdata; |
|
28
|
|
|
|
|
29
|
|
|
$array_structure = array( |
|
30
|
|
|
'0', 'integer', '1234', |
|
31
|
|
|
'1', 'stdClass', '1', |
|
32
|
|
|
'public', 'abc', 'string', '3', 'def', |
|
33
|
|
|
'2', 'double', '1234.5678', |
|
34
|
|
|
'3', 'string', '43', 'Good news everyone! I\'ve got some bad news!', |
|
35
|
|
|
'4', 'null', |
|
36
|
|
|
); |
|
37
|
|
|
|
|
38
|
|
|
Kint::$return = true; |
|
39
|
|
|
Kint::$cli_detection = false; |
|
40
|
|
|
Kint::$display_called_from = false; |
|
41
|
|
|
|
|
42
|
|
|
Kint::$enabled_mode = Kint::MODE_RICH; |
|
43
|
|
|
$richbase = d($testdata); |
|
44
|
|
|
|
|
45
|
|
|
$this->assertLike( |
|
46
|
|
|
array_merge( |
|
47
|
|
|
$array_structure, |
|
48
|
|
|
array('&array', '6'), |
|
49
|
|
|
$array_structure, |
|
50
|
|
|
array('&array', 'Recursion') |
|
51
|
|
|
), |
|
52
|
|
|
$richbase |
|
53
|
|
|
); |
|
54
|
|
|
|
|
55
|
|
|
Kint::$enabled_mode = true; |
|
56
|
|
|
$this->assertSame($richbase, d($testdata)); |
|
57
|
|
|
$this->assertSame($richbase, Kint::dump($testdata)); |
|
58
|
|
|
|
|
59
|
|
|
Kint::$enabled_mode = Kint::MODE_PLAIN; |
|
60
|
|
|
$plainbase = d($testdata); |
|
61
|
|
|
|
|
62
|
|
|
$this->assertLike( |
|
63
|
|
|
array_merge( |
|
64
|
|
|
$array_structure, |
|
65
|
|
|
array('&array', '6'), |
|
66
|
|
|
$array_structure, |
|
67
|
|
|
array('&array', 'RECURSION') |
|
68
|
|
|
), |
|
69
|
|
|
$plainbase |
|
70
|
|
|
); |
|
71
|
|
|
|
|
72
|
|
|
$this->assertSame($plainbase, Kint::dump($testdata)); |
|
73
|
|
|
|
|
74
|
|
|
Kint::$enabled_mode = true; |
|
75
|
|
|
$this->assertSame($plainbase, s($testdata)); |
|
76
|
|
|
|
|
77
|
|
|
Kint::$enabled_mode = Kint::MODE_CLI; |
|
78
|
|
|
$clibase = d($testdata); |
|
79
|
|
|
|
|
80
|
|
|
$this->assertLike( |
|
81
|
|
|
array_merge( |
|
82
|
|
|
$array_structure, |
|
83
|
|
|
array('&array', '6'), |
|
84
|
|
|
$array_structure, |
|
85
|
|
|
array('&array', 'RECURSION') |
|
86
|
|
|
), |
|
87
|
|
|
$clibase |
|
88
|
|
|
); |
|
89
|
|
|
|
|
90
|
|
|
$this->assertSame($clibase, Kint::dump($testdata)); |
|
91
|
|
|
|
|
92
|
|
|
Kint::$enabled_mode = true; |
|
93
|
|
|
Kint::$cli_detection = true; |
|
94
|
|
|
$this->assertSame($clibase, d($testdata)); |
|
95
|
|
|
$this->assertSame($clibase, s($testdata)); |
|
96
|
|
|
Kint::$cli_detection = false; |
|
97
|
|
|
|
|
98
|
|
|
Kint::$enabled_mode = Kint::MODE_TEXT; |
|
99
|
|
|
$textbase = d($testdata); |
|
100
|
|
|
|
|
101
|
|
|
$this->assertLike( |
|
102
|
|
|
array_merge( |
|
103
|
|
|
$array_structure, |
|
104
|
|
|
array('&array', '6'), |
|
105
|
|
|
$array_structure, |
|
106
|
|
|
array('&array', 'RECURSION') |
|
107
|
|
|
), |
|
108
|
|
|
$textbase |
|
109
|
|
|
); |
|
110
|
|
|
|
|
111
|
|
|
$this->assertSame($textbase, Kint::dump($testdata)); |
|
112
|
|
|
|
|
113
|
|
|
Kint::$return = false; |
|
114
|
|
|
Kint::$enabled_mode = true; |
|
115
|
|
|
ob_start(); |
|
116
|
|
|
~d($testdata); |
|
117
|
|
|
$this->assertSame($textbase, ob_get_clean()); |
|
118
|
|
|
|
|
119
|
|
|
Kint::$enabled_mode = false; |
|
120
|
|
|
$this->assertSame(0, d($testdata)); |
|
121
|
|
|
$this->assertSame(0, s($testdata)); |
|
122
|
|
|
} |
|
123
|
|
|
|
|
124
|
|
|
/** |
|
125
|
|
|
* Test this test suite's restore after test. |
|
126
|
|
|
* |
|
127
|
|
|
* @covers \Kint\Test\KintTestCase::setUp |
|
128
|
|
|
* @covers \Kint\Test\KintTestCase::tearDown |
|
129
|
|
|
*/ |
|
130
|
|
|
public function testStore() |
|
131
|
|
|
{ |
|
132
|
|
|
Kint::$file_link_format = 'test_store'; |
|
133
|
|
|
$this->assertEquals('test_store', Kint::$file_link_format); |
|
134
|
|
|
BlobObject::$char_encodings[] = 'this_is_not_a_real_encoding'; |
|
135
|
|
|
$this->assertContains('this_is_not_a_real_encoding', BlobObject::$char_encodings); |
|
136
|
|
|
} |
|
137
|
|
|
|
|
138
|
|
|
/** |
|
139
|
|
|
* @covers \Kint\Test\KintTestCase::setUp |
|
140
|
|
|
* @covers \Kint\Test\KintTestCase::tearDown |
|
141
|
|
|
*/ |
|
142
|
|
|
public function testRestore() |
|
143
|
|
|
{ |
|
144
|
|
|
$this->assertNotEquals('test_store', Kint::$file_link_format); |
|
145
|
|
|
$this->assertNotContains('this_is_not_a_real_encoding', BlobObject::$char_encodings); |
|
146
|
|
|
} |
|
147
|
|
|
|
|
148
|
|
|
/** |
|
149
|
|
|
* @covers \Kint\Test\KintTestCase::assertLike |
|
150
|
|
|
*/ |
|
151
|
|
|
public function testLike() |
|
152
|
|
|
{ |
|
153
|
|
|
$this->assertLike(array('a', 'b', 'c'), 'foo a bar baz c buzz'); |
|
154
|
|
|
} |
|
155
|
|
|
|
|
156
|
|
|
/** |
|
157
|
|
|
* @covers \Kint\Test\KintTestCase::assertLike |
|
158
|
|
|
*/ |
|
159
|
|
|
public function testNotLike() |
|
160
|
|
|
{ |
|
161
|
|
|
try { |
|
162
|
|
|
$this->assertLike(array('a', 'b', 'c', 'o'), 'foo a bar baz c buzz'); |
|
163
|
|
|
} catch (PHPUnit_Framework_AssertionFailedError $e) { |
|
164
|
|
|
return; |
|
165
|
|
|
} |
|
166
|
|
|
|
|
167
|
|
|
self::fail('Failed to mismatch'); |
|
168
|
|
|
} |
|
169
|
|
|
|
|
170
|
|
|
/** |
|
171
|
|
|
* @covers \Kint\Test\KintTestCase::assertLike |
|
172
|
|
|
*/ |
|
173
|
|
|
public function testLikeNonString() |
|
174
|
|
|
{ |
|
175
|
|
|
try { |
|
176
|
|
|
$this->assertLike(array('a', 'b', 'c'), array('a', 'b', 'c')); |
|
177
|
|
|
} catch (PHPUnit_Framework_Exception $e) { |
|
178
|
|
|
return; |
|
179
|
|
|
} |
|
180
|
|
|
|
|
181
|
|
|
self::fail('Failed to throw'); |
|
182
|
|
|
} |
|
183
|
|
|
} |
|
184
|
|
|
|