1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
declare(strict_types=1); |
4
|
|
|
|
5
|
|
|
namespace DummyGenerator\Test\Extension; |
6
|
|
|
|
7
|
|
|
use DummyGenerator\Container\DefinitionContainer; |
8
|
|
|
use DummyGenerator\Core\Lorem; |
9
|
|
|
use DummyGenerator\Definitions\Extension\LoremExtensionInterface; |
10
|
|
|
use DummyGenerator\Definitions\Randomizer\RandomizerInterface; |
11
|
|
|
use DummyGenerator\Definitions\Replacer\ReplacerInterface; |
12
|
|
|
use DummyGenerator\Definitions\Transliterator\TransliteratorInterface; |
13
|
|
|
use DummyGenerator\DummyGenerator; |
14
|
|
|
use DummyGenerator\Core\Randomizer\Randomizer; |
15
|
|
|
use DummyGenerator\Core\Replacer\Replacer; |
16
|
|
|
use DummyGenerator\Core\Transliterator\Transliterator; |
17
|
|
|
use PHPUnit\Framework\TestCase; |
18
|
|
|
|
19
|
|
|
class LoremTest extends TestCase |
20
|
|
|
{ |
21
|
|
|
private DummyGenerator $generator; |
22
|
|
|
|
23
|
|
|
public function setUp(): void |
24
|
|
|
{ |
25
|
|
|
parent::setUp(); |
26
|
|
|
|
27
|
|
|
$container = new DefinitionContainer([]); |
28
|
|
|
$container->add(RandomizerInterface::class, Randomizer::class); |
29
|
|
|
$container->add(TransliteratorInterface::class, Transliterator::class); |
30
|
|
|
$container->add(ReplacerInterface::class, Replacer::class); |
31
|
|
|
$container->add(LoremExtensionInterface::class, Lorem::class); |
32
|
|
|
$this->generator = new DummyGenerator($container); |
33
|
|
|
} |
34
|
|
|
|
35
|
|
|
public function testWord(): void |
36
|
|
|
{ |
37
|
|
|
self::assertNotEmpty($this->generator->word()); |
38
|
|
|
} |
39
|
|
|
|
40
|
|
|
public function testWords(): void |
41
|
|
|
{ |
42
|
|
|
self::assertCount(4, $this->generator->words(wordCount: 4)); |
43
|
|
|
} |
44
|
|
|
|
45
|
|
|
public function testSentence(): void |
46
|
|
|
{ |
47
|
|
|
self::assertCount(5, explode(' ', $this->generator->sentence(wordCount: 5, variableWordCount: false))); |
48
|
|
|
} |
49
|
|
|
|
50
|
|
|
public function testSentences(): void |
51
|
|
|
{ |
52
|
|
|
self::assertCount(4, $this->generator->sentences(sentenceCount: 4)); |
53
|
|
|
} |
54
|
|
|
|
55
|
|
|
public function testParagraph(): void |
56
|
|
|
{ |
57
|
|
|
self::assertNotEmpty($this->generator->paragraph(sentenceCount: 4, variableSentenceCount: false)); |
58
|
|
|
} |
59
|
|
|
|
60
|
|
|
public function testParagraphs(): void |
61
|
|
|
{ |
62
|
|
|
self::assertCount(5, $this->generator->paragraphs(paragraphCount: 5)); |
63
|
|
|
} |
64
|
|
|
|
65
|
|
|
public function testText(): void |
66
|
|
|
{ |
67
|
|
|
self::assertTrue(strlen($this->generator->text(maxCharacters: 80)) < 80); |
68
|
|
|
} |
69
|
|
|
} |
70
|
|
|
|