|
1
|
|
|
<?php |
|
2
|
|
|
namespace Aerophant\RamdaTest; |
|
3
|
|
|
|
|
4
|
|
|
use function Aerophant\Ramda\endsWith; |
|
5
|
|
|
use PHPUnit\Framework\TestCase; |
|
6
|
|
|
|
|
7
|
|
|
class EndsWithTest extends TestCase |
|
8
|
|
|
{ |
|
9
|
|
|
public function testEndsWithValidString() |
|
10
|
|
|
{ |
|
11
|
|
|
$suffix = 'SomeKeyword'; |
|
12
|
|
|
$list = 'StringWhichEndsWithSomeKeyword'; |
|
13
|
|
|
$actual = endsWith($suffix)($list); |
|
14
|
|
|
$this->assertTrue($actual); |
|
15
|
|
|
} |
|
16
|
|
|
|
|
17
|
|
|
public function testEndsWithInvalidString() |
|
18
|
|
|
{ |
|
19
|
|
|
$suffix = 'AnotherKeyword'; |
|
20
|
|
|
$list = 'StringWhichEndsWithSomeKeyword'; |
|
21
|
|
|
$actual = endsWith($suffix)($list); |
|
22
|
|
|
$this->assertFalse($actual); |
|
23
|
|
|
} |
|
24
|
|
|
|
|
25
|
|
|
public function testEndsWithEmptyString() |
|
26
|
|
|
{ |
|
27
|
|
|
$suffix = ''; |
|
28
|
|
|
$list = 'StringWhichEndsWithSomeKeyword'; |
|
29
|
|
|
$actual = endsWith($suffix)($list); |
|
30
|
|
|
$this->assertTrue($actual); |
|
31
|
|
|
} |
|
32
|
|
|
|
|
33
|
|
|
public function testWithUnsupportedArguments() |
|
34
|
|
|
{ |
|
35
|
|
|
$this->expectException(\InvalidArgumentException::class); |
|
36
|
|
|
endsWith(1)('111'); |
|
37
|
|
|
} |
|
38
|
|
|
|
|
39
|
|
|
public function testEndsWithEmptyArray() |
|
40
|
|
|
{ |
|
41
|
|
|
$suffix = []; |
|
42
|
|
|
$list = [1, 2 ,3, 4]; |
|
43
|
|
|
$actual = endsWith($suffix)($list); |
|
44
|
|
|
$this->assertTrue($actual); |
|
45
|
|
|
} |
|
46
|
|
|
public function testEndsWithValidArray() |
|
47
|
|
|
{ |
|
48
|
|
|
$suffix = [4]; |
|
49
|
|
|
$list = [1, 2 ,3, 4]; |
|
50
|
|
|
$actual = endsWith($suffix)($list); |
|
51
|
|
|
$this->assertTrue($actual); |
|
52
|
|
|
} |
|
53
|
|
|
public function testEndsWithInvalidArray() |
|
54
|
|
|
{ |
|
55
|
|
|
$suffix = [5]; |
|
56
|
|
|
$list = [1, 2 ,3, 4]; |
|
57
|
|
|
$actual = endsWith($suffix)($list); |
|
58
|
|
|
$this->assertFalse($actual); |
|
59
|
|
|
} |
|
60
|
|
|
} |
|
61
|
|
|
|