forked from alexjustesen/speedtest-tracker
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMultiServiceSpeedtestTest.php
More file actions
85 lines (66 loc) · 2.23 KB
/
MultiServiceSpeedtestTest.php
File metadata and controls
85 lines (66 loc) · 2.23 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
<?php
namespace Tests\Feature;
use App\Actions\Speedtest\RunSpeedtest;
use App\Enums\ResultService;
use App\Settings\GeneralSettings;
use Illuminate\Support\Facades\Bus;
use Tests\TestCase;
class MultiServiceSpeedtestTest extends TestCase
{
public function test_it_dispatches_configured_services()
{
Bus::fake();
GeneralSettings::fake([
'ookla_enabled' => true,
'fast_enabled' => true,
'execution_mode' => 'parallel',
]);
$action = app(RunSpeedtest::class);
$results = $action->handle();
$this->assertCount(2, $results);
$this->assertEquals(ResultService::Ookla, $results[0]->service);
$this->assertEquals(ResultService::Fast, $results[1]->service);
Bus::assertBatched(function ($batch) {
return $batch->name === 'Ookla Speedtest';
});
Bus::assertBatched(function ($batch) {
return $batch->name === 'Fast Speedtest';
});
}
public function test_it_runs_only_ookla_when_fast_disabled()
{
Bus::fake();
GeneralSettings::fake([
'ookla_enabled' => true,
'fast_enabled' => false,
'execution_mode' => 'parallel',
]);
$action = app(RunSpeedtest::class);
$results = $action->handle();
$this->assertCount(1, $results);
$this->assertEquals(ResultService::Ookla, $results[0]->service);
Bus::assertBatched(function ($batch) {
return $batch->name === 'Ookla Speedtest';
});
Bus::assertNothingBatched(function ($batch) {
return $batch->name === 'Fast Speedtest';
});
}
public function test_it_dispatches_single_batch_for_sequential_mode()
{
Bus::fake();
GeneralSettings::fake([
'ookla_enabled' => true,
'fast_enabled' => true,
'execution_mode' => 'sequential',
]);
$action = app(RunSpeedtest::class);
$action->handle();
Bus::assertBatched(function ($batch) {
return $batch->name === 'Sequential Speedtests';
});
Bus::assertNothingBatched(function ($batch) {
return $batch->name === 'Ookla Speedtest';
});
}
}