Completed
Pull Request — master (#2)
by Siwapun
13:33
created

CurryNTest   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 21
Duplicated Lines 0 %

Importance

Changes 0
Metric Value
wmc 2
dl 0
loc 21
rs 10
c 0
b 0
f 0

2 Methods

Rating   Name   Duplication   Size   Complexity  
A testCurryNWithAutoCurry() 0 8 1
A testCurryNWithInvokeFunctionDirectly() 0 8 1
1
<?php
2
namespace Aerophant\RamdaTest;
3
4
use function Aerophant\Ramda\curryN;
5
use PHPUnit\Framework\TestCase;
6
7
class CurryNTest extends TestCase
8
{
9
10
  public function testCurryNWithInvokeFunctionDirectly()
11
  {
12
    $curriedReduce = curryN('array_reduce', 3);
13
    $add = function ($a, $b) {
14
      return $a + $b;
15
    };
16
    $result = $curriedReduce([4,5,6], $add, 0);
17
    $this->assertEquals(15, $result);
18
  }
19
20
  public function testCurryNWithAutoCurry()
21
  {
22
    $curriedReduce = curryN('array_reduce', 3);
23
    $add = function ($a, $b) {
24
      return $a + $b;
25
    };
26
    $result = $curriedReduce([4,5,6])($add)(0);
27
    $this->assertEquals(15, $result);
28
  }
29
}
30