1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
declare(strict_types=1); |
4
|
|
|
|
5
|
|
|
namespace DummyGenerator\Test\Extension; |
6
|
|
|
|
7
|
|
|
use DummyGenerator\Container\DefinitionContainer; |
8
|
|
|
use DummyGenerator\Core\Randomizer\Randomizer; |
9
|
|
|
use DummyGenerator\Core\Replacer\Replacer; |
10
|
|
|
use DummyGenerator\Core\Transliterator\Transliterator; |
11
|
|
|
use DummyGenerator\Definitions\Extension\TextExtensionInterface; |
12
|
|
|
use DummyGenerator\Definitions\Randomizer\RandomizerInterface; |
13
|
|
|
use DummyGenerator\Definitions\Replacer\ReplacerInterface; |
14
|
|
|
use DummyGenerator\Definitions\Transliterator\TransliteratorInterface; |
15
|
|
|
use DummyGenerator\DummyGenerator; |
16
|
|
|
use DummyGenerator\Test\Fixtures\TextProvider; |
17
|
|
|
use PHPUnit\Framework\TestCase; |
18
|
|
|
|
19
|
|
|
class TextTest 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(TextExtensionInterface::class, TextProvider::class); |
32
|
|
|
$this->generator = new DummyGenerator($container); |
33
|
|
|
} |
34
|
|
|
public function testRealText(): void |
35
|
|
|
{ |
36
|
|
|
$realText = $this->generator->realText(min: 5, max: 50, indexSize: 3); |
37
|
|
|
|
38
|
|
|
// @phpstan-ignore-next-line |
39
|
|
|
$length = $this->generator->ext(ReplacerInterface::class)->strlen($realText); |
40
|
|
|
|
41
|
|
|
self::assertTrue($length >= 5 && $length <= 50); |
42
|
|
|
} |
43
|
|
|
} |
44
|
|
|
|