|
1
|
|
|
<?php |
|
2
|
|
|
|
|
3
|
|
|
namespace Test\Skautis; |
|
4
|
|
|
|
|
5
|
|
|
use Skautis; |
|
6
|
|
|
use Skautis\Wsdl\WebService; |
|
7
|
|
|
use Skautis\Exception as SkautisException; |
|
8
|
|
|
use Skautis\SkautisQuery; |
|
9
|
|
|
use Skautis\Wsdl\WebServiceFactory; |
|
10
|
|
|
|
|
11
|
|
|
class WebServiceTest extends \PHPUnit_Framework_TestCase |
|
12
|
|
|
{ |
|
13
|
|
|
|
|
14
|
|
|
protected $queries = []; |
|
15
|
|
|
|
|
16
|
|
|
/** |
|
17
|
|
|
* @var WebServiceFactory |
|
18
|
|
|
*/ |
|
19
|
|
|
private $wsFactory; |
|
20
|
|
|
|
|
21
|
|
|
protected function setUp() |
|
22
|
|
|
{ |
|
23
|
|
|
$this->wsFactory = new WebServiceFactory(); |
|
24
|
|
|
} |
|
25
|
|
|
|
|
26
|
|
|
|
|
27
|
|
|
public function queryCallback($query) |
|
28
|
|
|
{ |
|
29
|
|
|
$this->queries[] = $query; |
|
30
|
|
|
} |
|
31
|
|
|
|
|
32
|
|
|
public function testCallback() |
|
33
|
|
|
{ |
|
34
|
|
|
$callback = [$this, 'queryCallback']; |
|
35
|
|
|
|
|
36
|
|
|
$data = [ |
|
37
|
|
|
'ID_Application' => 123, |
|
38
|
|
|
Skautis\User::ID_LOGIN => 'xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx', |
|
39
|
|
|
]; |
|
40
|
|
|
|
|
41
|
|
|
|
|
42
|
|
|
$webService = $this->wsFactory->createWebService( |
|
43
|
|
|
'https://test-is.skaut.cz/JunakWebservice/UserManagement.asmx?WSDL', |
|
44
|
|
|
$data |
|
45
|
|
|
); |
|
46
|
|
|
$webService->subscribe(WebService::EVENT_FAILURE, $callback); |
|
47
|
|
|
|
|
48
|
|
|
try { |
|
49
|
|
|
$webService->call('UserDetail'); |
|
50
|
|
|
$this->fail(); |
|
51
|
|
|
} catch (SkautisException $e) { |
|
52
|
|
|
//Vyjimku chceme |
|
53
|
|
|
} |
|
54
|
|
|
|
|
55
|
|
|
$this->assertCount(1, $this->queries); |
|
56
|
|
|
$this->assertInstanceOf(SkautisQuery::class, $this->queries[0]); |
|
57
|
|
|
$this->assertEquals('UserDetail', $this->queries[0]->fname); |
|
58
|
|
|
$this->assertGreaterThan(0, strlen($this->queries[0]->getExceptionString())); |
|
59
|
|
|
$this->assertEquals('SoapFault', $this->queries[0]->getExceptionClass()); |
|
60
|
|
|
$this->assertTrue($this->queries[0]->hasFailed()); |
|
61
|
|
|
} |
|
62
|
|
|
|
|
63
|
|
|
public function testCall() |
|
64
|
|
|
{ |
|
65
|
|
|
$callback = [$this, 'queryCallback']; |
|
66
|
|
|
|
|
67
|
|
|
$data = [ |
|
68
|
|
|
'ID_Application' => 123, |
|
69
|
|
|
Skautis\User::ID_LOGIN => 'xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx', |
|
70
|
|
|
]; |
|
71
|
|
|
$webService = $this->wsFactory->createWebService( |
|
72
|
|
|
'https://test-is.skaut.cz/JunakWebservice/UserManagement.asmx?WSDL', |
|
73
|
|
|
$data |
|
74
|
|
|
); |
|
75
|
|
|
$webService->subscribe(WebService::EVENT_FAILURE, $callback); |
|
76
|
|
|
|
|
77
|
|
|
try { |
|
78
|
|
|
$webService->UserDetail(); |
|
79
|
|
|
$this->fail(); |
|
80
|
|
|
} catch (SkautisException $e) { |
|
81
|
|
|
//Vyjimku chceme |
|
82
|
|
|
} |
|
83
|
|
|
|
|
84
|
|
|
$this->assertCount(1, $this->queries); |
|
85
|
|
|
$this->assertInstanceOf(SkautisQuery::class, $this->queries[0]); |
|
86
|
|
|
$this->assertEquals('UserDetail', $this->queries[0]->fname); |
|
87
|
|
|
$this->assertGreaterThan(0, strlen($this->queries[0]->getExceptionString())); |
|
88
|
|
|
$this->assertEquals('SoapFault', $this->queries[0]->getExceptionClass()); |
|
89
|
|
|
$this->assertTrue($this->queries[0]->hasFailed()); |
|
90
|
|
|
} |
|
91
|
|
|
} |
|
92
|
|
|
|