Completed
Push — master ( 8871bc...78797b )
by Siwapun
03:45
created

SortByTest   A

Complexity

Total Complexity 1

Size/Duplication

Total Lines 17
Duplicated Lines 0 %

Importance

Changes 0
Metric Value
dl 0
loc 17
rs 10
c 0
b 0
f 0
wmc 1

1 Method

Rating   Name   Duplication   Size   Complexity  
A testSortBy() 0 12 1
1
<?php
2
3
namespace Aerophant\RamdaTest;
4
5
use function Aerophant\Ramda\compose;
6
use function Aerophant\Ramda\path;
7
use function Aerophant\Ramda\pathOr;
8
use function Aerophant\Ramda\sortBy;
9
use PHPUnit\Framework\TestCase;
10
11
class SortByTest extends TestCase
12
{
13
  /**
14
   * @throws \Exception
15
   */
16
  public function testSortBy()
17
  {
18
    $clara = ['name' => 'clara', 'age' => 314.159];
19
    $bob = ['name' => 'Bob', 'age' => -10];
20
    $alice = ['name' => 'ALICE', 'age' => 101];
21
    $sortByNameCaseInsensitive = sortBy(compose(
22
      'strtolower',
23
      path(['name'])
24
    ));
25
    $expect = [$alice, $bob, $clara];
26
    $actual = $sortByNameCaseInsensitive([$clara, $bob, $alice]);
27
    $this->assertEquals($expect, $actual);
28
  }
29
}
30