20250214
+ [TwoDimSize]: Класс, описывающий двумерный размер. + [HashGetType]: Перечисление типов получения хэша. + [FileHash]: Класс для работы с хэшем файла или строки.
This commit is contained in:
42
tests/classes/FileHashTest.php
Normal file
42
tests/classes/FileHashTest.php
Normal file
@@ -0,0 +1,42 @@
|
||||
<?php
|
||||
|
||||
namespace goodboyalex\php_components_pack\tests\classes;
|
||||
|
||||
use goodboyalex\php_components_pack\classes\FileHash;
|
||||
use goodboyalex\php_components_pack\enums\HashGetType;
|
||||
use PHPUnit\Framework\TestCase;
|
||||
|
||||
class FileHashTest extends TestCase
|
||||
{
|
||||
public function test__construct ()
|
||||
{
|
||||
$this->PrepareForTest();
|
||||
|
||||
$fileHash = new FileHash("Тестовое слово");
|
||||
$this->assertEquals("000e22f7ba01ae35f781bc3069038110c46593306cafef6b489f7c83b34629b7", $fileHash->Hash);
|
||||
|
||||
$fileHash = new FileHash(__DIR__ . '/../data/A.php', HashGetType::ByFile);
|
||||
$this->assertEquals("fc8dad93af5de5dd7c7d64e04faadfa22557e577a1538737fe462a5f78699fa2", $fileHash->Hash);
|
||||
|
||||
$fileHash = new FileHash(__DIR__ . '/../data/B.php', HashGetType::ByFile);
|
||||
$this->assertEquals("f419262e46e9461517af46d0c1e4faf25f38990bb50351b691d84f1ad51f2299", $fileHash->Hash);
|
||||
}
|
||||
|
||||
private function PrepareForTest (): void
|
||||
{
|
||||
require_once __DIR__ . '/../../sources/traits/EnumExtensionsTrait.php';
|
||||
require_once __DIR__ . '/../../sources/enums/HashGetType.php';
|
||||
require_once __DIR__ . '/../../sources/extensions/StringExtension.php';
|
||||
require_once __DIR__ . '/../../sources/classes/FileHash.php';
|
||||
}
|
||||
|
||||
public function testIsEqual ()
|
||||
{
|
||||
$this->PrepareForTest();
|
||||
|
||||
$fileHash = new FileHash("Тестовое слово");
|
||||
|
||||
$this->assertTrue($fileHash->IsEqual(new FileHash("Тестовое слово")));
|
||||
$this->assertFalse($fileHash->IsEqual(new FileHash("Тестовое слово2")));
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user