|
14 | 14 | beforeEach(function () { |
15 | 15 | Queue::fake(); |
16 | 16 | Redis::flushdb(); |
| 17 | + |
| 18 | + config(['metrics.queue' => false]); |
17 | 19 | }); |
18 | 20 |
|
19 | 21 | it('displays message when no metrics to commit', function () { |
|
25 | 27 | }); |
26 | 28 |
|
27 | 29 | it('commits captured metrics without queueing', function () { |
28 | | - config(['metrics.queue' => false]); |
29 | | - |
30 | 30 | Metrics::capture(); |
31 | 31 | Metrics::record(new MetricData('page_views')); |
32 | 32 | Metrics::record(new MetricData('page_views')); |
|
62 | 62 | }); |
63 | 63 |
|
64 | 64 | it('displays singular message for one metric', function () { |
65 | | - config(['metrics.queue' => false]); |
66 | | - |
67 | 65 | Metrics::capture(); |
68 | 66 | Metrics::record(new MetricData('page_views')); |
69 | 67 |
|
|
75 | 73 | }); |
76 | 74 |
|
77 | 75 | it('displays plural message for multiple metrics', function () { |
78 | | - config(['metrics.queue' => false]); |
79 | | - |
80 | 76 | Metrics::capture(); |
81 | 77 | Metrics::record(new MetricData('page_views')); |
82 | 78 | Metrics::record(new MetricData('api_calls')); |
|
90 | 86 | }); |
91 | 87 |
|
92 | 88 | it('flushes repository after committing', function () { |
93 | | - config(['metrics.queue' => false]); |
94 | | - |
95 | 89 | Metrics::capture(); |
96 | 90 | Metrics::record(new MetricData('page_views')); |
97 | 91 |
|
|
109 | 103 | }); |
110 | 104 |
|
111 | 105 | it('commits metrics with categories', function () { |
112 | | - config(['metrics.queue' => false]); |
113 | | - |
114 | 106 | Metrics::capture(); |
115 | 107 | Metrics::record(new MetricData('page_views', 'marketing')); |
116 | 108 | Metrics::record(new MetricData('page_views', 'analytics')); |
|
127 | 119 | }); |
128 | 120 |
|
129 | 121 | it('commits metrics with measurable models', function () { |
130 | | - config(['metrics.queue' => false]); |
131 | | - |
132 | 122 | $user1 = createUser([ 'name' => 'John', 'email' => '[email protected]']); |
133 | 123 | $user2 = createUser([ 'name' => 'Jane', 'email' => '[email protected]']); |
134 | 124 |
|
|
148 | 138 | }); |
149 | 139 |
|
150 | 140 | it('commits large number of metrics', function () { |
151 | | - config(['metrics.queue' => false]); |
152 | | - |
153 | 141 | Metrics::capture(); |
154 | 142 |
|
155 | 143 | for ($i = 0; $i < 100; $i++) { |
|
165 | 153 | }); |
166 | 154 |
|
167 | 155 | it('can be run multiple times', function () { |
168 | | - config(['metrics.queue' => false]); |
169 | | - |
170 | 156 | Metrics::capture(); |
171 | 157 | Metrics::record(new MetricData('page_views')); |
172 | 158 |
|
|
184 | 170 | }); |
185 | 171 |
|
186 | 172 | it('works when capturing is not enabled', function () { |
187 | | - config(['metrics.queue' => false]); |
188 | | - |
189 | 173 | // Record without capturing |
190 | 174 | Metrics::record(new MetricData('page_views')); |
191 | 175 |
|
|
198 | 182 | }); |
199 | 183 |
|
200 | 184 | it('commits metrics with custom values', function () { |
201 | | - config(['metrics.queue' => false]); |
202 | | - |
203 | 185 | Metrics::capture(); |
204 | 186 | Metrics::record(new MetricData('revenue', value: 100)); |
205 | 187 | Metrics::record(new MetricData('revenue', value: 250)); |
|
214 | 196 | }); |
215 | 197 |
|
216 | 198 | it('commits metrics with different dates separately', function () { |
217 | | - config(['metrics.queue' => false]); |
218 | | - |
219 | 199 | $today = now(); |
220 | 200 | $yesterday = now()->subDay(); |
221 | 201 |
|
|
231 | 211 | }); |
232 | 212 |
|
233 | 213 | it('handles metrics with all properties', function () { |
234 | | - config(['metrics.queue' => false]); |
235 | | - |
236 | 214 | $user = createUser(); |
237 | 215 | $date = now(); |
238 | 216 |
|
|
253 | 231 | }); |
254 | 232 |
|
255 | 233 | it('works with redis repository', function () { |
256 | | - config(['metrics.queue' => false]); |
257 | | - |
258 | 234 | // Bind Redis repository |
259 | 235 | $this->app->singleton( |
260 | 236 | MetricRepository::class, |
|
0 commit comments