/** * @param string $location * @return $this * @throws InvalidArgumentException */ public function setLocation($location) { IsValid::notEmpty($location, 'Location cannot be empty'); $this->location = $location; return $this; }
/** * @test * @dataProvider emptyValues * @param mixed $value * @param string $customMessage */ public function shouldThrowExceptionWithCustomMessageWhenValueIsEmpty($value, $customMessage) { //when try { IsValid::notEmpty($value, $customMessage); $this->assertFalse(true, 'Triggered when exception is not throw'); } catch (InvalidArgumentException $e) { //then $this->assertEquals($customMessage, $e->getMessage()); $this->assertInstanceOf('\\InvalidArgumentException', $e); } }