Completed
Push — master ( 5c4201...24a9b5 )
by Siwapun
05:35
created

InsertTest   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 25
Duplicated Lines 0 %

Importance

Changes 0
Metric Value
wmc 3
dl 0
loc 25
rs 10
c 0
b 0
f 0

3 Methods

Rating   Name   Duplication   Size   Complexity  
A testInsertFirst() 0 6 1
A testInsertLast() 0 6 1
A testInsertNth() 0 6 1
1
<?php
2
3
namespace Aerophant\RamdaTest;
4
5
use function Aerophant\Ramda\insert;
6
use PHPUnit\Framework\TestCase;
7
8
class InsertTest extends TestCase
9
{
10
11
  public function testInsertFirst()
12
  {
13
    $array = [1, 2, 3, 4, 5];
14
    $expected = ['newItem', 1, 2, 3, 4, 5];
15
    $actual = insert(0)('newItem')($array);
16
    $this->assertEquals($expected, $actual);
17
  }
18
19
  public function testInsertLast()
20
  {
21
    $array = [1, 2, 3, 4, 5];
22
    $expected = [1, 2, 3, 4, 5, 'newItem'];
23
    $actual = insert(5)('newItem')($array);
24
    $this->assertEquals($expected, $actual);
25
  }
26
27
  public function testInsertNth()
28
  {
29
    $array = [1, 2, 3, 4, 5];
30
    $expected = [1, 2,  'newItem', 3, 4, 5];
31
    $actual = insert(2)('newItem')($array);
32
    $this->assertEquals($expected, $actual);
33
  }
34
}
35