. */ namespace Sikofitt\GenerateMac\Tests; use PHPUnit\Framework\TestCase; use Sikofitt\GenerateMac\Mac; class MacTest extends TestCase { private const REGEX = '/^([0-9A-Fa-f]{2}[:-]){5}([0-9A-Fa-f]{2})$/'; private const NON_UNIQ_PREFIX = '02:bb:01'; public function testGetMacAddresses(): void { $mac = new Mac(); $macAddresses = $mac->getMacAddresses(50); $this->assertCount(50, $macAddresses); foreach ($macAddresses as $address) { $this->assertRegExp(self::REGEX, $address); } $this->assertRegExp(self::REGEX, $mac->getMacAddress()); } public function testSeparator(): void { $mac = new Mac('-'); $this->assertRegExp(self::REGEX, $mac->getMacAddress()); } public function testUnique(): void { $class = new class extends Mac { protected $isTest = true; }; $macAddress = $class->getMacAddress(); $this->assertStringStartsNotWith(self::NON_UNIQ_PREFIX, $macAddress); } public function testThrowsOnInvalidPrefix(): void { $this->expectException(\InvalidArgumentException::class); $mac = new Mac('_'); } }