-
Notifications
You must be signed in to change notification settings - Fork 4
Expand file tree
/
Copy pathFunctionsTest.php
More file actions
58 lines (49 loc) · 1.53 KB
/
FunctionsTest.php
File metadata and controls
58 lines (49 loc) · 1.53 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
<?php
namespace PhpSchool\PhpWorkshopTest;
use PHPUnit\Framework\TestCase;
use function PhpSchool\PhpWorkshop\any;
use function PhpSchool\PhpWorkshop\camel_case_to_kebab_case;
use function PhpSchool\PhpWorkshop\mb_str_pad;
class FunctionsTest extends TestCase
{
/**
* @dataProvider mbStrPadProvider
*/
public function testMbStrPad(string $string, int $pad, string $expected): void
{
self::assertSame(mb_str_pad($string, $pad), $expected);
}
public function mbStrPadProvider(): array
{
return [
['hello', 10, 'hello '],
['hello😂', 10, 'hello😂 '],
];
}
/**
* @dataProvider camelCaseToKebabCaseProvider
*/
public function testCamelCaseToKebabCase(string $string, string $expected): void
{
self::assertSame(camel_case_to_kebab_case($string), $expected);
}
public function camelCaseToKebabCaseProvider(): array
{
return [
['camelCase', 'camel-case'],
[
'educationIsThePassportToTheFutureForTomorrowBelongsToThoseWhoPrepareForItToday',
'education-is-the-passport-to-the-future-for-tomorrow-belongs-to-those-who-prepare-for-it-today',
],
];
}
public function testAny(): void
{
self::assertEquals(true, any([1, 2, 3, 10, 11], function (int $num) {
return $num > 10;
}));
self::assertEquals(false, any([1, 2, 3, 10, 11], function (int $num) {
return $num > 11;
}));
}
}