From e9a90aec0b96cfe2ed31090ca27c7e0f49a4cafa Mon Sep 17 00:00:00 2001 From: Geoffrey Brier Date: Thu, 31 May 2012 11:06:04 +0200 Subject: [PATCH] Improved unit tests --- test/Faker/Provider/LoremTest.php | 34 +++++++++++++++++++++++++------ 1 file changed, 28 insertions(+), 6 deletions(-) diff --git a/test/Faker/Provider/LoremTest.php b/test/Faker/Provider/LoremTest.php index 70ca58ad..285668b7 100644 --- a/test/Faker/Provider/LoremTest.php +++ b/test/Faker/Provider/LoremTest.php @@ -16,18 +16,40 @@ class LoremTest extends \PHPUnit_Framework_TestCase $this->assertEquals($singleParagraph . "\n" . $singleParagraph, $provider->text(52)); } - public function testWithNegativeParam() + public function testSentenceWithZeroNbWordsReturnsEmptyString() + { + $this->assertEquals('', Lorem::sentence(0)); + } + + public function testSentenceWithNegativeNbWordsReturnsEmptyString() { $this->assertEquals('', Lorem::sentence(-1)); - $this->assertEquals('', Lorem::paragraph(-1)); - $this->assertEquals('', Lorem::sentence(0)); + } + + public function testParagraphWithZeroNbSentencesReturnsEmptyString() + { $this->assertEquals('', Lorem::paragraph(0)); } - public function testWithStrictlyPositiveParam() + public function testParagraphWithNegativeNbSentencesReturnsEmptyString() { - $this->assertGreaterThan(1, strlen(Lorem::sentence(1))); - $this->assertGreaterThan(1, strlen(Lorem::paragraph(1))); + $this->assertEquals('', Lorem::paragraph(-1)); + } + + public function testSentenceWithPositiveNbWordsReturnsAtLeastOneWord() + { + $sentence = Lorem::sentence(1); + + $this->assertGreaterThan(1, strlen($sentence)); + $this->assertGreaterThanOrEqual(1, count(explode(' ', $sentence))); + } + + public function testParagraphWithPositiveNbSentencesReturnsAtLeastOneWord() + { + $paragraph = Lorem::paragraph(1); + + $this->assertGreaterThan(1, strlen($paragraph)); + $this->assertGreaterThanOrEqual(1, count(explode(' ', $paragraph))); } }