mirror of
https://github.com/henrywhitaker3/Speedtest-Tracker.git
synced 2025-12-29 22:41:20 +01:00
Fix some tests
This commit is contained in:
@@ -56,7 +56,6 @@ class APISpeedtestTest extends TestCase
|
||||
|
||||
$response->assertStatus(200);
|
||||
$response->assertJsonStructure([
|
||||
'method',
|
||||
'data' => [
|
||||
'id',
|
||||
'ping',
|
||||
|
||||
@@ -2,11 +2,18 @@
|
||||
|
||||
namespace Tests\Unit\Helpers\SpeedtestHelper;
|
||||
|
||||
use App\Helpers\SpeedtestHelper;
|
||||
use App\Utils\OoklaTester;
|
||||
use PHPUnit\Framework\TestCase;
|
||||
|
||||
class CheckOutputTest extends TestCase
|
||||
{
|
||||
private OoklaTester $speedtestProvider;
|
||||
|
||||
public function __construct()
|
||||
{
|
||||
$this->speedtestProvider = new OoklaTester();
|
||||
}
|
||||
|
||||
/**
|
||||
* A basic unit test example.
|
||||
*
|
||||
@@ -16,9 +23,9 @@ class CheckOutputTest extends TestCase
|
||||
{
|
||||
$expected = [
|
||||
'type' => 'result',
|
||||
'download' => [ 'bandwidth' => '*' ],
|
||||
'upload' => [ 'bandwidth' => '*' ],
|
||||
'ping' => [ 'latency' => '*' ],
|
||||
'download' => ['bandwidth' => '*'],
|
||||
'upload' => ['bandwidth' => '*'],
|
||||
'ping' => ['latency' => '*'],
|
||||
'server' => [
|
||||
'id' => '*',
|
||||
'name' => '*',
|
||||
@@ -30,7 +37,7 @@ class CheckOutputTest extends TestCase
|
||||
]
|
||||
];
|
||||
|
||||
$this->assertTrue(SpeedtestHelper::checkOutputIsComplete($expected));
|
||||
$this->assertTrue($this->speedtestProvider->isOutputComplete($expected));
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -42,7 +49,7 @@ class CheckOutputTest extends TestCase
|
||||
{
|
||||
$expected = [
|
||||
'type' => 'result',
|
||||
'download' => [ 'bandwidth' => '*' ],
|
||||
'download' => ['bandwidth' => '*'],
|
||||
'server' => [
|
||||
'id' => '*',
|
||||
'name' => '*',
|
||||
@@ -54,6 +61,6 @@ class CheckOutputTest extends TestCase
|
||||
]
|
||||
];
|
||||
|
||||
$this->assertFalse(SpeedtestHelper::checkOutputIsComplete($expected));
|
||||
$this->assertFalse($this->speedtestProvider->isOutputComplete($expected));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -3,6 +3,7 @@
|
||||
namespace Tests\Unit\Helpers\SpeedtestHelper;
|
||||
|
||||
use App\Helpers\SpeedtestHelper;
|
||||
use App\Utils\OoklaTester;
|
||||
use Illuminate\Foundation\Testing\RefreshDatabase;
|
||||
use JsonException;
|
||||
use Tests\TestCase;
|
||||
@@ -13,11 +14,15 @@ class SpeedtestTest extends TestCase
|
||||
|
||||
private $output;
|
||||
|
||||
public function setUp() : void
|
||||
private OoklaTester $speedtestProvider;
|
||||
|
||||
public function setUp(): void
|
||||
{
|
||||
parent::setUp();
|
||||
|
||||
$this->output = SpeedtestHelper::output();
|
||||
$this->speedtestProvider = new OoklaTester();
|
||||
|
||||
$this->output = $this->speedtestProvider->output();
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -39,7 +44,7 @@ class SpeedtestTest extends TestCase
|
||||
{
|
||||
$output = json_decode($this->output, true);
|
||||
|
||||
$test = SpeedtestHelper::runSpeedtest($this->output);
|
||||
$test = $this->speedtestProvider->run($this->output);
|
||||
|
||||
$this->assertEquals($output['ping']['latency'], $test->ping);
|
||||
$this->assertEquals(SpeedtestHelper::convert($output['download']['bandwidth']), $test->download);
|
||||
@@ -55,7 +60,7 @@ class SpeedtestTest extends TestCase
|
||||
{
|
||||
$json = '{hi: hi}';
|
||||
|
||||
$o = SpeedtestHelper::runSpeedtest($json);
|
||||
$o = $this->speedtestProvider->run($json);
|
||||
|
||||
$this->assertFalse($o);
|
||||
}
|
||||
@@ -69,7 +74,7 @@ class SpeedtestTest extends TestCase
|
||||
{
|
||||
$json = '{"hi": "hi"}';
|
||||
|
||||
$o = SpeedtestHelper::runSpeedtest($json);
|
||||
$o = $this->speedtestProvider->run($json);
|
||||
|
||||
$this->assertFalse($o);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user