This commit is contained in:
		@@ -1,23 +1,65 @@
 | 
			
		||||
<?php declare(strict_types=1);
 | 
			
		||||
 | 
			
		||||
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 \App\Rclone\Rclone('invalid');
 | 
			
		||||
        $this->assertString('', $rclone->getVersion());
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    public function testRcloneInvalidVersion(): void
 | 
			
		||||
    {
 | 
			
		||||
        $this->expectException(\Exception::class);
 | 
			
		||||
        $rclone = new \App\Rclone\Rclone('uname');
 | 
			
		||||
        $this->assertString('', $rclone->getVersion());
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    public function testRcloneValidVersion(): void
 | 
			
		||||
    {
 | 
			
		||||
        $rclone = new \App\Rclone\Rclone('./tests/mock-rclone');
 | 
			
		||||
        $rclone = new \App\Rclone\Rclone();
 | 
			
		||||
        $this->assertStringContainsString('rclone', $rclone->getVersion());
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    public function testRcloneSize(): void
 | 
			
		||||
    {
 | 
			
		||||
        $rclone = new \App\Rclone\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 \App\Rclone\Rclone();
 | 
			
		||||
        $result = $rclone->copy('temp/source','temp/destination');
 | 
			
		||||
        $this->assertDirectoryExists('temp/destination');
 | 
			
		||||
 | 
			
		||||
        $rclone = new \App\Rclone\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');
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
		Reference in New Issue
	
	Block a user