@@ -1,12 +1,15 @@
|
||||
<?php
|
||||
|
||||
use App\Facades\Utils;
|
||||
use App\Support\ICAO;
|
||||
use App\Support\Units\Time;
|
||||
use App\Support\Utils;
|
||||
use Carbon\Carbon;
|
||||
|
||||
class UtilsTest extends TestCase
|
||||
{
|
||||
public function testDates()
|
||||
{
|
||||
$carbon = new \Carbon\Carbon('2018-04-28T12:55:40Z');
|
||||
$carbon = new Carbon('2018-04-28T12:55:40Z');
|
||||
$this->assertNotNull($carbon);
|
||||
}
|
||||
|
||||
@@ -15,46 +18,49 @@ class UtilsTest extends TestCase
|
||||
*/
|
||||
public function testSecondsToTimeParts()
|
||||
{
|
||||
$t = Utils::secondsToTimeParts(3600);
|
||||
$t = Time::secondsToTimeParts(3600);
|
||||
$this->assertEquals(['h' => 1, 'm' => 0, 's' => 0], $t);
|
||||
|
||||
$t = Utils::secondsToTimeParts(3720);
|
||||
$t = Time::secondsToTimeParts(3720);
|
||||
$this->assertEquals(['h' => 1, 'm' => 2, 's' => 0], $t);
|
||||
|
||||
$t = Utils::secondsToTimeParts(3722);
|
||||
$t = Time::secondsToTimeParts(3722);
|
||||
$this->assertEquals(['h' => 1, 'm' => 2, 's' => 2], $t);
|
||||
|
||||
$t = Utils::secondsToTimeParts(60);
|
||||
$t = Time::secondsToTimeParts(60);
|
||||
$this->assertEquals(['h' => 0, 'm' => 1, 's' => 0], $t);
|
||||
|
||||
$t = Utils::secondsToTimeParts(62);
|
||||
$t = Time::secondsToTimeParts(62);
|
||||
$this->assertEquals(['h' => 0, 'm' => 1, 's' => 2], $t);
|
||||
}
|
||||
|
||||
/**
|
||||
* @throws \Exception
|
||||
*/
|
||||
public function testSecondsToTime()
|
||||
{
|
||||
$t = Utils::secondsToTimeString(3600);
|
||||
$t = Time::secondsToTimeString(3600);
|
||||
$this->assertEquals('1h 0m', $t);
|
||||
|
||||
$t = Utils::secondsToTimeString(3720);
|
||||
$t = Time::secondsToTimeString(3720);
|
||||
$this->assertEquals('1h 2m', $t);
|
||||
|
||||
$t = Utils::secondsToTimeString(3722);
|
||||
$t = Time::secondsToTimeString(3722);
|
||||
$this->assertEquals('1h 2m', $t);
|
||||
|
||||
$t = Utils::secondsToTimeString(3722, true);
|
||||
$t = Time::secondsToTimeString(3722, true);
|
||||
$this->assertEquals('1h 2m 2s', $t);
|
||||
}
|
||||
|
||||
public function testMinutesToTime()
|
||||
{
|
||||
$t = Utils::minutesToTimeParts(65);
|
||||
$t = Time::minutesToTimeParts(65);
|
||||
$this->assertEquals(['h' => 1, 'm' => 5], $t);
|
||||
|
||||
$t = Utils::minutesToTimeString(65);
|
||||
$t = Time::minutesToTimeString(65);
|
||||
$this->assertEquals('1h 5m', $t);
|
||||
|
||||
$t = Utils::minutesToTimeString(43200);
|
||||
$t = Time::minutesToTimeString(43200);
|
||||
$this->assertEquals('720h 0m', $t);
|
||||
}
|
||||
|
||||
@@ -64,9 +70,12 @@ class UtilsTest extends TestCase
|
||||
$this->assertNotNull($api_key);
|
||||
}
|
||||
|
||||
/**
|
||||
* @throws \Exception
|
||||
*/
|
||||
public function testHexCode()
|
||||
{
|
||||
$hex_code = \App\Support\ICAO::createHexCode();
|
||||
$hex_code = ICAO::createHexCode();
|
||||
$this->assertNotNull($hex_code);
|
||||
}
|
||||
|
||||
@@ -82,9 +91,9 @@ class UtilsTest extends TestCase
|
||||
];
|
||||
|
||||
foreach ($tests as $case) {
|
||||
$this->assertEquals('phpvms.net', \App\Support\Utils::getRootDomain($case));
|
||||
$this->assertEquals('phpvms.net', Utils::getRootDomain($case));
|
||||
}
|
||||
|
||||
$this->assertEquals('phpvms', \App\Support\Utils::getRootDomain('http://phpvms'));
|
||||
$this->assertEquals('phpvms', Utils::getRootDomain('http://phpvms'));
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user