|
| 1 | +<?php |
| 2 | + |
| 3 | +declare(strict_types=1); |
| 4 | + |
| 5 | +namespace Tests; |
| 6 | + |
| 7 | +use PHPUnit\Framework\Attributes\DataProvider; |
| 8 | +use Iterator; |
| 9 | + |
| 10 | +final class SwapTest extends BaseStringSuite |
| 11 | +{ |
| 12 | + public static function __validData(): Iterator |
| 13 | + { |
| 14 | + yield ['bar foo', 'foo bar', ['foo' => 'bar', 'bar' => 'foo']]; |
| 15 | + yield ['Hello World', 'Hello World', []]; |
| 16 | + yield ['Hello World', 'Hi World', ['Hi' => 'Hello']]; |
| 17 | + yield ['abc', 'xyz', ['x' => 'a', 'y' => 'b', 'z' => 'c']]; |
| 18 | + yield ['', '', ['foo' => 'bar']]; |
| 19 | + yield ['Hello World', 'Hello World', ['xyz' => 'abc']]; |
| 20 | + yield ['foobär', 'foobaz', ['baz' => 'bär']]; |
| 21 | + yield ['1-2-3', 'a-b-c', ['a' => '1', 'b' => '2', 'c' => '3']]; |
| 22 | + yield ['HELLO world', 'hello WORLD', ['hello' => 'HELLO', 'WORLD' => 'world']]; |
| 23 | + yield ['foo foo', 'bar bar', ['bar' => 'foo']]; |
| 24 | + } |
| 25 | + |
| 26 | + #[DataProvider('__validData')] |
| 27 | + public function testSwapMethod(string $expected, string $string, array $map): void |
| 28 | + { |
| 29 | + $this->assertSame($expected, $this->utility($string)->swap($map)->value()); |
| 30 | + } |
| 31 | +} |
0 commit comments