mirror of
https://github.com/henrywhitaker3/Speedtest-Tracker.git
synced 2026-01-05 04:15:23 +01:00
Added unit tests for helpers and tests for commands
This commit is contained in:
46
tests/Unit/Helpers/SpeedtestHelper/FailureRateTest.php
Normal file
46
tests/Unit/Helpers/SpeedtestHelper/FailureRateTest.php
Normal file
@@ -0,0 +1,46 @@
|
||||
<?php
|
||||
|
||||
namespace Tests\Unit\Helpers\SpeedtestHelper;
|
||||
|
||||
use App\Helpers\SpeedtestHelper;
|
||||
use App\Speedtest;
|
||||
use Illuminate\Foundation\Testing\RefreshDatabase;
|
||||
use Tests\TestCase;
|
||||
|
||||
class FailureRateTest extends TestCase
|
||||
{
|
||||
use RefreshDatabase;
|
||||
|
||||
/**
|
||||
* A basic unit test example.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function testFailureRate()
|
||||
{
|
||||
$success = rand(1, 15);
|
||||
$failed = rand(1, 15);
|
||||
|
||||
for($i = 0; $i < $success; $i++) {
|
||||
Speedtest::create([
|
||||
'ping' => 5,
|
||||
'download' => 5,
|
||||
'upload' => 5
|
||||
]);
|
||||
}
|
||||
|
||||
for($i = 0; $i < $failed; $i++) {
|
||||
Speedtest::create([
|
||||
'ping' => 5,
|
||||
'download' => 5,
|
||||
'upload' => 5,
|
||||
'failed' => true
|
||||
]);
|
||||
}
|
||||
|
||||
$output = SpeedtestHelper::failureRate(1);
|
||||
|
||||
$this->assertEquals($output[0]['success'], $success);
|
||||
$this->assertEquals($output[0]['failure'], $failed);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user