From 09e4b3adea8b1e7f6669c7890cfe9c9c4e98d3d7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tim=20D=C3=BCsterhus?= Date: Tue, 18 Feb 2014 18:10:21 +0100 Subject: [PATCH] Add an advanced text generator based on markov chains. The advanced text generator's text()-generator is compatible to Lorem's one and can be used as a drop in replacement. --- src/Faker/Provider/Text.php | 737 +++++++++++++++++++++++++++++++ test/Faker/Provider/TextTest.php | 29 ++ 2 files changed, 766 insertions(+) create mode 100644 src/Faker/Provider/Text.php create mode 100644 test/Faker/Provider/TextTest.php diff --git a/src/Faker/Provider/Text.php b/src/Faker/Provider/Text.php new file mode 100644 index 00000000..ca40ebd5 --- /dev/null +++ b/src/Faker/Provider/Text.php @@ -0,0 +1,737 @@ +addProvider(new Text($generator)); + $generator->seed(0); + + $lengths = array(10, 20, 50, 70, 90, 120, 150, 200, 500); + + foreach ($lengths as $length) { + $this->assertLessThan($length, $generator->text($length)); + } + } + + /** + * @expectedException \InvalidArgumentException + */ + public function testTextInvalidUnit() + { + Text::text(200, 2, 'invalid'); + } +}