1 | <?php |
||
19 | class ContainerTest extends \PHPUnit\Framework\TestCase |
||
20 | { |
||
21 | use ContainerProvider; |
||
22 | |||
23 | /** |
||
24 | * 正常系 |
||
25 | * 値を格納して取り出せること |
||
26 | * @test |
||
27 | * @dataProvider valueLazyProvider |
||
28 | */ |
||
29 | public function okContainer($value, $result) |
||
35 | |||
36 | /** |
||
37 | * 正常系 |
||
38 | * 設定した値のカウントが取得できること |
||
39 | * @test |
||
40 | */ |
||
41 | public function okLength() |
||
48 | |||
49 | /** |
||
50 | * 正常系 |
||
51 | * 値を削除できること |
||
52 | * 削除後の要素にアクセスすると例外が発生すること |
||
53 | * @test |
||
54 | * @expectedException WebStream\Exception\Extend\InvalidArgumentException |
||
55 | */ |
||
56 | public function okRemove() |
||
63 | |||
64 | /** |
||
65 | * 正常系 |
||
66 | * プリミティブ値を登録できること |
||
67 | * 値はそのまま保存される |
||
68 | * @test |
||
69 | * @dataProvider valueDynamicProvider |
||
70 | */ |
||
71 | public function okRegisterPrimitive($value, $result) |
||
77 | |||
78 | /** |
||
79 | * 正常系 |
||
80 | * クロージャを登録できること |
||
81 | * 値はそのまま保存される |
||
82 | * @test |
||
83 | */ |
||
84 | public function okRegisterClosure() |
||
95 | |||
96 | /** |
||
97 | * 正常系 |
||
98 | * 即時実行状態で登録されること |
||
99 | * @test |
||
100 | */ |
||
101 | public function okRegisterAsDynamic() |
||
112 | |||
113 | /** |
||
114 | * 正常系 |
||
115 | * 遅延実行状態で登録されること |
||
116 | * @test |
||
117 | */ |
||
118 | public function okRegisterAsLazy() |
||
130 | |||
131 | /** |
||
132 | * 正常系 |
||
133 | * コンテナから取得するとき、値はキャッシュされていること |
||
134 | * @test |
||
135 | */ |
||
136 | public function okRegisterCached() |
||
158 | |||
159 | /** |
||
160 | * 正常系 |
||
161 | * コンテナから取得するとき、値はキャッシュされていないこと |
||
162 | * @test |
||
163 | */ |
||
164 | public function okRegisterUnCached() |
||
184 | |||
185 | /** |
||
186 | * 正常系 |
||
187 | * 未定義の値にアクセスしても例外が発生しないこと |
||
188 | * @test |
||
189 | */ |
||
190 | public function okUnStrictContainer() |
||
195 | } |
||
196 |
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.