@@ -19,7 +19,7 @@ public function adding_stats_will_add_them_to_the_collection()
19
19
20
20
$ this ->assertEquals ([
21
21
['stat ' => 'stat1 ' , 'value ' => 'test ' , 'tags ' => null , 'sample-rate ' => 1.0 ],
22
- ['stat ' => 'stat2 ' , 'value ' => 'test ' , 'tags ' => 'tags ' , 'sample-rate ' => 1.0 ],
22
+ ['stat ' => 'stat2 ' , 'value ' => 'test ' , 'tags ' => [ 'tags ' => null ] , 'sample-rate ' => 1.0 ],
23
23
['stat ' => 'stat3 ' , 'value ' => 'other ' , 'tags ' => ['key ' => 'value ' ], 'sample-rate ' => 1.0 ],
24
24
], $ collection ->toArray ());
25
25
}
@@ -36,7 +36,7 @@ public function adding_the_same_stat_multiple_times_will_add_them_to_the_collect
36
36
37
37
$ this ->assertEquals ([
38
38
['stat ' => 'stat ' , 'value ' => 'test ' , 'tags ' => null , 'sample-rate ' => 1.0 ],
39
- ['stat ' => 'stat ' , 'value ' => 'test ' , 'tags ' => 'tags ' , 'sample-rate ' => 1.0 ],
39
+ ['stat ' => 'stat ' , 'value ' => 'test ' , 'tags ' => [ 'tags ' => null ] , 'sample-rate ' => 1.0 ],
40
40
['stat ' => 'stat ' , 'value ' => 'other ' , 'tags ' => ['key ' => 'value ' ], 'sample-rate ' => 1.0 ],
41
41
], $ collection ->toArray ());
42
42
}
@@ -55,7 +55,7 @@ public function filtering_by_stat_will_remove_all_other_stats()
55
55
56
56
$ this ->assertEquals ([
57
57
['stat ' => 'stat1 ' , 'value ' => 'test ' , 'tags ' => null , 'sample-rate ' => 1.0 ],
58
- ['stat ' => 'stat1 ' , 'value ' => 'test ' , 'tags ' => 'tags ' , 'sample-rate ' => 1.0 ],
58
+ ['stat ' => 'stat1 ' , 'value ' => 'test ' , 'tags ' => [ 'tags ' => null ] , 'sample-rate ' => 1.0 ],
59
59
], $ collection ->toArray ());
60
60
}
61
61
@@ -73,7 +73,7 @@ public function filtering_by_value_will_remove_all_stats_with_different_values()
73
73
74
74
$ this ->assertEquals ([
75
75
['stat ' => 'stat1 ' , 'value ' => 'test ' , 'tags ' => null , 'sample-rate ' => 1.0 ],
76
- ['stat ' => 'stat2 ' , 'value ' => 'test ' , 'tags ' => 'tags ' , 'sample-rate ' => 1.0 ],
76
+ ['stat ' => 'stat2 ' , 'value ' => 'test ' , 'tags ' => [ 'tags ' => null ] , 'sample-rate ' => 1.0 ],
77
77
], $ collection ->toArray ());
78
78
}
79
79
@@ -110,8 +110,8 @@ public function filtering_by_tags_will_remove_all_stats_with_different_tags()
110
110
$ collection = $ collection ->filterByTags ('tags ' );
111
111
112
112
$ this ->assertEquals ([
113
- ['stat ' => 'stat2 ' , 'value ' => 'test ' , 'tags ' => 'tags ' , 'sample-rate ' => 1.0 ],
114
- ['stat ' => 'stat3 ' , 'value ' => 'another ' , 'tags ' => 'tags ' , 'sample-rate ' => 1.0 ],
113
+ ['stat ' => 'stat2 ' , 'value ' => 'test ' , 'tags ' => [ 'tags ' => null ] , 'sample-rate ' => 1.0 ],
114
+ ['stat ' => 'stat3 ' , 'value ' => 'another ' , 'tags ' => [ 'tags ' => null ] , 'sample-rate ' => 1.0 ],
115
115
], $ collection ->toArray ());
116
116
}
117
117
@@ -130,7 +130,28 @@ public function filtering_by_multiple_fields_will_return_the_correct_set()
130
130
$ collection = $ collection ->filterByStat ('stat1 ' )->filterByValue ('test ' )->filterByTags ('tags ' );
131
131
132
132
$ this ->assertEquals ([
133
- ['stat ' => 'stat1 ' , 'value ' => 'test ' , 'tags ' => 'tags ' , 'sample-rate ' => 1.0 ],
133
+ ['stat ' => 'stat1 ' , 'value ' => 'test ' , 'tags ' => [ 'tags ' => null ] , 'sample-rate ' => 1.0 ],
134
134
], $ collection ->toArray ());
135
135
}
136
+
137
+ /**
138
+ * @test
139
+ */
140
+ public function filtering_by_tags_will_match_stats_that_have_the_same_normalized_tags ()
141
+ {
142
+ $ collection = new StatsCollection ();
143
+ $ collection ->add ('stat1 ' , 'test ' , 1.0 , 'tags ' )
144
+ ->add ('stat2 ' , 'other ' , 1.0 , ['key ' => 'value ' ])
145
+ ->add ('stat3 ' , 'another ' , 1.0 , ['tags ' => null ]);
146
+
147
+ $ this ->assertEquals ([
148
+ ['stat ' => 'stat1 ' , 'value ' => 'test ' , 'tags ' => ['tags ' => null ], 'sample-rate ' => 1.0 ],
149
+ ['stat ' => 'stat3 ' , 'value ' => 'another ' , 'tags ' => ['tags ' => null ], 'sample-rate ' => 1.0 ],
150
+ ], $ collection ->filterByTags ('tags ' )->toArray ());
151
+
152
+ $ this ->assertEquals ([
153
+ ['stat ' => 'stat1 ' , 'value ' => 'test ' , 'tags ' => ['tags ' => null ], 'sample-rate ' => 1.0 ],
154
+ ['stat ' => 'stat3 ' , 'value ' => 'another ' , 'tags ' => ['tags ' => null ], 'sample-rate ' => 1.0 ],
155
+ ], $ collection ->filterByTags (['tags ' => null ])->toArray ());
156
+ }
136
157
}
0 commit comments