NameTest   A
last analyzed

Complexity

Total Complexity 7

Size/Duplication

Total Lines 90
Duplicated Lines 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
wmc 7
eloc 22
c 1
b 0
f 0
dl 0
loc 90
rs 10

7 Methods

Rating   Name   Duplication   Size   Complexity  
A setUp() 0 10 1
A isNotMale() 0 3 1
A data_is_set_correctly() 0 6 1
A defaults_added_correctly() 0 10 1
A isNotFemale() 0 3 1
A isMale() 0 3 1
A isFemale() 0 3 1
1
<?php namespace Pixelpeter\Genderize\Test;
2
3
use Pixelpeter\Genderize\Models\Name;
4
5
class NameTest extends \PHPUnit\Framework\TestCase
6
{
7
    /**
8
     * @var \Pixelpeter\Genderize\Models\Name
9
     */
10
    protected $name;
11
12
    /**
13
     * Set up
14
     */
15
    public function setUp()
16
    {
17
        $data = (object)[
18
            'gender' => 'male',
19
            'name' => 'John',
20
            'probability' => 0.98,
21
            'count' => 1234
22
        ];
23
24
        $this->name = new Name($data);
25
    }
26
27
    /**
28
     * Check data is set correctly
29
     *
30
     * @test
31
     */
32
    public function data_is_set_correctly()
33
    {
34
        $this->assertSame('male', $this->name->gender);
0 ignored issues
show
Bug Best Practice introduced by
The property $gender is declared protected in Pixelpeter\Genderize\Models\Name. Since you implement __get, consider adding a @property or @property-read.
Loading history...
35
        $this->assertSame('John', $this->name->name);
0 ignored issues
show
Bug Best Practice introduced by
The property $name is declared protected in Pixelpeter\Genderize\Models\Name. Since you implement __get, consider adding a @property or @property-read.
Loading history...
36
        $this->assertSame(0.98, $this->name->probability);
0 ignored issues
show
Bug Best Practice introduced by
The property $probability is declared protected in Pixelpeter\Genderize\Models\Name. Since you implement __get, consider adding a @property or @property-read.
Loading history...
37
        $this->assertSame(1234, $this->name->count);
0 ignored issues
show
Bug Best Practice introduced by
The property $count is declared protected in Pixelpeter\Genderize\Models\Name. Since you implement __get, consider adding a @property or @property-read.
Loading history...
38
    }
39
40
    /**
41
     * Check default properties are added correctly
42
     *
43
     * @test
44
     */
45
    public function defaults_added_correctly()
46
    {
47
        $data = (object)[];
48
49
        $name = new Name($data);
50
51
        $this->assertNull($name->gender);
0 ignored issues
show
Bug Best Practice introduced by
The property $gender is declared protected in Pixelpeter\Genderize\Models\Name. Since you implement __get, consider adding a @property or @property-read.
Loading history...
52
        $this->assertNull($name->name);
0 ignored issues
show
Bug Best Practice introduced by
The property $name is declared protected in Pixelpeter\Genderize\Models\Name. Since you implement __get, consider adding a @property or @property-read.
Loading history...
53
        $this->assertNull($name->probability);
0 ignored issues
show
Bug Best Practice introduced by
The property $probability is declared protected in Pixelpeter\Genderize\Models\Name. Since you implement __get, consider adding a @property or @property-read.
Loading history...
54
        $this->assertNull($name->count);
0 ignored issues
show
Bug Best Practice introduced by
The property $count is declared protected in Pixelpeter\Genderize\Models\Name. Since you implement __get, consider adding a @property or @property-read.
Loading history...
55
    }
56
57
    /**
58
     * Check isMale() is working
59
     *
60
     * @test
61
     */
62
    public function isMale()
63
    {
64
        $this->assertTrue($this->name->isMale());
65
    }
66
67
    /**
68
     *Check isNotMail() is working
69
     *
70
     * @test
71
     */
72
    public function isNotMale()
73
    {
74
        $this->assertFalse($this->name->isNotMale());
75
    }
76
77
    /**
78
     * Check isFemale() is working
79
     *
80
     * @test
81
     */
82
    public function isFemale()
83
    {
84
        $this->assertFalse($this->name->isFemale());
85
    }
86
87
    /**
88
     * Check isNotFemail() is working
89
     *
90
     * @test
91
     */
92
    public function isNotFemale()
93
    {
94
        $this->assertTrue($this->name->isNotFemale());
95
    }
96
}
97