@@ -19,7 +19,7 @@ public function adding_stats_will_add_them_to_the_collection()
1919
2020 $ this ->assertEquals ([
2121 ['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 ],
2323 ['stat ' => 'stat3 ' , 'value ' => 'other ' , 'tags ' => ['key ' => 'value ' ], 'sample-rate ' => 1.0 ],
2424 ], $ collection ->toArray ());
2525 }
@@ -36,7 +36,7 @@ public function adding_the_same_stat_multiple_times_will_add_them_to_the_collect
3636
3737 $ this ->assertEquals ([
3838 ['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 ],
4040 ['stat ' => 'stat ' , 'value ' => 'other ' , 'tags ' => ['key ' => 'value ' ], 'sample-rate ' => 1.0 ],
4141 ], $ collection ->toArray ());
4242 }
@@ -55,7 +55,7 @@ public function filtering_by_stat_will_remove_all_other_stats()
5555
5656 $ this ->assertEquals ([
5757 ['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 ],
5959 ], $ collection ->toArray ());
6060 }
6161
@@ -73,7 +73,7 @@ public function filtering_by_value_will_remove_all_stats_with_different_values()
7373
7474 $ this ->assertEquals ([
7575 ['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 ],
7777 ], $ collection ->toArray ());
7878 }
7979
@@ -110,8 +110,8 @@ public function filtering_by_tags_will_remove_all_stats_with_different_tags()
110110 $ collection = $ collection ->filterByTags ('tags ' );
111111
112112 $ 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 ],
115115 ], $ collection ->toArray ());
116116 }
117117
@@ -130,7 +130,28 @@ public function filtering_by_multiple_fields_will_return_the_correct_set()
130130 $ collection = $ collection ->filterByStat ('stat1 ' )->filterByValue ('test ' )->filterByTags ('tags ' );
131131
132132 $ 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 ],
134134 ], $ collection ->toArray ());
135135 }
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+ }
136157}
0 commit comments