Skip to content

Commit d17417d

Browse files
authored
Merge pull request #398 from laravel/fix-test
[1.x] Fixes time usage in test
2 parents 419a9bf + 572951b commit d17417d

File tree

4 files changed

+39
-37
lines changed

4 files changed

+39
-37
lines changed

tests/Feature/Recorders/ExceptionsTest.php

Lines changed: 30 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -115,50 +115,50 @@
115115
it('can sample', function () {
116116
Config::set('pulse.recorders.'.Exceptions::class.'.sample_rate', 0.1);
117117

118-
report(new MyReportedException());
119-
report(new MyReportedException());
120-
report(new MyReportedException());
121-
report(new MyReportedException());
122-
report(new MyReportedException());
123-
report(new MyReportedException());
124-
report(new MyReportedException());
125-
report(new MyReportedException());
126-
report(new MyReportedException());
127-
report(new MyReportedException());
118+
report(new MyReportedException);
119+
report(new MyReportedException);
120+
report(new MyReportedException);
121+
report(new MyReportedException);
122+
report(new MyReportedException);
123+
report(new MyReportedException);
124+
report(new MyReportedException);
125+
report(new MyReportedException);
126+
report(new MyReportedException);
127+
report(new MyReportedException);
128128

129129
expect(Pulse::ingest())->toEqualWithDelta(1, 4);
130130
});
131131

132132
it('can sample at zero', function () {
133133
Config::set('pulse.recorders.'.Exceptions::class.'.sample_rate', 0);
134134

135-
report(new MyReportedException());
136-
report(new MyReportedException());
137-
report(new MyReportedException());
138-
report(new MyReportedException());
139-
report(new MyReportedException());
140-
report(new MyReportedException());
141-
report(new MyReportedException());
142-
report(new MyReportedException());
143-
report(new MyReportedException());
144-
report(new MyReportedException());
135+
report(new MyReportedException);
136+
report(new MyReportedException);
137+
report(new MyReportedException);
138+
report(new MyReportedException);
139+
report(new MyReportedException);
140+
report(new MyReportedException);
141+
report(new MyReportedException);
142+
report(new MyReportedException);
143+
report(new MyReportedException);
144+
report(new MyReportedException);
145145

146146
expect(Pulse::ingest())->toBe(0);
147147
});
148148

149149
it('can sample at one', function () {
150150
Config::set('pulse.recorders.'.Exceptions::class.'.sample_rate', 1);
151151

152-
report(new MyReportedException());
153-
report(new MyReportedException());
154-
report(new MyReportedException());
155-
report(new MyReportedException());
156-
report(new MyReportedException());
157-
report(new MyReportedException());
158-
report(new MyReportedException());
159-
report(new MyReportedException());
160-
report(new MyReportedException());
161-
report(new MyReportedException());
152+
report(new MyReportedException);
153+
report(new MyReportedException);
154+
report(new MyReportedException);
155+
report(new MyReportedException);
156+
report(new MyReportedException);
157+
report(new MyReportedException);
158+
report(new MyReportedException);
159+
report(new MyReportedException);
160+
report(new MyReportedException);
161+
report(new MyReportedException);
162162

163163
expect(Pulse::ingest())->toBe(10);
164164
});

tests/Feature/Recorders/UserRequestsTest.php

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22

33
use Illuminate\Auth\GuardHelpers;
44
use Illuminate\Contracts\Auth\Guard;
5+
use Illuminate\Support\Carbon;
56
use Illuminate\Support\Facades\Auth;
67
use Illuminate\Support\Facades\Config;
78
use Illuminate\Support\Facades\DB;
@@ -15,14 +16,15 @@
1516
use function Pest\Laravel\post;
1617

1718
it('captures authenticated requests', function () {
19+
Carbon::setTestNow('2000-01-02 03:04:05');
1820
Route::get('users', fn () => []);
1921

2022
actingAs(User::make(['id' => '567']))->get('users');
2123

2224
$entries = Pulse::ignore(fn () => DB::table('pulse_entries')->get());
2325
expect($entries)->toHaveCount(1);
2426
expect($entries[0])->toHaveProperties([
25-
'timestamp' => now()->timestamp,
27+
'timestamp' => 946782245,
2628
'type' => 'user_request',
2729
'key' => '567',
2830
'value' => null,

tests/Feature/RedisTest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -108,7 +108,7 @@ function prepareForDriver($driver)
108108
->output();
109109
[$firstEntryKey, $lastEntryKey] = collect(explode("\n", $output))->only([17, 21])->values();
110110

111-
$commands = captureRedisCommands(fn () => $ingest->digest(new StorageFake()));
111+
$commands = captureRedisCommands(fn () => $ingest->digest(new StorageFake));
112112

113113
expect($commands)->toContain('"XRANGE" "laravel_database_laravel:pulse:ingest" "-" "+" "COUNT" "567"');
114114
expect($commands)->toContain('"XDEL" "laravel_database_laravel:pulse:ingest" "'.$firstEntryKey.'" "'.$lastEntryKey.'"');

tests/StorageFake.php

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@ public function purge(?array $types = null): void
6363
*/
6464
public function values(string $type, ?array $keys = null): Collection
6565
{
66-
return new Collection();
66+
return new Collection;
6767
}
6868

6969
/**
@@ -74,7 +74,7 @@ public function values(string $type, ?array $keys = null): Collection
7474
*/
7575
public function graph(array $types, string $aggregate, CarbonInterval $interval): Collection
7676
{
77-
return new Collection();
77+
return new Collection;
7878
}
7979

8080
/**
@@ -97,7 +97,7 @@ public function aggregate(
9797
string $direction = 'desc',
9898
int $limit = 101,
9999
): Collection {
100-
return new Collection();
100+
return new Collection;
101101
}
102102

103103
/**
@@ -114,7 +114,7 @@ public function aggregateTypes(
114114
string $direction = 'desc',
115115
int $limit = 101,
116116
): Collection {
117-
return new Collection();
117+
return new Collection;
118118
}
119119

120120
/**
@@ -128,6 +128,6 @@ public function aggregateTotal(
128128
string $aggregate,
129129
CarbonInterval $interval,
130130
): Collection {
131-
return new Collection();
131+
return new Collection;
132132
}
133133
}

0 commit comments

Comments
 (0)