From bc175f0e123bb949f3d1564458eba4bf1ffdfe5d Mon Sep 17 00:00:00 2001 From: ChristianGaertner Date: Tue, 3 Sep 2013 23:17:51 +0200 Subject: [PATCH] Added test to cover 100% + fixed fatal error --- src/Stringy/Stringy.php | 2 +- tests/Stringy/StaticStringyTest.php | 8 ++++++++ tests/Stringy/StringyTest.php | 9 +++++++++ 3 files changed, 18 insertions(+), 1 deletion(-) 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 */