Added ID manager
This commit is contained in:
parent
5885fbf492
commit
03713164fa
2 changed files with 42 additions and 1 deletions
|
@ -1,4 +1,4 @@
|
|||
<?php
|
||||
<?php declare(strict_types=1);
|
||||
|
||||
|
||||
use MMK2410\MyTodoList\IdManager;
|
||||
|
@ -6,5 +6,27 @@ use PHPUnit\Framework\TestCase;
|
|||
|
||||
class IdManagerTest extends TestCase
|
||||
{
|
||||
public function testGenerateTwoIds(): void
|
||||
{
|
||||
$id1 = IdManager::generateID(IdManagerTest::class . "::testGenerateTwoIds");
|
||||
$id2 = IdManager::generateID(IdManagerTest::class . "::testGenerateTwoIds");
|
||||
self::assertNotEquals(
|
||||
$id1,
|
||||
$id2,
|
||||
"ID 1 '$id1' and ID 2 '$id2' are equal, but the shouldn't."
|
||||
);
|
||||
}
|
||||
|
||||
public function testGetCurrentId(): void
|
||||
{
|
||||
for ($i = 0; $i < 3; $i++) {
|
||||
IdManager::generateID(IdManagerTest::class . "::testGetCurrentId()");
|
||||
}
|
||||
$currentId = IdManager::getCurrentId(IdManagerTest::class . "::testGetCurrentId()");
|
||||
self::assertEquals(
|
||||
2,
|
||||
$currentId,
|
||||
"Expected current ID to be '2', but got '$currentId'"
|
||||
);
|
||||
}
|
||||
}
|
||||
|
|
Reference in a new issue