@@ -29,7 +29,7 @@ public function testSetTag(): void
29
29
$ this ->assertSame (['foo ' => 'bar ' , 'bar ' => 'baz ' ], $ event ->getTagsContext ()->toArray ());
30
30
}
31
31
32
- public function setTags (): void
32
+ public function testSetTags (): void
33
33
{
34
34
$ scope = new Scope ();
35
35
$ scope ->setTags (['foo ' => 'bar ' ]);
@@ -82,7 +82,12 @@ public function testSetExtras(): void
82
82
$ this ->assertSame (['foo ' => 'bar ' , 'bar ' => 'baz ' ], $ event ->getExtraContext ()->toArray ());
83
83
}
84
84
85
- public function testSetUser (): void
85
+ /**
86
+ * @group legacy
87
+ *
88
+ * @expectedDeprecation Replacing the data is deprecated since version 2.3 and will stop working from version 3.0. Set the second argument to `true` to merge the data instead.
89
+ */
90
+ public function testSetUserThrowsDeprecation (): void
86
91
{
87
92
$ scope = new Scope ();
88
93
@@ -106,6 +111,30 @@ public function testSetUser(): void
106
111
$ this ->assertSame (['bar ' => 'baz ' ], $ event ->getUserContext ()->toArray ());
107
112
}
108
113
114
+ public function testSetUser (): void
115
+ {
116
+ $ scope = new Scope ();
117
+
118
+ $ event = $ scope ->applyToEvent (new Event (), []);
119
+
120
+ $ this ->assertNotNull ($ event );
121
+ $ this ->assertSame ([], $ event ->getUserContext ()->toArray ());
122
+
123
+ $ scope ->setUser (['foo ' => 'bar ' ], true );
124
+
125
+ $ event = $ scope ->applyToEvent (new Event (), []);
126
+
127
+ $ this ->assertNotNull ($ event );
128
+ $ this ->assertSame (['foo ' => 'bar ' ], $ event ->getUserContext ()->toArray ());
129
+
130
+ $ scope ->setUser (['bar ' => 'baz ' ], true );
131
+
132
+ $ event = $ scope ->applyToEvent (new Event (), []);
133
+
134
+ $ this ->assertNotNull ($ event );
135
+ $ this ->assertSame (['foo ' => 'bar ' , 'bar ' => 'baz ' ], $ event ->getUserContext ()->toArray ());
136
+ }
137
+
109
138
public function testSetFingerprint (): void
110
139
{
111
140
$ scope = new Scope ();
@@ -237,7 +266,7 @@ public function testClear(): void
237
266
$ scope ->setFingerprint (['foo ' ]);
238
267
$ scope ->setExtras (['foo ' => 'bar ' ]);
239
268
$ scope ->setTags (['bar ' => 'foo ' ]);
240
- $ scope ->setUser (['foobar ' => 'barfoo ' ]);
269
+ $ scope ->setUser (['foobar ' => 'barfoo ' ], true );
241
270
242
271
$ event = $ scope ->applyToEvent (new Event (), []);
243
272
@@ -273,7 +302,7 @@ public function testApplyToEvent(): void
273
302
$ scope ->addBreadcrumb ($ breadcrumb );
274
303
$ scope ->setTag ('foo ' , 'bar ' );
275
304
$ scope ->setExtra ('bar ' , 'foo ' );
276
- $ scope ->setUser (['foo ' => 'baz ' ]);
305
+ $ scope ->setUser (['foo ' => 'baz ' ], true );
277
306
278
307
$ event = $ scope ->applyToEvent ($ event , []);
279
308
@@ -290,7 +319,7 @@ public function testApplyToEvent(): void
290
319
$ scope ->setLevel (Severity::fatal ());
291
320
$ scope ->setTag ('bar ' , 'foo ' );
292
321
$ scope ->setExtra ('foo ' , 'bar ' );
293
- $ scope ->setUser (['baz ' => 'foo ' ]);
322
+ $ scope ->setUser (['baz ' => 'foo ' ], true );
294
323
295
324
$ event = $ scope ->applyToEvent ($ event , []);
296
325
0 commit comments