2626class TranslationSchemeTest extends TestCase
2727{
2828 /**
29- * @param string $source
30- * @param list<list< string> > $expectedValues
29+ * @param string $source
30+ * @param list<string> $expectedValues
3131 * @throws UniLexException
3232 * @dataProvider providerValidBuffer
3333 */
@@ -37,11 +37,20 @@ public function testTranslation_ValidBuffer_BuildsMatchingLocator(string $source
3737 $ scheme = new TranslationScheme ($ locatorBuilder );
3838 $ parser = $ this ->createParser ($ scheme , $ source );
3939
40+ $ textBuffer = [];
4041 $ locatorBuilder
41- ->expects (self ::exactly (count ($ expectedValues )))
4242 ->method ('addReference ' )
43- ->withConsecutive (...$ expectedValues );
43+ ->with (
44+ self ::callback (
45+ function (string $ text ) use (&$ textBuffer ): bool {
46+ $ textBuffer [] = $ text ;
47+
48+ return true ;
49+ },
50+ ),
51+ );
4452 $ parser ->run ();
53+ self ::assertSame ($ expectedValues , $ textBuffer );
4554 }
4655
4756 /**
@@ -66,25 +75,25 @@ private function createParser(TranslationSchemeInterface $scheme, string $source
6675 }
6776
6877 /**
69- * @return iterable<string, array{string, list<list< string> >}>
78+ * @return iterable<string, array{string, list<string>}>
7079 */
7180 public static function providerValidBuffer (): iterable
7281 {
7382 return [
7483 'Empty string ' => ['' , []],
75- 'Empty property ' => ['/ ' , [[ '' ] ]],
76- 'Single alpha property ' => ['/a ' , [[ 'a ' ] ]],
77- 'Single numeric property ' => ['/1 ' , [[ '1 ' ] ]],
78- 'Single non-ASCII property ' => ['/б ' , [[ 'б ' ] ]],
79- 'Property sequence ' => ['/a/1 ' , [[ 'a ' ], [ '1 ' ] ]],
80- 'Escaped property sequence ' => ['/~0/~1 ' , [[ '~ ' ], [ '/ ' ] ]],
81- 'Escaped tilde in a word ' => ['/a~0b ' , [[ 'a~b ' ] ]],
82- 'Escaped tilde in a word before zero ' => ['/a~00 ' , [[ 'a~0 ' ] ]],
83- 'Escaped tilde in a word before one ' => ['/a~01 ' , [[ 'a~1 ' ] ]],
84- 'Escaped slash in a word ' => ['/a~1b ' , [[ 'a/b ' ] ]],
85- 'Escaped slash in a word before zero ' => ['/a~10 ' , [[ 'a/0 ' ] ]],
86- 'Escaped tilde then escaped slash ' => ['/~0~1 ' , [[ '~/ ' ] ]],
87- 'Escaped slash then escaped tilde ' => ['/~1~0 ' , [[ '/~ ' ] ]],
84+ 'Empty property ' => ['/ ' , ['' ]],
85+ 'Single alpha property ' => ['/a ' , ['a ' ]],
86+ 'Single numeric property ' => ['/1 ' , ['1 ' ]],
87+ 'Single non-ASCII property ' => ['/б ' , ['б ' ]],
88+ 'Property sequence ' => ['/a/1 ' , ['a ' , '1 ' ]],
89+ 'Escaped property sequence ' => ['/~0/~1 ' , ['~ ' , '/ ' ]],
90+ 'Escaped tilde in a word ' => ['/a~0b ' , ['a~b ' ]],
91+ 'Escaped tilde in a word before zero ' => ['/a~00 ' , ['a~0 ' ]],
92+ 'Escaped tilde in a word before one ' => ['/a~01 ' , ['a~1 ' ]],
93+ 'Escaped slash in a word ' => ['/a~1b ' , ['a/b ' ]],
94+ 'Escaped slash in a word before zero ' => ['/a~10 ' , ['a/0 ' ]],
95+ 'Escaped tilde then escaped slash ' => ['/~0~1 ' , ['~/ ' ]],
96+ 'Escaped slash then escaped tilde ' => ['/~1~0 ' , ['/~ ' ]],
8897 ];
8998 }
9099
0 commit comments