1
0
mirror of https://github.com/fzaninotto/Faker.git synced 2025-03-22 08:19:52 +01:00

Add tests

This commit is contained in:
Jordi Boggiano 2012-10-27 11:42:23 +02:00
parent ab50ccf28c
commit 9e8d2b5548
2 changed files with 40 additions and 0 deletions

View File

@ -34,6 +34,24 @@ class BaseTest extends \PHPUnit_Framework_TestCase
$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()));

View File

@ -65,6 +65,28 @@ class LoremTest extends \PHPUnit_Framework_TestCase
$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