|
1
|
|
|
<?php |
|
2
|
|
|
|
|
3
|
|
|
namespace ProtocolsTests; |
|
4
|
|
|
|
|
5
|
|
|
|
|
6
|
|
|
use CommonTestClass; |
|
7
|
|
|
use kalanis\RemoteRequest\Interfaces; |
|
8
|
|
|
use kalanis\RemoteRequest\Protocols; |
|
9
|
|
|
use kalanis\RemoteRequest\RequestException; |
|
10
|
|
|
use kalanis\RemoteRequest\Translations; |
|
11
|
|
|
|
|
12
|
|
|
|
|
13
|
|
|
class LoadersTest extends CommonTestClass |
|
14
|
|
|
{ |
|
15
|
|
|
/** |
|
16
|
|
|
* @throws RequestException |
|
17
|
|
|
*/ |
|
18
|
|
|
public function testInit(): void |
|
19
|
|
|
{ |
|
20
|
|
|
$lang = new Translations(); |
|
21
|
|
|
$this->assertInstanceOf('\kalanis\RemoteRequest\Protocols\Tcp', Protocols\Factory::getProtocol($lang, Interfaces\ISchema::SCHEMA_TCP)); |
|
22
|
|
|
$this->assertInstanceOf('\kalanis\RemoteRequest\Protocols\Tcp', Protocols\Factory::getProtocol($lang, Interfaces\ISchema::SCHEMA_FILE)); |
|
23
|
|
|
$this->assertInstanceOf('\kalanis\RemoteRequest\Protocols\Udp', Protocols\Factory::getProtocol($lang, Interfaces\ISchema::SCHEMA_UDP)); |
|
24
|
|
|
$this->assertInstanceOf('\kalanis\RemoteRequest\Protocols\Http', Protocols\Factory::getProtocol($lang, 'http')); |
|
25
|
|
|
$this->assertInstanceOf('\kalanis\RemoteRequest\Protocols\Http', Protocols\Factory::getProtocol($lang, 'https')); |
|
26
|
|
|
$this->assertInstanceOf('\kalanis\RemoteRequest\Protocols\Fsp', Protocols\Factory::getProtocol($lang, 'fsp')); |
|
27
|
|
|
// $this->assertInstanceOf('\kalanis\RemoteRequest\Protocols\Http2', Protocols\Factory::getProtocol($lang, 'http2')); |
|
28
|
|
|
// $this->assertInstanceOf('\kalanis\RemoteRequest\Protocols\Http3', Protocols\Factory::getProtocol($lang, 'http3')); |
|
29
|
|
|
$this->assertInstanceOf('\kalanis\RemoteRequest\Protocols\WebDAV', Protocols\Factory::getProtocol($lang, 'webdav')); |
|
30
|
|
|
// $this->assertInstanceOf('\kalanis\RemoteRequest\Protocols\Samba', Protocols\Factory::getProtocol($lang, 'smb')); |
|
31
|
|
|
// $this->assertInstanceOf('\kalanis\RemoteRequest\Protocols\Git', Protocols\Factory::getProtocol($lang, 'git')); |
|
32
|
|
|
} |
|
33
|
|
|
|
|
34
|
|
|
/** |
|
35
|
|
|
* @throws RequestException |
|
36
|
|
|
*/ |
|
37
|
|
|
public function testFail(): void |
|
38
|
|
|
{ |
|
39
|
|
|
$this->expectException(RequestException::class); |
|
40
|
|
|
Protocols\Factory::getProtocol(new Translations(), 'unknown'); |
|
41
|
|
|
} |
|
42
|
|
|
|
|
43
|
|
|
public function testTcp(): void |
|
44
|
|
|
{ |
|
45
|
|
|
$protocol = new Protocols\Tcp(new Translations()); |
|
46
|
|
|
$this->assertInstanceOf('\kalanis\RemoteRequest\Connection\Params\Tcp', $protocol->getParams()); |
|
47
|
|
|
$this->assertInstanceOf('\kalanis\RemoteRequest\Protocols\Dummy\Query', $protocol->getQuery()); |
|
48
|
|
|
} |
|
49
|
|
|
|
|
50
|
|
|
public function testUdp(): void |
|
51
|
|
|
{ |
|
52
|
|
|
$protocol = new Protocols\Udp(new Translations()); |
|
53
|
|
|
$this->assertInstanceOf('\kalanis\RemoteRequest\Connection\Params\Udp', $protocol->getParams()); |
|
54
|
|
|
$this->assertInstanceOf('\kalanis\RemoteRequest\Protocols\Dummy\Query', $protocol->getQuery()); |
|
55
|
|
|
} |
|
56
|
|
|
|
|
57
|
|
|
public function testHttp(): void |
|
58
|
|
|
{ |
|
59
|
|
|
$protocol = new Protocols\Http(new Translations()); |
|
60
|
|
|
$this->assertInstanceOf('\kalanis\RemoteRequest\Connection\Params\Tcp', $protocol->getParams()); |
|
61
|
|
|
$this->assertInstanceOf('\kalanis\RemoteRequest\Protocols\Http\Query', $protocol->getQuery()); |
|
62
|
|
|
} |
|
63
|
|
|
|
|
64
|
|
|
public function testHttps(): void |
|
65
|
|
|
{ |
|
66
|
|
|
$protocol = new Protocols\Https(new Translations()); |
|
67
|
|
|
$this->assertInstanceOf('\kalanis\RemoteRequest\Connection\Params\Ssl', $protocol->getParams()); |
|
68
|
|
|
$this->assertInstanceOf('\kalanis\RemoteRequest\Protocols\Http\Query', $protocol->getQuery()); |
|
69
|
|
|
} |
|
70
|
|
|
|
|
71
|
|
|
public function testRestful(): void |
|
72
|
|
|
{ |
|
73
|
|
|
$protocol = new Protocols\Restful(new Translations()); |
|
74
|
|
|
$this->assertInstanceOf('\kalanis\RemoteRequest\Connection\Params\Tcp', $protocol->getParams()); |
|
75
|
|
|
$this->assertInstanceOf('\kalanis\RemoteRequest\Protocols\Restful\Query', $protocol->getQuery()); |
|
76
|
|
|
} |
|
77
|
|
|
|
|
78
|
|
|
public function testWebDav(): void |
|
79
|
|
|
{ |
|
80
|
|
|
$protocol = new Protocols\WebDAV(new Translations()); |
|
81
|
|
|
$this->assertInstanceOf('\kalanis\RemoteRequest\Connection\Params\Tcp', $protocol->getParams()); |
|
82
|
|
|
$this->assertInstanceOf('\kalanis\RemoteRequest\Protocols\WebDAV\Query', $protocol->getQuery()); |
|
83
|
|
|
} |
|
84
|
|
|
|
|
85
|
|
|
public function testFsp(): void |
|
86
|
|
|
{ |
|
87
|
|
|
$protocol = new Protocols\Fsp(new Translations()); |
|
88
|
|
|
$this->assertInstanceOf('\kalanis\RemoteRequest\Connection\Params\Udp', $protocol->getParams()); |
|
89
|
|
|
$this->assertInstanceOf('\kalanis\RemoteRequest\Protocols\Fsp\Query', $protocol->getQuery()); |
|
90
|
|
|
} |
|
91
|
|
|
} |
|
92
|
|
|
|