Passed
Push — master ( ac0310...e9156b )
by Sérgio
06:31
created

WhenTest   A

Complexity

Total Complexity 1

Size/Duplication

Total Lines 19
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 1

Importance

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

1 Method

Rating   Name   Duplication   Size   Complexity  
A shouldReturnTruncate() 0 13 1
1
<?php
2
3
namespace Prelude\Tests;
4
5
use const Prelude\_;
6
use function Prelude\when;
7
use function Prelude\pipe;
8
use function Prelude\placeholder;
9
use function Prelude\partial;
10
11
class WhenTest extends \PHPUnit_Framework_TestCase
12
{
13
    /**
14
     * @test
15
     */
16
    public function shouldReturnTruncate()
17
    {
18
        $append = partial(function ($x, $y) {
19
            return $y.$x;
20
        });
21
        $pred = function ($str) {
22
            return strlen($str) > 10;
23
        };
24
        $truncate = when($pred, pipe(placeholder('substr', _, 0, 10), $append('…')));
25
26
        $this->assertEquals('12345', $truncate('12345'));
27
        $this->assertEquals('0123456789…', $truncate('0123456789ABC'));
28
    }
29
}
30