|
| 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 ReplaceLastTest extends BaseStringSuite |
| 11 | +{ |
| 12 | + public static function __validData(): Iterator |
| 13 | + { |
| 14 | + yield ['foo bar baz', 'foo bar foo', 'foo', 'baz']; |
| 15 | + yield ['Hello World', 'Hello World', 'xyz', 'abc']; |
| 16 | + yield ['Hello World', 'Hello World', '', 'abc']; |
| 17 | + yield ['Hello World', 'Hello Hello World', 'Hello', '']; |
| 18 | + yield ['', '', 'foo', 'bar']; |
| 19 | + yield ['foobär', 'foobaz', 'baz', 'bär']; |
| 20 | + yield ['foo-bar-baz', 'foo-bar-bar', 'bar', 'baz']; |
| 21 | + yield ['fooXX', 'foobar', 'bar', 'XX']; |
| 22 | + yield ['foobar', 'foobar', 'BAR', 'XX']; |
| 23 | + yield ['a::b::X', 'a::b::c', 'c', 'X']; |
| 24 | + yield ['foo.bar.XX', 'foo.bar.baz', 'baz', 'XX']; |
| 25 | + } |
| 26 | + |
| 27 | + #[DataProvider('__validData')] |
| 28 | + public function testReplaceLastMethod(string $expected, string $string, string $search, string $replace): void |
| 29 | + { |
| 30 | + $this->assertSame($expected, $this->utility($string)->replaceLast($search, $replace)->value()); |
| 31 | + } |
| 32 | +} |
0 commit comments