mirror of
https://github.com/RSS-Bridge/rss-bridge.git
synced 2024-11-23 18:15:28 +03:00
57d5aa45f7
* fix: php notice in eztvbridge Fixes Undefined property: stdClass::$torrents * lint
43 lines
1.2 KiB
PHP
43 lines
1.2 KiB
PHP
<?php
|
|
|
|
declare(strict_types=1);
|
|
|
|
namespace RssBridge\Tests;
|
|
|
|
use PHPUnit\Framework\TestCase;
|
|
|
|
final class UtilsTest extends TestCase
|
|
{
|
|
public function testTruncate()
|
|
{
|
|
$this->assertSame('f...', truncate('foo', 1));
|
|
$this->assertSame('fo...', truncate('foo', 2));
|
|
$this->assertSame('foo', truncate('foo', 3));
|
|
$this->assertSame('foo', truncate('foo', 4));
|
|
$this->assertSame('fo[...]', truncate('foo', 2, '[...]'));
|
|
}
|
|
|
|
public function testFormatBytes()
|
|
{
|
|
$this->assertSame('1 B', format_bytes(1));
|
|
$this->assertSame('1 KB', format_bytes(1024));
|
|
$this->assertSame('1 MB', format_bytes(1024 ** 2));
|
|
$this->assertSame('1 GB', format_bytes(1024 ** 3));
|
|
$this->assertSame('1 TB', format_bytes(1024 ** 4));
|
|
}
|
|
|
|
public function testFileCache()
|
|
{
|
|
$sut = new \FileCache();
|
|
$sut->setScope('scope');
|
|
$sut->purgeCache(-1);
|
|
$sut->setKey(['key']);
|
|
|
|
$this->assertNull($sut->loadData());
|
|
|
|
$sut->saveData('data');
|
|
$this->assertSame('data', $sut->loadData());
|
|
$this->assertIsNumeric($sut->getTime());
|
|
$sut->purgeCache(-1);
|
|
}
|
|
}
|