52 lines
1.4 KiB
PHP
52 lines
1.4 KiB
PHP
<?php
|
|
|
|
namespace goodboyalex\php_components_pack\tests\extensions;
|
|
|
|
use goodboyalex\php_components_pack\extensions\GUIDExtension;
|
|
use PHPUnit\Framework\TestCase;
|
|
|
|
class GUIDExtensionTest extends TestCase
|
|
{
|
|
public function testGenerate ()
|
|
{
|
|
$this->PrepareForTest();
|
|
|
|
$guid = GUIDExtension::Generate();
|
|
$this->assertTrue(strlen($guid) === 36);
|
|
}
|
|
|
|
public function testIsNotValidOrEmpty ()
|
|
{
|
|
$this->PrepareForTest();
|
|
|
|
$guid = GUIDExtension::Generate();
|
|
$this->assertFalse(GUIDExtension::IsNotValidOrEmpty($guid));
|
|
|
|
$guid = '12345678-91101-1121-3141-516171819202';
|
|
$this->assertTrue(GUIDExtension::IsNotValidOrEmpty($guid));
|
|
|
|
$guid = GUIDExtension::GUIDEmpty;
|
|
$this->assertTrue(GUIDExtension::IsNotValidOrEmpty($guid));
|
|
}
|
|
|
|
public function testValidate ()
|
|
{
|
|
$this->PrepareForTest();
|
|
|
|
$guid = GUIDExtension::Generate();
|
|
$this->assertFalse(GUIDExtension::IsNotValidOrEmpty($guid));
|
|
|
|
$guid = '12345678-91101-1121-3141-516171819202';
|
|
$this->assertTrue(GUIDExtension::IsNotValidOrEmpty($guid));
|
|
|
|
$guid = GUIDExtension::GUIDEmpty;
|
|
$this->assertTrue(GUIDExtension::IsNotValidOrEmpty($guid));
|
|
}
|
|
|
|
private function PrepareForTest (): void
|
|
{
|
|
require_once __DIR__ . '/../../sources/extensions/StringExtension.php';
|
|
require_once __DIR__ . '/../../sources/extensions/GUIDExtension.php';
|
|
}
|
|
}
|