php_components_pack/tests/classes/FileHashTest.php
babaev-an b6f9698e59 20250214
+ [TwoDimSize]: Класс, описывающий двумерный размер.

+ [HashGetType]: Перечисление типов получения хэша.

+ [FileHash]: Класс для работы с хэшем файла или строки.
2025-02-14 16:41:50 +03:00

42 lines
1.6 KiB
PHP
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

<?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")));
}
}