|
1
|
|
|
<?php |
|
2
|
|
|
|
|
3
|
|
|
namespace BasicTests; |
|
4
|
|
|
|
|
5
|
|
|
|
|
6
|
|
|
use CommonTestClass; |
|
7
|
|
|
use kalanis\RemoteRequest\Connection; |
|
8
|
|
|
use kalanis\RemoteRequest\Interfaces; |
|
9
|
|
|
use kalanis\RemoteRequest\Protocols; |
|
10
|
|
|
use kalanis\RemoteRequest\RequestException; |
|
11
|
|
|
use kalanis\RemoteRequest\Sockets; |
|
12
|
|
|
use kalanis\RemoteRequest\Translations; |
|
13
|
|
|
|
|
14
|
|
|
|
|
15
|
|
|
class EmptyTestSocket extends Sockets\ASocket |
|
16
|
|
|
{ |
|
17
|
|
|
protected function remotePointer(Interfaces\IConnectionParams $schema) |
|
18
|
|
|
{ |
|
19
|
|
|
return null; |
|
20
|
|
|
} |
|
21
|
|
|
} |
|
22
|
|
|
|
|
23
|
|
|
|
|
24
|
|
|
class ExceptionTestSocket extends Sockets\ASocket |
|
25
|
|
|
{ |
|
26
|
|
|
protected function remotePointer(Interfaces\IConnectionParams $schema) |
|
27
|
|
|
{ |
|
28
|
|
|
throw new RequestException($this->lang->rrSocketCannotConnect()); |
|
29
|
|
|
} |
|
30
|
|
|
} |
|
31
|
|
|
|
|
32
|
|
|
|
|
33
|
|
|
class PointersTest extends CommonTestClass |
|
34
|
|
|
{ |
|
35
|
|
|
/** |
|
36
|
|
|
* When it blows |
|
37
|
|
|
* @throws RequestException |
|
38
|
|
|
*/ |
|
39
|
|
|
public function testCallException(): void |
|
40
|
|
|
{ |
|
41
|
|
|
$lang = new Translations(); |
|
42
|
|
|
$processor = new Connection\Processor($lang, new ExceptionTestSocket($lang)); |
|
43
|
|
|
$processor->setConnectionParams(new Connection\Params\File()); |
|
44
|
|
|
$processor->setData(new Protocols\Dummy\Query()); |
|
45
|
|
|
$this->expectException(RequestException::class); |
|
46
|
|
|
$processor->process(); // die |
|
47
|
|
|
} |
|
48
|
|
|
|
|
49
|
|
|
/** |
|
50
|
|
|
* When it blows |
|
51
|
|
|
* @throws RequestException |
|
52
|
|
|
*/ |
|
53
|
|
|
public function testCallNoPointer(): void |
|
54
|
|
|
{ |
|
55
|
|
|
$lang = new Translations(); |
|
56
|
|
|
$processor = new Connection\Processor($lang, new EmptyTestSocket($lang)); |
|
57
|
|
|
$processor->setConnectionParams(new Connection\Params\File()); |
|
58
|
|
|
$processor->setData(new Protocols\Dummy\Query()); |
|
59
|
|
|
$this->expectException(RequestException::class); |
|
60
|
|
|
$processor->process(); // die |
|
61
|
|
|
} |
|
62
|
|
|
} |
|
63
|
|
|
|