@@ -126,7 +126,7 @@ public function testUserKey()
126126 $ builder =
new LDUserBuilder (
"[email protected] " );
127127 $ user = $ builder ->build ();
128128 $ json = $ this ->getJsonForUserBySerializingEvent ($ user );
129- $ this ->
assertEquals (
"[email protected] " ,
$ json[
'key ' ]);
129+ $ this ->
assertSame (
"[email protected] " ,
$ json[
'key ' ]);
130130 }
131131
132132 public function testEmptyCustom ()
@@ -150,70 +150,106 @@ public function testUserSecondary()
150150 $ builder =
new LDUserBuilder (
"[email protected] " );
151151 $ user = $ builder ->secondary ("secondary " )->build ();
152152 $ json = $ this ->getJsonForUserBySerializingEvent ($ user );
153- $ this ->assertEquals ("secondary " , $ json ['secondary ' ]);
153+ $ this ->assertSame ("secondary " , $ json ['secondary ' ]);
154154 }
155155
156156 public function testUserIP ()
157157 {
158158 $ builder =
new LDUserBuilder (
"[email protected] " );
159159 $ user = $ builder ->ip ("127.0.0.1 " )->build ();
160160 $ json = $ this ->getJsonForUserBySerializingEvent ($ user );
161- $ this ->assertEquals ("127.0.0.1 " , $ json ['ip ' ]);
161+ $ this ->assertSame ("127.0.0.1 " , $ json ['ip ' ]);
162162 }
163163
164164 public function testUserCountry ()
165165 {
166166 $ builder =
new LDUserBuilder (
"[email protected] " );
167167 $ user = $ builder ->country ("US " )->build ();
168168 $ json = $ this ->getJsonForUserBySerializingEvent ($ user );
169- $ this ->assertEquals ("US " , $ json ['country ' ]);
169+ $ this ->assertSame ("US " , $ json ['country ' ]);
170170 }
171171
172172 public function testUserEmail ()
173173 {
174174 $ builder =
new LDUserBuilder (
"[email protected] " );
175175 $ user =
$ builder->
email (
"[email protected] " )->
build ();
176176 $ json = $ this ->getJsonForUserBySerializingEvent ($ user );
177- $ this ->
assertEquals (
"[email protected] " ,
$ json[
'email ' ]);
177+ $ this ->
assertSame (
"[email protected] " ,
$ json[
'email ' ]);
178178 }
179179
180180 public function testUserName ()
181181 {
182182 $ builder =
new LDUserBuilder (
"[email protected] " );
183183 $ user = $ builder ->name ("Foo Bar " )->build ();
184184 $ json = $ this ->getJsonForUserBySerializingEvent ($ user );
185- $ this ->assertEquals ("Foo Bar " , $ json ['name ' ]);
185+ $ this ->assertSame ("Foo Bar " , $ json ['name ' ]);
186186 }
187187
188188 public function testUserAvatar ()
189189 {
190190 $ builder =
new LDUserBuilder (
"[email protected] " );
191191 $ user = $ builder ->avatar ("http://www.gravatar.com/avatar/1 " )->build ();
192192 $ 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 ' ]);
194194 }
195195
196196 public function testUserFirstName ()
197197 {
198198 $ builder =
new LDUserBuilder (
"[email protected] " );
199199 $ user = $ builder ->firstName ("Foo " )->build ();
200200 $ json = $ this ->getJsonForUserBySerializingEvent ($ user );
201- $ this ->assertEquals ("Foo " , $ json ['firstName ' ]);
201+ $ this ->assertSame ("Foo " , $ json ['firstName ' ]);
202202 }
203203
204204 public function testUserLastName ()
205205 {
206206 $ builder =
new LDUserBuilder (
"[email protected] " );
207207 $ user = $ builder ->lastName ("Bar " )->build ();
208208 $ json = $ this ->getJsonForUserBySerializingEvent ($ user );
209- $ this ->assertEquals ("Bar " , $ json ['lastName ' ]);
209+ $ this ->assertSame ("Bar " , $ json ['lastName ' ]);
210210 }
211211
212212 public function testUserAnonymous ()
213213 {
214214 $ builder =
new LDUserBuilder (
"[email protected] " );
215215 $ user = $ builder ->anonymous (true )->build ();
216216 $ 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 (
"[email protected] " );
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
218254 }
219255}
0 commit comments