@@ -126,7 +126,7 @@ public function testUserKey()
126
126
$ builder = new LDUserBuilder ("foo@bar.com " );
127
127
$ user = $ builder ->build ();
128
128
$ json = $ this ->getJsonForUserBySerializingEvent ($ user );
129
- $ this ->assertEquals ("foo@bar.com " , $ json ['key ' ]);
129
+ $ this ->assertSame ("foo@bar.com " , $ json ['key ' ]);
130
130
}
131
131
132
132
public function testEmptyCustom ()
@@ -150,70 +150,106 @@ public function testUserSecondary()
150
150
$ builder = new LDUserBuilder ("foo@bar.com " );
151
151
$ user = $ builder ->secondary ("secondary " )->build ();
152
152
$ json = $ this ->getJsonForUserBySerializingEvent ($ user );
153
- $ this ->assertEquals ("secondary " , $ json ['secondary ' ]);
153
+ $ this ->assertSame ("secondary " , $ json ['secondary ' ]);
154
154
}
155
155
156
156
public function testUserIP ()
157
157
{
158
158
$ builder = new LDUserBuilder ("foo@bar.com " );
159
159
$ user = $ builder ->ip ("127.0.0.1 " )->build ();
160
160
$ json = $ this ->getJsonForUserBySerializingEvent ($ user );
161
- $ this ->assertEquals ("127.0.0.1 " , $ json ['ip ' ]);
161
+ $ this ->assertSame ("127.0.0.1 " , $ json ['ip ' ]);
162
162
}
163
163
164
164
public function testUserCountry ()
165
165
{
166
166
$ builder = new LDUserBuilder ("foo@bar.com " );
167
167
$ user = $ builder ->country ("US " )->build ();
168
168
$ json = $ this ->getJsonForUserBySerializingEvent ($ user );
169
- $ this ->assertEquals ("US " , $ json ['country ' ]);
169
+ $ this ->assertSame ("US " , $ json ['country ' ]);
170
170
}
171
171
172
172
public function testUserEmail ()
173
173
{
174
174
$ builder = new LDUserBuilder ("foo@bar.com " );
175
175
$ user = $ builder ->email ("foo+test@bar.com " )->build ();
176
176
$ json = $ this ->getJsonForUserBySerializingEvent ($ user );
177
- $ this ->assertEquals ("foo+test@bar.com " , $ json ['email ' ]);
177
+ $ this ->assertSame ("foo+test@bar.com " , $ json ['email ' ]);
178
178
}
179
179
180
180
public function testUserName ()
181
181
{
182
182
$ builder = new LDUserBuilder ("foo@bar.com " );
183
183
$ user = $ builder ->name ("Foo Bar " )->build ();
184
184
$ json = $ this ->getJsonForUserBySerializingEvent ($ user );
185
- $ this ->assertEquals ("Foo Bar " , $ json ['name ' ]);
185
+ $ this ->assertSame ("Foo Bar " , $ json ['name ' ]);
186
186
}
187
187
188
188
public function testUserAvatar ()
189
189
{
190
190
$ builder = new LDUserBuilder ("foo@bar.com " );
191
191
$ user = $ builder ->avatar ("http://www.gravatar.com/avatar/1 " )->build ();
192
192
$ json = $ this ->getJsonForUserBySerializingEvent ($ user );
193
- $ this ->assertEquals ("http://www.gravatar.com/avatar/1 " , $ json ['avatar ' ]);
193
+ $ this ->assertSame ("http://www.gravatar.com/avatar/1 " , $ json ['avatar ' ]);
194
194
}
195
195
196
196
public function testUserFirstName ()
197
197
{
198
198
$ builder = new LDUserBuilder ("foo@bar.com " );
199
199
$ user = $ builder ->firstName ("Foo " )->build ();
200
200
$ json = $ this ->getJsonForUserBySerializingEvent ($ user );
201
- $ this ->assertEquals ("Foo " , $ json ['firstName ' ]);
201
+ $ this ->assertSame ("Foo " , $ json ['firstName ' ]);
202
202
}
203
203
204
204
public function testUserLastName ()
205
205
{
206
206
$ builder = new LDUserBuilder ("foo@bar.com " );
207
207
$ user = $ builder ->lastName ("Bar " )->build ();
208
208
$ json = $ this ->getJsonForUserBySerializingEvent ($ user );
209
- $ this ->assertEquals ("Bar " , $ json ['lastName ' ]);
209
+ $ this ->assertSame ("Bar " , $ json ['lastName ' ]);
210
210
}
211
211
212
212
public function testUserAnonymous ()
213
213
{
214
214
$ builder = new LDUserBuilder ("foo@bar.com " );
215
215
$ user = $ builder ->anonymous (true )->build ();
216
216
$ json = $ this ->getJsonForUserBySerializingEvent ($ user );
217
- $ this ->assertEquals (true , $ json ['anonymous ' ]);
217
+ $ this ->assertSame (true , $ json ['anonymous ' ]);
218
+ }
219
+
220
+ public function testUserNotAnonymous ()
221
+ {
222
+ $ builder = new LDUserBuilder ("foo@bar.com " );
223
+ $ user = $ builder ->anonymous (false )->build ();
224
+ $ json = $ this ->getJsonForUserBySerializingEvent ($ user );
225
+ $ this ->assertFalse (isset ($ json ['anonymous ' ])); // omitted rather than set to false, for efficiency
226
+ }
227
+
228
+ public function testNonStringAttributes ()
229
+ {
230
+ $ builder = new LDUserBuilder (1 );
231
+ $ user = $ builder ->secondary (2 )
232
+ ->ip (3 )
233
+ ->country (4 )
234
+ ->email (5 )
235
+ ->name (6 )
236
+ ->avatar (7 )
237
+ ->firstName (8 )
238
+ ->lastName (9 )
239
+ ->anonymous (true )
240
+ ->customAttribute ('foo ' , 10 )
241
+ ->build ();
242
+ $ json = $ this ->getJsonForUserBySerializingEvent ($ user );
243
+ $ this ->assertSame ('1 ' , $ json ['key ' ]);
244
+ $ this ->assertSame ('2 ' , $ json ['secondary ' ]);
245
+ $ this ->assertSame ('3 ' , $ json ['ip ' ]);
246
+ $ this ->assertSame ('4 ' , $ json ['country ' ]);
247
+ $ this ->assertSame ('5 ' , $ json ['email ' ]);
248
+ $ this ->assertSame ('6 ' , $ json ['name ' ]);
249
+ $ this ->assertSame ('7 ' , $ json ['avatar ' ]);
250
+ $ this ->assertSame ('8 ' , $ json ['firstName ' ]);
251
+ $ this ->assertSame ('9 ' , $ json ['lastName ' ]);
252
+ $ this ->assertSame (true , $ json ['anonymous ' ]); // We do NOT want "anonymous" to be stringified
253
+ $ this ->assertSame (10 , $ json ['custom ' ]['foo ' ]); // We do NOT want custom attribute values to be stringified
218
254
}
219
255
}
0 commit comments