PaersonTest   A
last analyzed

Complexity

Total Complexity 5

Size/Duplication

Total Lines 38
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 2

Importance

Changes 1
Bugs 1 Features 0
Metric Value
wmc 5
c 1
b 1
f 0
lcom 1
cbo 2
dl 0
loc 38
rs 10

5 Methods

Rating   Name   Duplication   Size   Complexity  
A setUp() 0 5 1
A testPaersonAngelicaBill() 0 6 1
A testPaersonAngelicaHaily() 0 6 1
A testPaersonAngelicaJordyn() 0 6 1
A testPaersonNoMatch() 0 6 1
1
<?php
2
3
namespace stojg\recommend\tests;
4
5
use stojg\recommend\strategy\Paerson;
6
7
class PaersonTest extends \PHPUnit_Framework_TestCase
8
{
9
    protected $set;
10
11
    public function setUp()
12
    {
13
        $data = file_get_contents(__DIR__.'/../fixtures/users.json');
14
        $this->set = json_decode($data, true);
15
    }
16
17
    public function testPaersonAngelicaBill()
18
    {
19
        $paerson = new Paerson();
20
        $score = $paerson->run($this->set['Angelica'], $this->set['Bill']);
21
        $this->assertEquals(0.09594650093173, $score);
22
    }
23
24
    public function testPaersonAngelicaHaily()
25
    {
26
        $paerson = new Paerson();
27
        $score = $paerson->run($this->set['Angelica'], $this->set['Hailey']);
28
        $this->assertEquals(0.5799159747916, $score);
29
    }
30
31
    public function testPaersonAngelicaJordyn()
32
    {
33
        $paerson = new Paerson();
34
        $score = $paerson->run($this->set['Angelica'], $this->set['Jordyn']);
35
        $this->assertEquals(0.23602513945246, $score);
36
    }
37
38
    public function testPaersonNoMatch()
39
    {
40
        $paerson = new Paerson();
41
        $score = $paerson->run($this->set['Angelica'], []);
42
        $this->assertEquals(0, $score);
43
    }
44
}
45