1
|
|
|
<?php |
2
|
|
|
/** |
3
|
|
|
* This file is part of the Gerrie package. |
4
|
|
|
* |
5
|
|
|
* (c) Andreas Grunwald <[email protected]> |
6
|
|
|
* |
7
|
|
|
* For the full copyright and license information, please view the LICENSE |
8
|
|
|
* file that was distributed with this source code. |
9
|
|
|
*/ |
10
|
|
|
|
11
|
|
|
namespace Gerrie\Tests\Component\DataService; |
12
|
|
|
|
13
|
|
|
use Gerrie\API\DataService\DataServiceFactory; |
14
|
|
|
|
15
|
|
|
class DataServiceFactoryTest extends \PHPUnit_Framework_TestCase |
16
|
|
|
{ |
17
|
|
|
|
18
|
|
|
public function invalidInstancePathDataProvider() |
19
|
|
|
{ |
20
|
|
|
$data = [ |
21
|
|
|
array(['Instance' => null]), |
22
|
|
|
array(['Instance' => '']), |
23
|
|
|
array(['Instance' => '/foo/bar']), |
24
|
|
|
array(['Instance' => 'www.google.de/path/x']) |
25
|
|
|
]; |
26
|
|
|
|
27
|
|
|
return $data; |
28
|
|
|
} |
29
|
|
|
|
30
|
|
|
public function invalidDataServiceSchemeDataProvider() |
31
|
|
|
{ |
32
|
|
|
$data = [ |
33
|
|
|
array(['Instance' => 'google://my.website/']), |
34
|
|
|
array(['Instance' => 'ftp://192.168.1.1/']), |
35
|
|
|
array(['Instance' => 'sftp://ccc.de/']) |
36
|
|
|
]; |
37
|
|
|
|
38
|
|
|
return $data; |
39
|
|
|
} |
40
|
|
|
|
41
|
|
|
/** |
42
|
|
|
* @dataProvider invalidInstancePathDataProvider |
43
|
|
|
* @expectedException \RuntimeException |
44
|
|
|
* @expectedExceptionCode 1415453791 |
45
|
|
|
*/ |
46
|
|
|
public function testGetDataServiceWithInvalidInstancePath($instanceConfig) |
47
|
|
|
{ |
48
|
|
|
DataServiceFactory::getDataService($instanceConfig); |
49
|
|
|
} |
50
|
|
|
|
51
|
|
|
/** |
52
|
|
|
* @dataProvider invalidDataServiceSchemeDataProvider |
53
|
|
|
* @expectedException \RuntimeException |
54
|
|
|
* @expectedExceptionCode 1364130057 |
55
|
|
|
*/ |
56
|
|
|
public function testGetDataServiceWithInvalidDataServiceScheme($instanceConfig) |
57
|
|
|
{ |
58
|
|
|
DataServiceFactory::getDataService($instanceConfig); |
59
|
|
|
} |
60
|
|
|
|
61
|
|
|
public function testGetSSHDataService() |
62
|
|
|
{ |
63
|
|
|
$instanceConfig = [ |
64
|
|
|
'Instance' => 'ssh://[email protected]:29418/', |
65
|
|
|
'KeyFile' => '', |
66
|
|
|
]; |
67
|
|
|
$sshDataService = DataServiceFactory::getDataService($instanceConfig); |
68
|
|
|
|
69
|
|
|
$this->assertInstanceOf('Gerrie\API\DataService\SSHDataService', $sshDataService); |
70
|
|
|
} |
71
|
|
|
|
72
|
|
|
public function testGetHTTPDataService() |
73
|
|
|
{ |
74
|
|
|
$instanceConfig = [ |
75
|
|
|
'Instance' => 'http://andy.grunwald:[email protected]:80/' |
76
|
|
|
]; |
77
|
|
|
$httpDataService = DataServiceFactory::getDataService($instanceConfig); |
78
|
|
|
|
79
|
|
|
$this->assertInstanceOf('Gerrie\API\DataService\HTTPDataService', $httpDataService); |
80
|
|
|
} |
81
|
|
|
|
82
|
|
|
public function testGetHTTPSDataService() |
83
|
|
|
{ |
84
|
|
|
$instanceConfig = [ |
85
|
|
|
'Instance' => 'https://andy.grunwald:[email protected]:80/' |
86
|
|
|
]; |
87
|
|
|
$httpDataService = DataServiceFactory::getDataService($instanceConfig); |
88
|
|
|
|
89
|
|
|
$this->assertInstanceOf('Gerrie\API\DataService\HTTPDataService', $httpDataService); |
90
|
|
|
} |
91
|
|
|
} |