FlySftpTest   A
last analyzed

Complexity

Total Complexity 7

Size/Duplication

Total Lines 50
Duplicated Lines 0 %

Importance

Changes 0
Metric Value
wmc 7
eloc 20
dl 0
loc 50
rs 10
c 0
b 0
f 0

5 Methods

Rating   Name   Duplication   Size   Complexity  
A testGetProvider() 0 6 1
A setUp() 0 8 3
A testGetProviderNoRoot() 0 7 1
A testGetProviderNoUser() 0 7 1
A testGetProviderNoHost() 0 7 1
1
<?php
2
3
namespace Aimeos\Base\Filesystem;
4
5
6
class FlySftpTest extends \PHPUnit\Framework\TestCase
7
{
8
	protected function setUp() : void
9
	{
10
		if( !class_exists( '\\League\\Flysystem\\Filesystem' ) ) {
11
			$this->markTestSkipped( 'Install Flysystem first' );
12
		}
13
14
		if( !class_exists( 'League\Flysystem\PhpseclibV2\SftpAdapter' ) ) {
15
			$this->markTestSkipped( 'Install Flysystem SFTP adapter' );
16
		}
17
	}
18
19
20
	public function testGetProvider()
21
	{
22
		$object = new FlySftp( ['host' => 'test.rebex.net', 'username' => 'demo', 'password' => 'password', 'root' => ''] );
23
		$this->assertInstanceof( \Aimeos\Base\Filesystem\Iface::class, $object );
24
25
		$object->has( 'test' );
26
	}
27
28
29
	public function testGetProviderNoHost()
30
	{
31
		$object = new FlySftp( [] );
32
		$this->assertInstanceof( \Aimeos\Base\Filesystem\Iface::class, $object );
33
34
		$this->expectException( \Aimeos\Base\Filesystem\Exception::class );
35
		$object->has( 'test' );
36
	}
37
38
39
	public function testGetProviderNoUser()
40
	{
41
		$object = new FlySftp( ['host' => 'test.rebex.net'] );
42
		$this->assertInstanceof( \Aimeos\Base\Filesystem\Iface::class, $object );
43
44
		$this->expectException( \Aimeos\Base\Filesystem\Exception::class );
45
		$object->has( 'test' );
46
	}
47
48
49
	public function testGetProviderNoRoot()
50
	{
51
		$object = new FlySftp( ['host' => 'test.rebex.net', 'username' => 'demo', 'password' => 'password'] );
52
		$this->assertInstanceof( \Aimeos\Base\Filesystem\Iface::class, $object );
53
54
		$this->expectException( \Aimeos\Base\Filesystem\Exception::class );
55
		$object->has( 'test' );
56
	}
57
}
58