diff --git a/src/Stringy/Stringy.php b/src/Stringy/Stringy.php index 9cf13b5..7d0ed56 100644 --- a/src/Stringy/Stringy.php +++ b/src/Stringy/Stringy.php @@ -359,7 +359,7 @@ class Stringy public function pad($length, $padStr = ' ', $padType = 'right') { if (!in_array($padType, array('left', 'right', 'both'))) { - throw new InvalidArgumentException('Pad expects $padType ' . + throw new \InvalidArgumentException('Pad expects $padType ' . "to be one of 'left', 'right' or 'both'"); } diff --git a/tests/Stringy/StaticStringyTest.php b/tests/Stringy/StaticStringyTest.php index ca17595..57863fb 100644 --- a/tests/Stringy/StaticStringyTest.php +++ b/tests/Stringy/StaticStringyTest.php @@ -139,6 +139,14 @@ class StaticStringyTestCase extends CommonTest $this->assertEquals($expected, $result); } + /** + * @expectedException \InvalidArgumentException + */ + public function testPadException() + { + $result = S::pad('string', 5, 'foo', 'bar'); + } + /** * @dataProvider stringsForPadLeft */ diff --git a/tests/Stringy/StringyTest.php b/tests/Stringy/StringyTest.php index 0397dfc..deb2285 100644 --- a/tests/Stringy/StringyTest.php +++ b/tests/Stringy/StringyTest.php @@ -187,6 +187,15 @@ class StringyTestCase extends CommonTest $this->assertEquals($str, $stringy); } + /** + * @expectedException \InvalidArgumentException + */ + public function testPadException() + { + $stringy = S::create('foo'); + $result = $stringy->pad(5, 'foo', 'bar'); + } + /** * @dataProvider stringsForPadLeft */