Skip to content

Commit f03da27

Browse files
committed
tests
1 parent e203e7c commit f03da27

File tree

2 files changed

+28
-0
lines changed

2 files changed

+28
-0
lines changed

tests/Feature/SlugTest.php

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,9 @@ public static function slugProvider()
4040
'german characters' => ['Björn Müller', '-', 'de', 'bjoern-mueller'],
4141
'arabic characters' => ['صباح الخير', '-', 'ar', 'sbah-alkhyr'],
4242
'alternate separator' => ['one two three', '_', 'en', 'one_two_three'],
43+
'null string' => ['null', '-', 'en', 'null'],
44+
'zero string' => ['0', '-', 'en', '0'],
45+
'false string' => ['false', '-', 'en', 'false'],
4346
];
4447
}
4548
}

tests/Fieldtypes/TextTest.php

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -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

Comments
 (0)