66 lines
1.9 KiB
PHP
66 lines
1.9 KiB
PHP
<?php declare(strict_types=1);
|
|
|
|
use App\Rclone\Rclone;
|
|
use PHPUnit\Framework\TestCase;
|
|
|
|
final class RcloneTest extends TestCase
|
|
{
|
|
protected function setUp(): void
|
|
{
|
|
shell_exec('rclone test makefiles temp/source 2>&1');
|
|
}
|
|
|
|
protected function tearDown(): void
|
|
{
|
|
exec('rclone purge temp 2>&1', $output);
|
|
}
|
|
|
|
|
|
public function testRclonePath(): void
|
|
{
|
|
$this->expectException(\Exception::class);
|
|
$rclone = new Rclone('invalid');
|
|
$this->assertString('', $rclone->getVersion());
|
|
}
|
|
|
|
public function testRcloneInvalidVersion(): void
|
|
{
|
|
$this->expectException(\Exception::class);
|
|
$rclone = new Rclone('uname');
|
|
$this->assertString('', $rclone->getVersion());
|
|
}
|
|
|
|
public function testRcloneValidVersion(): void
|
|
{
|
|
$rclone = new Rclone();
|
|
$this->assertStringContainsString('rclone', $rclone->getVersion());
|
|
}
|
|
|
|
public function testRcloneSize(): void
|
|
{
|
|
$rclone = new Rclone();
|
|
$size = $rclone->getSize('temp/source');
|
|
$this->assertGreaterThan(10000, $size);
|
|
|
|
$this->expectException(\Exception::class);
|
|
$this->expectExceptionMessage("ERROR");
|
|
$size = $rclone->getSize('temp/bogus-source');
|
|
$this->assertEquals(0, $size);
|
|
}
|
|
|
|
public function testRcloneCopy(): void
|
|
{
|
|
$rclone = new Rclone();
|
|
$result = $rclone->copy('temp/source','temp/destination');
|
|
$this->assertDirectoryExists('temp/destination');
|
|
|
|
$rclone = new Rclone();
|
|
$result = $rclone->copy('temp/source','temp/destination',['bwlimit'=>'6M']);
|
|
$this->assertDirectoryExists('temp/destination');
|
|
|
|
$this->expectException(\Exception::class);
|
|
$this->expectExceptionMessage("ERROR");
|
|
$result = $rclone->copy('temp/bogus-source','temp/bogus-destination');
|
|
$this->assertDirectoryDoesNotExist('temp/bogus-destination');
|
|
}
|
|
} |