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

WhenTest::shouldReturnTruncate()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 13
Code Lines 8

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
eloc 8
nc 1
nop 0
dl 0
loc 13
rs 9.4285
c 0
b 0
f 0
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