| @@ 170-181 (lines=12) @@ | ||
| 167 | * @dataProvider emptyValues |
|
| 168 | * @param mixed $value |
|
| 169 | */ |
|
| 170 | public function shouldThrowExceptionWhenValueIsEmpty($value) |
|
| 171 | { |
|
| 172 | //when |
|
| 173 | try { |
|
| 174 | IsValid::notEmpty($value); |
|
| 175 | $this->assertFalse(true, 'Triggered when exception is not throw'); |
|
| 176 | } catch (InvalidArgumentException $e) { |
|
| 177 | //then |
|
| 178 | $this->assertEquals('Value cannot be empty', $e->getMessage()); |
|
| 179 | $this->assertInstanceOf('\InvalidArgumentException', $e); |
|
| 180 | } |
|
| 181 | } |
|
| 182 | ||
| 183 | /** |
|
| 184 | * @test |
|
| @@ 189-200 (lines=12) @@ | ||
| 186 | * @param mixed $value |
|
| 187 | * @param string $customMessage |
|
| 188 | */ |
|
| 189 | public function shouldThrowExceptionWithCustomMessageWhenValueIsEmpty($value, $customMessage) |
|
| 190 | { |
|
| 191 | //when |
|
| 192 | try { |
|
| 193 | IsValid::notEmpty($value, $customMessage); |
|
| 194 | $this->assertFalse(true, 'Triggered when exception is not throw'); |
|
| 195 | } catch (InvalidArgumentException $e) { |
|
| 196 | //then |
|
| 197 | $this->assertEquals($customMessage, $e->getMessage()); |
|
| 198 | $this->assertInstanceOf('\InvalidArgumentException', $e); |
|
| 199 | } |
|
| 200 | } |
|
| 201 | ||
| 202 | public function emptyValues() |
|
| 203 | { |
|