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
|
<?php
namespace PhpAmqpLib\Tests\Unit\Helper;
use PhpAmqpLib\Helper\MiscHelper;
use PhpAmqpLib\Tests\TestCaseCompat;
use PHPUnit\Framework\Attributes\DataProvider;
use PHPUnit\Framework\Attributes\Test;
class MiscHelperTest extends TestCaseCompat
{
#[DataProvider('splitSecondsMicrosecondsData')]
#[Test]
public function split_seconds_microseconds($input, $expected)
{
self::assertEquals($expected, MiscHelper::splitSecondsMicroseconds($input));
}
#[DataProvider('hexdumpData')]
#[Test]
public function hexdump($args, $expected)
{
self::assertPattern($expected, MiscHelper::hexdump($args[0], $args[1], $args[2], $args[3]));
}
#[Test]
public function method_sig()
{
self::assertEquals('test', MiscHelper::methodSig('test'));
}
public static function splitSecondsMicrosecondsData(): array
{
return [
[0, [0, 0]],
[0.3, [0, 300000]],
['0.3', [0, 300000]],
[3, [3, 0]],
['3', [3, 0]],
[3.0, [3, 0]],
['3.0', [3, 0]],
[3.1, [3, 100000]],
['3.1', [3, 100000]],
[3.123456, [3, 123456]],
['3.123456', [3, 123456]],
];
}
public static function hexdumpData(): array
{
return [
[['FM', false, false, true], '/000\s+46 4d\s+FM/'],
[['FM', false, true, true], '/000\s+46 4D\s+FM/'],
];
}
}
|