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); |
|
|
|
|
35
|
|
|
$this->assertSame('John', $this->name->name); |
|
|
|
|
36
|
|
|
$this->assertSame(0.98, $this->name->probability); |
|
|
|
|
37
|
|
|
$this->assertSame(1234, $this->name->count); |
|
|
|
|
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); |
|
|
|
|
52
|
|
|
$this->assertNull($name->name); |
|
|
|
|
53
|
|
|
$this->assertNull($name->probability); |
|
|
|
|
54
|
|
|
$this->assertNull($name->count); |
|
|
|
|
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
|
|
|
|