1 | <?php |
||
21 | class InputStreamReaderTest extends \PHPUnit\Framework\TestCase |
||
22 | { |
||
23 | use InputStreamReaderProvider; |
||
24 | |||
25 | /** |
||
26 | * 正常系 |
||
27 | * バイト単位で読み込みできること |
||
28 | * EOFを超えるサイズの読み込み時は、ファイルの場合改行が含まれる |
||
29 | * @test |
||
30 | * @dataProvider readCharProvider |
||
31 | */ |
||
32 | public function okReadChar($stream, $result, $byteLength) |
||
37 | |||
38 | /** |
||
39 | * 正常系 |
||
40 | * 行単位でデータが読み込めること |
||
41 | * @test |
||
42 | * @dataProvider readLineProvider |
||
43 | */ |
||
44 | public function okReadLine($stream, $result1, $result2) |
||
51 | |||
52 | /** |
||
53 | * 正常系 |
||
54 | * 入力ストリームをクローズできること |
||
55 | * @test |
||
56 | * @dataProvider closeProvider |
||
57 | */ |
||
58 | public function okClose($stream) |
||
64 | |||
65 | /** |
||
66 | * 正常系 |
||
67 | * 指定バイト数だけスキップできること |
||
68 | * EOFを超えるサイズの読み込み時は、ファイルの場合改行が含まれる |
||
69 | * @test |
||
70 | * @dataProvider skipProvider |
||
71 | */ |
||
72 | public function okSkip($stream, $result, $pos) |
||
78 | |||
79 | /** |
||
80 | * 正常系 |
||
81 | * 終端を越えたスキップをしたとき |
||
82 | * 1回目のreadは空文字を返し、2回目のreadはnullを返すこと |
||
83 | * @test |
||
84 | * @dataProvider overSkipAndReadProvider |
||
85 | */ |
||
86 | public function okOverSkipAndRead($stream, $skipNum) |
||
93 | |||
94 | /** |
||
95 | * 正常系 |
||
96 | * ポインタを後方に移動できること |
||
97 | * @test |
||
98 | * @dataProvider frontSkipProvider |
||
99 | */ |
||
100 | public function okFrontSkip($stream, $skipNum1, $skipNum2, $result) |
||
107 | |||
108 | /** |
||
109 | * 正常系 |
||
110 | * ポインタ位置が負になった場合、移動量は常に-1になること |
||
111 | * @test |
||
112 | * @dataProvider overFrontSkipProvider |
||
113 | */ |
||
114 | public function okOverFrontSkip($stream, $pos) |
||
119 | |||
120 | /** |
||
121 | * 正常系 |
||
122 | * リセットすると初期位置にポインタが移動すること |
||
123 | * @test |
||
124 | * @dataProvider resetProvider |
||
125 | */ |
||
126 | public function okReset($stream, $skipNum, $result) |
||
133 | |||
134 | /** |
||
135 | * 正常系 |
||
136 | * リセットするとマーク位置にポインタが移動すること |
||
137 | * @test |
||
138 | * @dataProvider markAndResetProvider |
||
139 | */ |
||
140 | public function okMarkAndReset($stream, $skipNum, $result) |
||
148 | |||
149 | /** |
||
150 | * 異常系 |
||
151 | * 読み込みサイズに不正値を渡した時、例外が発生すること |
||
152 | * @test |
||
153 | * @dataProvider invalidLengthProvider |
||
154 | * @expectedException WebStream\Exception\Extend\InvalidArgumentException |
||
155 | */ |
||
156 | public function ngInvalidLength($stream) |
||
162 | } |
||
163 |
The PSR-1: Basic Coding Standard recommends that a file should either introduce new symbols, that is classes, functions, constants or similar, or have side effects. Side effects are anything that executes logic, like for example printing output, changing ini settings or writing to a file.
The idea behind this recommendation is that merely auto-loading a class should not change the state of an application. It also promotes a cleaner style of programming and makes your code less prone to errors, because the logic is not spread out all over the place.
To learn more about the PSR-1, please see the PHP-FIG site on the PSR-1.