|
1
|
|
|
<?php |
|
2
|
|
|
|
|
3
|
|
|
/* |
|
4
|
|
|
* This file is part of the xAPI package. |
|
5
|
|
|
* |
|
6
|
|
|
* (c) Christian Flothmann <[email protected]> |
|
7
|
|
|
* |
|
8
|
|
|
* For the full copyright and license information, please view the LICENSE |
|
9
|
|
|
* file that was distributed with this source code. |
|
10
|
|
|
*/ |
|
11
|
|
|
|
|
12
|
|
|
namespace Xabbuh\XApi\Model\Tests; |
|
13
|
|
|
|
|
14
|
|
|
use Xabbuh\XApi\Model\Account; |
|
15
|
|
|
use Xabbuh\XApi\Model\Actor; |
|
16
|
|
|
use Xabbuh\XApi\Model\Agent; |
|
17
|
|
|
use Xabbuh\XApi\Model\Group; |
|
18
|
|
|
|
|
19
|
|
|
/** |
|
20
|
|
|
* @author Christian Flothmann <[email protected]> |
|
21
|
|
|
*/ |
|
22
|
|
|
class ActorTest extends \PHPUnit_Framework_TestCase |
|
23
|
|
|
{ |
|
24
|
|
|
public function testActorsEqualWhenAllPropertiesAreEqual() |
|
25
|
|
|
{ |
|
26
|
|
|
$agent1 = $this->createAgent(); |
|
27
|
|
|
$agent2 = $this->createAgent(); |
|
28
|
|
|
|
|
29
|
|
|
$this->assertTrue($agent1->equals($agent2)); |
|
30
|
|
|
|
|
31
|
|
|
$group1 = $this->createGroup(); |
|
32
|
|
|
$group2 = $this->createGroup(); |
|
33
|
|
|
|
|
34
|
|
|
$this->assertTrue($group1->equals($group2)); |
|
35
|
|
|
} |
|
36
|
|
|
|
|
37
|
|
|
public function testAgentAndGroupDoNotEqual() |
|
38
|
|
|
{ |
|
39
|
|
|
$agent = $this->createAgent(); |
|
40
|
|
|
$group = $this->createGroup(); |
|
41
|
|
|
|
|
42
|
|
|
$this->assertFalse($agent->equals($group)); |
|
43
|
|
|
$this->assertFalse($group->equals($agent)); |
|
44
|
|
|
} |
|
45
|
|
|
|
|
46
|
|
|
/** |
|
47
|
|
|
* @dataProvider getActorsWithDifferingInverseFunctionalIdentifiers |
|
48
|
|
|
*/ |
|
49
|
|
|
public function testActorsDifferWhenInverseFunctionalIdentifierDiffer(Actor $actor1, Actor $actor2) |
|
50
|
|
|
{ |
|
51
|
|
|
$this->assertFalse($actor1->equals($actor2)); |
|
52
|
|
|
} |
|
53
|
|
|
|
|
54
|
|
|
public function getActorsWithDifferingInverseFunctionalIdentifiers() |
|
55
|
|
|
{ |
|
56
|
|
|
return array( |
|
57
|
|
|
'agent-and-group' => array( |
|
58
|
|
|
new Agent(), |
|
59
|
|
|
new Group(), |
|
60
|
|
|
), |
|
61
|
|
|
'group-and-agent' => array( |
|
62
|
|
|
new Group(), |
|
63
|
|
|
new Agent(), |
|
64
|
|
|
), |
|
65
|
|
|
'agents-with-different-mboxes' => array( |
|
66
|
|
|
new Agent('[email protected]'), |
|
67
|
|
|
new Agent('[email protected]'), |
|
68
|
|
|
), |
|
69
|
|
|
'groups-with-different-mboxes' => array( |
|
70
|
|
|
new Group('[email protected]'), |
|
71
|
|
|
new Group('[email protected]'), |
|
72
|
|
|
), |
|
73
|
|
|
'agents-with-different-mbox-hashsums' => array( |
|
74
|
|
|
new Agent(null, 'foo'), |
|
75
|
|
|
new Agent(null, 'bar'), |
|
76
|
|
|
), |
|
77
|
|
|
'groups-with-different-mbox-hashsums' => array( |
|
78
|
|
|
new Group(null, 'foo'), |
|
79
|
|
|
new Group(null, 'bar'), |
|
80
|
|
|
), |
|
81
|
|
|
'agents-with-different-openids' => array( |
|
82
|
|
|
new Agent(null, null, 'aaron.openid.example.org'), |
|
83
|
|
|
new Agent(null, null, 'bob.openid.example.org'), |
|
84
|
|
|
), |
|
85
|
|
|
'groups-with-different-openids' => array( |
|
86
|
|
|
new Group(null, null, 'aaron.openid.example.org'), |
|
87
|
|
|
new Group(null, null, 'bob.openid.example.org'), |
|
88
|
|
|
), |
|
89
|
|
|
'agents-with-first-account-null' => array( |
|
90
|
|
|
new Agent(null, null, null, null), |
|
91
|
|
|
new Agent(null, null, null, new Account('user account', 'http://example.com/bob')), |
|
92
|
|
|
), |
|
93
|
|
|
'agents-with-other-account-null' => array( |
|
94
|
|
|
new Agent(null, null, null, new Account('user account', 'http://example.com/bob')), |
|
95
|
|
|
new Agent(null, null, null, null), |
|
96
|
|
|
), |
|
97
|
|
|
'groups-with-first-account-null' => array( |
|
98
|
|
|
new Group(null, null, null, null), |
|
99
|
|
|
new Group(null, null, null, new Account('user account', 'http://example.com/bob')), |
|
100
|
|
|
), |
|
101
|
|
|
'groups-with-other-account-null' => array( |
|
102
|
|
|
new Group(null, null, null, new Account('user account', 'http://example.com/bob')), |
|
103
|
|
|
new Group(null, null, null, null), |
|
104
|
|
|
), |
|
105
|
|
|
'agents-with-different-account-names' => array( |
|
106
|
|
|
new Agent(null, null, null, new Account('user account', 'http://example.com/bob')), |
|
107
|
|
|
new Agent(null, null, null, new Account('another user account', 'http://example.com/bob')), |
|
108
|
|
|
), |
|
109
|
|
|
'agents-with-different-account-home-pages' => array( |
|
110
|
|
|
new Agent(null, null, null, new Account('user account', 'http://example.com/bob')), |
|
111
|
|
|
new Agent(null, null, null, new Account('user account', 'http://example.com/christian')), |
|
112
|
|
|
), |
|
113
|
|
|
'groups-with-different-account-names' => array( |
|
114
|
|
|
new Group(null, null, null, new Account('user account', 'http://example.com/bob')), |
|
115
|
|
|
new Group(null, null, null, new Account('another user account', 'http://example.com/bob')), |
|
116
|
|
|
), |
|
117
|
|
|
'groups-with-different-account-home-pages' => array( |
|
118
|
|
|
new Group(null, null, null, new Account('user account', 'http://example.com/bob')), |
|
119
|
|
|
new Group(null, null, null, new Account('user account', 'http://example.com/christian')), |
|
120
|
|
|
), |
|
121
|
|
|
'agents-with-different-names' => array( |
|
122
|
|
|
new Agent(null, null, null, null, 'Christian'), |
|
123
|
|
|
new Agent(null, null, null, null, 'Bob'), |
|
124
|
|
|
), |
|
125
|
|
|
'groups-with-different-names' => array( |
|
126
|
|
|
new Group(null, null, null, null, 'Christian'), |
|
127
|
|
|
new Group(null, null, null, null, 'Bob'), |
|
128
|
|
|
), |
|
129
|
|
|
'groups-with-different-number-of-members' => array( |
|
130
|
|
|
new Group(null, null, null, null, null, array( |
|
131
|
|
|
$this->createAgent1(), |
|
132
|
|
|
$this->createAgent2(), |
|
133
|
|
|
$this->createAgent3(), |
|
134
|
|
|
)), |
|
135
|
|
|
new Group(null, null, null, null, null, array( |
|
136
|
|
|
$this->createAgent1(), |
|
137
|
|
|
$this->createAgent3(), |
|
138
|
|
|
)), |
|
139
|
|
|
), |
|
140
|
|
|
'groups-with-different-members' => array( |
|
141
|
|
|
new Group(null, null, null, null, null, array( |
|
142
|
|
|
$this->createAgent1(), |
|
143
|
|
|
$this->createAgent2(), |
|
144
|
|
|
)), |
|
145
|
|
|
new Group(null, null, null, null, null, array( |
|
146
|
|
|
$this->createAgent1(), |
|
147
|
|
|
$this->createAgent3(), |
|
148
|
|
|
)), |
|
149
|
|
|
), |
|
150
|
|
|
); |
|
151
|
|
|
} |
|
152
|
|
|
|
|
153
|
|
|
private function createAgent() |
|
154
|
|
|
{ |
|
155
|
|
|
return new Agent('mailto:[email protected]', null, null, null, 'Christian'); |
|
156
|
|
|
} |
|
157
|
|
|
|
|
158
|
|
|
private function createAgent1() |
|
159
|
|
|
{ |
|
160
|
|
|
return new Agent('mailto:[email protected]', null, null, null, 'Andrew Downes'); |
|
161
|
|
|
} |
|
162
|
|
|
|
|
163
|
|
|
private function createAgent2() |
|
164
|
|
|
{ |
|
165
|
|
|
return new Agent(null, null, 'aaron.openid.example.org', null, 'Aaron Silvers'); |
|
166
|
|
|
} |
|
167
|
|
|
|
|
168
|
|
|
private function createAgent3() |
|
169
|
|
|
{ |
|
170
|
|
|
return new Agent('mailto:[email protected]', null, null, null, 'Christian'); |
|
171
|
|
|
} |
|
172
|
|
|
|
|
173
|
|
|
private function createGroup() |
|
174
|
|
|
{ |
|
175
|
|
|
return new Group(null, null, null, new Account('GroupAccount', 'http://example.com/homePage'), 'Example Group'); |
|
176
|
|
|
} |
|
177
|
|
|
} |
|
178
|
|
|
|