1 | <?php |
||
8 | class FormatterTest extends \PHPUnit_Framework_TestCase |
||
9 | { |
||
10 | /** @var Formatter */ |
||
11 | protected $sut; |
||
12 | |||
13 | protected function setUp() |
||
17 | |||
18 | /** |
||
19 | * @covers DmFileman\Helper\FileInfo\Formatter |
||
20 | */ |
||
21 | public function testFormatSizeReturnsZeroIfSplInfoIsMissing() |
||
27 | |||
28 | /** |
||
29 | * @covers DmFileman\Helper\FileInfo\Formatter |
||
30 | * @requires PHP 5.6 |
||
31 | */ |
||
32 | public function testFormatSizeReturnsZeroOnZeroSizedSplInfo() |
||
42 | |||
43 | /** |
||
44 | * @covers DmFileman\Helper\FileInfo\Formatter |
||
45 | * @requires PHP 5.6 |
||
46 | */ |
||
47 | public function testFormatSizeReturnsFileSizeIfRawIsGiven() |
||
57 | |||
58 | /** |
||
59 | * @return array |
||
60 | */ |
||
61 | public function formatSizeProvider() |
||
72 | |||
73 | /** |
||
74 | * @dataProvider formatSizeProvider |
||
75 | * @covers DmFileman\Helper\FileInfo\Formatter |
||
76 | * @requires PHP 5.6 |
||
77 | * |
||
78 | * @param int $size |
||
79 | * @param string $expectedResult |
||
80 | * @param null|string $decPoint |
||
81 | * @param null|string $thousandsSep |
||
82 | */ |
||
83 | public function testFormatSizeReturnsHumanReadable($size, $expectedResult, $decPoint = null, $thousandsSep = null) |
||
97 | |||
98 | /** |
||
99 | * @covers DmFileman\Helper\FileInfo\Formatter |
||
100 | * @requires PHP 5.6 |
||
101 | */ |
||
102 | public function testFormatSizeReturnsRawIfUnitIsNotSet() |
||
114 | |||
115 | /** |
||
116 | * @covers DmFileman\Helper\FileInfo\Formatter |
||
117 | */ |
||
118 | public function testFormatPermissionsReturnEmptyStringOnEmptySplFileInfo() |
||
124 | |||
125 | /** |
||
126 | * @covers DmFileman\Helper\FileInfo\Formatter |
||
127 | * @requires PHP 5.6 |
||
128 | */ |
||
129 | public function testFormatPermissions() |
||
139 | |||
140 | /** |
||
141 | * @covers DmFileman\Helper\FileInfo\Formatter |
||
142 | */ |
||
143 | public function testFormatOwnerReturnEmptyStringOnEmptySplFileInfo() |
||
149 | |||
150 | /** |
||
151 | * @covers DmFileman\Helper\FileInfo\Formatter |
||
152 | * @requires PHP 5.6 |
||
153 | */ |
||
154 | public function testFormatOwner() |
||
166 | |||
167 | /** |
||
168 | * @covers DmFileman\Helper\FileInfo\Formatter |
||
169 | */ |
||
170 | public function testFormatGroupReturnEmptyStringOnEmptySplFileInfo() |
||
176 | |||
177 | /** |
||
178 | * @covers DmFileman\Helper\FileInfo\Formatter |
||
179 | * @requires PHP 5.6 |
||
180 | */ |
||
181 | public function testFormatGroup() |
||
193 | |||
194 | /** |
||
195 | * @return PHPUnit_Framework_MockObject_MockObject |
||
196 | */ |
||
197 | private function getSplFileInfoMock() |
||
204 | } |
||
205 |
In PHP, under loose comparison (like
==
, or!=
, orswitch
conditions), values of different types might be equal.For
string
values, the empty string''
is a special case, in particular the following results might be unexpected: