Skip to content

Commit 1586d1f

Browse files
committed
add tests for shortenString
1 parent 0030239 commit 1586d1f

File tree

1 file changed

+19
-0
lines changed

1 file changed

+19
-0
lines changed

test/unit/UtilsTest.php

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -116,4 +116,23 @@ public function testGetURL(array $relative_url_components, string $expected)
116116
{
117117
$this->assertEquals($expected, getURL(...$relative_url_components));
118118
}
119+
120+
public static function shortenStringProvider()
121+
{
122+
return [
123+
[["foo###bar", 3, 3, "..."], "foo...bar"],
124+
[["foo###bar", 1, 3, "..."], "f...bar"],
125+
// input string is shorter than requested output size
126+
[["foo###bar", 999, 999, "..."], "foo###bar"],
127+
// input string is shorter than requested output size due to the long ellipsis
128+
[["foo###bar", 3, 3, "...."], "foo###bar"],
129+
[["", 3, 3], ""],
130+
];
131+
}
132+
133+
#[DataProvider("shortenStringProvider")]
134+
public function testShortenString(array $input_args, string $expected_output)
135+
{
136+
$this->assertEquals(shortenString(...$input_args), $expected_output);
137+
}
119138
}

0 commit comments

Comments
 (0)