-
-
Notifications
You must be signed in to change notification settings - Fork 14
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
3 changed files
with
64 additions
and
21 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,62 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
namespace h4kuna\Exchange\Tests; | ||
|
||
use Closure; | ||
use DateTime; | ||
use h4kuna\Exchange\Utils; | ||
use Tester\Assert; | ||
use Tester\TestCase; | ||
|
||
require __DIR__ . '/../bootstrap.php'; | ||
|
||
final class UtilsTest extends TestCase | ||
{ | ||
/** | ||
* @return array<string|int, array{0: Closure(static):void}> | ||
*/ | ||
public function data(): array | ||
{ | ||
return [ | ||
[ | ||
function (self $self) { | ||
$self->assert( | ||
901, | ||
new DateTime('+901 seconds'), | ||
); | ||
}, | ||
], | ||
[ | ||
function (self $self) { | ||
$self->assert( | ||
87300, | ||
new DateTime('+900 seconds'), | ||
); | ||
}, | ||
], | ||
]; | ||
} | ||
|
||
|
||
/** | ||
* @param Closure(static):void $assert | ||
* @dataProvider data | ||
*/ | ||
public function testCountTTL(Closure $assert): void | ||
{ | ||
$assert($this); | ||
} | ||
|
||
|
||
public function assert( | ||
int $expectedTime, | ||
DateTime $from | ||
): void | ||
{ | ||
Assert::same($expectedTime, Utils::countTTL($from)); | ||
} | ||
} | ||
|
||
(new UtilsTest())->run(); |