| @@ 166-176 (lines=11) @@ | ||
| 163 | * @dataProvider emptyValues |
|
| 164 | * @param mixed $value |
|
| 165 | */ |
|
| 166 | public function shouldThrowExceptionWhenValueIsEmpty($value) |
|
| 167 | { |
|
| 168 | //when |
|
| 169 | try { |
|
| 170 | IsValid::notEmpty($value); |
|
| 171 | $this->assertFalse(true, 'Triggered when exception is not throw'); |
|
| 172 | } catch (InvalidArgumentException $e) { |
|
| 173 | //then |
|
| 174 | $this->assertEquals('Value cannot be empty', $e->getMessage()); |
|
| 175 | $this->assertInstanceOf('\InvalidArgumentException', $e); |
|
| 176 | } |
|
| 177 | } |
|
| 178 | ||
| 179 | /** |
|
| @@ 185-195 (lines=11) @@ | ||
| 182 | * @param mixed $value |
|
| 183 | * @param string $customMessage |
|
| 184 | */ |
|
| 185 | public function shouldThrowExceptionWithCustomMessageWhenValueIsEmpty($value, $customMessage) |
|
| 186 | { |
|
| 187 | //when |
|
| 188 | try { |
|
| 189 | IsValid::notEmpty($value, $customMessage); |
|
| 190 | $this->assertFalse(true, 'Triggered when exception is not throw'); |
|
| 191 | } catch (InvalidArgumentException $e) { |
|
| 192 | //then |
|
| 193 | $this->assertEquals($customMessage, $e->getMessage()); |
|
| 194 | $this->assertInstanceOf('\InvalidArgumentException', $e); |
|
| 195 | } |
|
| 196 | } |
|
| 197 | ||
| 198 | public function emptyValues() |
|
| @@ 230-241 (lines=12) @@ | ||
| 227 | /** |
|
| 228 | * @test |
|
| 229 | */ |
|
| 230 | public function shouldThrowExceptionWhenParameterStyleIsInValid() |
|
| 231 | { |
|
| 232 | //when |
|
| 233 | try { |
|
| 234 | IsValid::parameterStyle('INVALID_PARAMETER_STYLE'); |
|
| 235 | $this->assertFalse(true, 'Triggered when exception is not throw'); |
|
| 236 | } catch (InvalidArgumentException $e) { |
|
| 237 | //then |
|
| 238 | $this->assertEquals('Invalid parameter style [INVALID_PARAMETER_STYLE] available parameter styles: [BARE, WRAPPED]', $e->getMessage()); |
|
| 239 | $this->assertInstanceOf('\InvalidArgumentException', $e); |
|
| 240 | } |
|
| 241 | } |
|
| 242 | } |
|
| 243 | ||