Skip to content

Commit

Permalink
Add tests
Browse files Browse the repository at this point in the history
  • Loading branch information
Seldaek committed Oct 27, 2012
1 parent ab50ccf commit 9e8d2b5
Show file tree
Hide file tree
Showing 2 changed files with 40 additions and 0 deletions.
18 changes: 18 additions & 0 deletions test/Faker/Provider/BaseTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,24 @@ public function testRandomNumberReturnsDigit()
$this->assertTrue(BaseProvider::randomNumber(3) < 1000);
}

public function testRandomNumberAcceptsMinMax()
{
$min = 5;
$max = 6;

$this->assertGreaterThanOrEqual($min, BaseProvider::randomNumber($min, $max));
$this->assertGreaterThanOrEqual(BaseProvider::randomNumber($min, $max), $max);
}

public function testNumberBetween()
{
$min = 5;
$max = 6;

$this->assertGreaterThanOrEqual($min, BaseProvider::numberBetween($min, $max));
$this->assertGreaterThanOrEqual(BaseProvider::numberBetween($min, $max), $max);
}

public function testRandomLetterReturnsString()
{
$this->assertTrue(is_string(BaseProvider::randomLetter()));
Expand Down
22 changes: 22 additions & 0 deletions test/Faker/Provider/LoremTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,28 @@ public function testParagraphWithPositiveNbSentencesReturnsAtLeastOneWord()
$this->assertGreaterThan(1, strlen($paragraph));
$this->assertGreaterThanOrEqual(1, count(explode(' ', $paragraph)));
}

public function testWordssAsText()
{
$words = TestableLorem::words(2, true);

$this->assertEquals('word word', $words);
}

public function testSentencesAsText()
{
$sentences = TestableLorem::sentences(2, true);

$this->assertEquals('This is a test sentence. This is a test sentence.', $sentences);
}

public function testParagraphsAsText()
{
$paragraphs = TestableLorem::paragraphs(2, true);

$expected = "This is a test paragraph. It has three sentences. Exactly three.\n\nThis is a test paragraph. It has three sentences. Exactly three.";
$this->assertEquals($expected, $paragraphs);
}
}

class TestableLorem extends Lorem
Expand Down

0 comments on commit 9e8d2b5

Please sign in to comment.