Files
librenms-librenms/tests/Unit/Util/RewriteTest.php
Kevin Zink 93209a0fc8 API mac search (#12964)
* 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
2021-08-09 19:33:04 -05:00

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'],
];
}
}