+ [TwoDimSize]: Класс, описывающий двумерный размер. + [HashGetType]: Перечисление типов получения хэша. + [FileHash]: Класс для работы с хэшем файла или строки.
66 lines
1.4 KiB
PHP
66 lines
1.4 KiB
PHP
<?php
|
|
|
|
namespace goodboyalex\php_components_pack\tests\classes;
|
|
|
|
use Exception;
|
|
use goodboyalex\php_components_pack\classes\TwoDimSize;
|
|
use PHPUnit\Framework\TestCase;
|
|
|
|
class TwoDimSizeTest extends TestCase
|
|
{
|
|
public function testParse ()
|
|
{
|
|
$this->PrepareForTest();
|
|
|
|
try {
|
|
$size = TwoDimSize::Parse("10x20", "x");
|
|
}
|
|
catch (Exception $e) {
|
|
$this->fail($e->getMessage());
|
|
}
|
|
|
|
$this->assertEquals(10, $size->Width);
|
|
$this->assertEquals(20, $size->Height);
|
|
|
|
}
|
|
|
|
private function PrepareForTest (): void
|
|
{
|
|
require_once __DIR__ . '/../../sources/interfaces/ISerializable.php';
|
|
require_once __DIR__ . '/../../sources/classes/TwoDimSize.php';
|
|
}
|
|
|
|
public function test__toString ()
|
|
{
|
|
$this->PrepareForTest();
|
|
|
|
$size = new TwoDimSize(10, 20);
|
|
|
|
$this->assertEquals("10:20", $size->__toString());
|
|
}
|
|
|
|
public function testSerialize ()
|
|
{
|
|
$this->PrepareForTest();
|
|
|
|
$size = new TwoDimSize(10, 20);
|
|
|
|
$this->assertEquals("10x20x1", $size->Serialize());
|
|
|
|
}
|
|
|
|
public function testUnSerialize ()
|
|
{
|
|
$this->PrepareForTest();
|
|
|
|
$serialized = "10x20x1";
|
|
|
|
$size = new TwoDimSize();
|
|
|
|
$size->UnSerialize($serialized);
|
|
|
|
$this->assertEquals(10, $size->Width);
|
|
$this->assertEquals(20, $size->Height);
|
|
$this->assertTrue($size->NoNegativeValues);
|
|
}
|
|
} |