mirror of
https://github.com/librenms/librenms.git
synced 2024-10-07 16:52:45 +00:00
* API find a switchport with the mac from device * fix style * convert SQL to Eloquent * convert SQL to Eloquent * git mistake * Global use App\Models\Port * git mistake partII * Refractor Eloquent - Not finish but easier to help for others * Better Eloquent Query without filter option * Validation * fix style * Add filter option and DOC * convert to the better macToHex method * add a maxToHex unit test * fix style * fix style * fix syle - seems my dev:check is running again :-) * Fix phpStan * phpStan #2
37 lines
1.0 KiB
PHP
37 lines
1.0 KiB
PHP
<?php
|
|
|
|
namespace LibreNMS\Tests\Unit\Util;
|
|
|
|
use LibreNMS\Tests\TestCase;
|
|
use LibreNMS\Util\Rewrite;
|
|
|
|
class RewriteTest extends TestCase
|
|
{
|
|
/**
|
|
* @test
|
|
* @dataProvider validMacProvider
|
|
*/
|
|
public function testMacToHex(string $from, string $to): void
|
|
{
|
|
$this->assertEquals(Rewrite::macToHex($from), $to);
|
|
}
|
|
|
|
public function validMacProvider(): array
|
|
{
|
|
return [
|
|
['00:00:00:00:00:01', '000000000001'],
|
|
['00-00-00-00-00-01', '000000000001'],
|
|
['000000.000001', '000000000001'],
|
|
['000000000001', '000000000001'],
|
|
['00:12:34:ab:cd:ef', '001234abcdef'],
|
|
['00:12:34:AB:CD:EF', '001234ABCDEF'],
|
|
['0:12:34:AB:CD:EF', '001234ABCDEF'],
|
|
['00-12-34-AB-CD-EF', '001234ABCDEF'],
|
|
['001234-ABCDEF', '001234ABCDEF'],
|
|
['0012.34AB.CDEF', '001234ABCDEF'],
|
|
['00:02:04:0B:0D:0F', '0002040B0D0F'],
|
|
['0:2:4:B:D:F', '0002040B0D0F'],
|
|
];
|
|
}
|
|
}
|