@@ -33,4 +33,29 @@ public static function processValuesProvider()
3333 'number ' => ['number ' , [0 , 3 , 3 , 3.14 , null ]],
3434 ];
3535 }
36+
37+ #[Test]
38+ #[DataProvider('preProcessIndexProvider ' )]
39+ public function it_pre_processes_index_values ($ config , $ value , $ expected )
40+ {
41+ $ field = (new Text )->setField (new Field ('test ' , array_merge ([
42+ 'type ' => 'text ' ,
43+ ], $ config )));
44+
45+ $ this ->assertSame ($ expected , $ field ->preProcessIndex ($ value ));
46+ }
47+
48+ public static function preProcessIndexProvider ()
49+ {
50+ return [
51+ 'string value ' => [[], 'hello ' , 'hello ' ],
52+ 'null value ' => [[], null , null ],
53+ 'zero integer ' => [[], 0 , '0 ' ],
54+ 'zero string ' => [[], '0 ' , '0 ' ],
55+ 'zero with prepend ' => [['prepend ' => '$ ' ], 0 , '$0 ' ],
56+ 'zero with append ' => [['append ' => '% ' ], 0 , '0% ' ],
57+ 'zero with prepend and append ' => [['prepend ' => '$ ' , 'append ' => '% ' ], 0 , '$0% ' ],
58+ 'string with prepend ' => [['prepend ' => '$ ' ], 'hello ' , '$hello ' ],
59+ ];
60+ }
3661}
0 commit comments