Passed
Push — master ( 857fa0...c481cb )
by Sérgio
03:09
created

CondTest   A

Complexity

Total Complexity 1

Size/Duplication

Total Lines 20
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 1

Importance

Changes 0
Metric Value
dl 0
loc 20
rs 10
c 0
b 0
f 0
wmc 1
lcom 0
cbo 1

1 Method

Rating   Name   Duplication   Size   Complexity  
A shouldReturnMatchedCond() 0 14 1
1
<?php
2
3
namespace Prelude\Tests;
4
5
use function Prelude\cond;
6
use function Prelude\equals;
7
use function Prelude\always;
8
9
class CondTest extends \PHPUnit_Framework_TestCase
10
{
11
    /**
12
     * @test
13
     */
14
    public function shouldReturnMatchedCond()
15
    {
16
        $fn = cond([
17
            [equals(0), always('water freezes at 0°C')],
18
            [equals(100), always('water boils at 100°C')],
19
            [always(true), function ($temp) {
20
                return 'nothing special happens at '.$temp.'°C';
21
            }]
22
        ]);
23
24
        $this->assertEquals('water freezes at 0°C', $fn(0));
25
        $this->assertEquals('nothing special happens at 50°C', $fn(50));
26
        $this->assertEquals('water boils at 100°C', $fn(100));
27
    }
28
}
29