Passed
Push — master ( 3f4370...54e8a7 )
by Sérgio
03:37
created

AllPassTest::test()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 18
Code Lines 11

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
eloc 11
nc 1
nop 0
dl 0
loc 18
rs 9.4285
c 0
b 0
f 0
1
<?php
2
3
namespace Prelude\Tests;
4
5
use function Prelude\partial;
6
use function Prelude\allPass;
7
use function Prelude\get;
8
use function Prelude\has;
9
10
class AllPassTest extends \PHPUnit\Framework\TestCase
11
{
12
    public function test()
13
    {
14
        $placeholders = [
15
            'to' => '[email protected]',
16
            'from' => '[email protected]'
17
        ];
18
19
        $propEq = partial(function ($k, $v, array $xss) {
20
            return ($xss[$k] ?? false) === $v;
21
        });
22
23
        $y = allPass([has('from'), has('to')]);
24
        $this->assertTrue($y($placeholders));
25
26
        $x = allPass([$propEq('rank', 'Q'), $propEq('suit', '♠︎')]);
27
        $this->assertTrue($x(['rank' => 'Q', 'suit' => '♠︎']));
28
        $this->assertFalse($x(['rank' => 'Q', 'suit' => '♣︎︎']));
29
    }
30
}
31