Completed
Push — master ( 1b4f53...76f910 )
by Siwapun
03:55
created

EndsWithTest::testEndsWithEmptyString()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 6

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 6
rs 10
c 0
b 0
f 0
cc 1
nc 1
nop 0
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