1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
|
<?php
require_once('SSRS/Report.php');
class SSRS_ReportTest extends PHPUnit_Framework_TestCase {
public function testPassCredentialsOnConstruct() {
$options = array(
'username' => 'bob',
'password' => 'monkhouse'
);
$ssrs = new SSRS_Report('http://test', $options);
$this->assertEquals($options['username'], $ssrs->getUsername());
$this->assertEquals($options['password'], $ssrs->getPassword());
}
public function testGetSoapServiceReturnsNTLMByDefault() {
$ssrs = new SSRS_Report('http://test');
$soap = $ssrs->getSoapService(false);
$this->assertInstanceOf('SSRS_Soap_NTLM', $soap);
$this->assertEquals('http://test/ReportService2010.asmx', $soap->getUri());
}
public function testGetSoapExecutionReturnsNTLMByDefault() {
$ssrs = new SSRS_Report('http://test');
$soap = $ssrs->getSoapExecution(false);
$this->assertInstanceOf('SSRS_Soap_NTLM', $soap);
$this->assertEquals('http://test/ReportExecution2005.asmx', $soap->getUri());
}
public function testSetSessionId() {
$sessionId = 't1mo0x45seatmr451xegqy55';
$headerStr = sprintf('<ExecutionHeader xmlns="%s"><ExecutionID>%s</ExecutionID></ExecutionHeader>', 'http://schemas.microsoft.com/sqlserver/2005/06/30/reporting/reportingservices', $sessionId);
$soapVar = new SoapVar($headerStr, XSD_ANYXML, null, null, null);
$soapHeader = new SoapHeader('http://schemas.microsoft.com/sqlserver/2005/06/30/reporting/reportingservices', 'ExecutionHeader', $soapVar);
$soapMock = $this->getMockFromWsdl(dirname(__FILE__) . '/ReportTest/ReportExecution2005.wsdl', 'SoapClientMockSession', '', array('__setSoapHeaders'));
$soapMock->expects($this->any())
->method('__setSoapHeaders')
->with($this->equalTo(array($soapHeader)));
$ssrs = new SSRS_Report('http://test/ReportServer');
$ssrs->setSoapExecution($soapMock);
$result = $ssrs->setSessionId($sessionId);
$this->assertEquals($ssrs, $result);
}
public function testLoadChildrenReturnsItemList() {
$soapMock = $this->getMockFromWsdl(dirname(__FILE__) . '/ReportTest/ReportService2010.wsdl', 'SoapClientMockChildren');
$catalogItem1 = new stdClass;
$catalogItem1->ID = '1386fc6d-9c58-489f-adea-081146b62799';
$catalogItem1->Name = 'Report Reference';
$catalogItem1->Path = '/Reports/Report_Reference';
$catalogItem1->TypeName = 'Report';
$catalogItem1->Size = '234413';
$catalogItem1->CreationDate = '2011-03-03T12:32:57.063';
$catalogItem1->ModifiedDate = '2011-03-03T12:51:12.05';
$catalogItem1->CreatedBy = 'MSSQL\WebAccount';
$catalogItem1->ModifiedBy = 'MSSQL\WebAccount';
$return = new stdClass;
$return->CatalogItems = new stdClass;
$return->CatalogItems->CatalogItem = array($catalogItem1);
$soapMock->expects($this->any())
->method('ListChildren')
->with($this->equalTo(array('ItemPath' => '/Reports', 'Recursive' => true)))
->will($this->returnValue($return));
$ssrs = new SSRS_Report('http://test/ReportServer');
$ssrs->setSoapService($soapMock);
$result = $ssrs->listChildren('/Reports', true);
$expected = new SSRS_Object_CatalogItems($return);
$this->assertInstanceOf('SSRS_Object_CatalogItems', $result);
$this->assertEquals($expected, $result);
}
public function testLoadChildrenCheckRecursiveParameterIsSetAndIsBoolean() {
$soapMock = $this->getMockFromWsdl(dirname(__FILE__) . '/ReportTest/ReportService2010.wsdl', 'SoapClientMockChildren2');
$recursiveParam = true;
$soapMock->expects($this->any())
->method('ListChildren')
->with($this->equalTo(array('ItemPath' => '/Reports', 'Recursive' => true)));
$ssrs = new SSRS_Report('http://test/ReportServer');
$ssrs->setSoapService($soapMock);
$result = $ssrs->listChildren('/Reports', $recursiveParam);
}
public function testLoadItemDefinitionsReturnsXMLStringWithInStdClass() {
$soapMock = $this->getMockFromWsdl(dirname(__FILE__) . '/ReportTest/ReportService2010.wsdl', 'SoapClientMockDefinitions');
$soapMock->expects($this->any())
->method('getItemDefinition')
->with($this->equalTo(array('ItemPath' => '/Reports/Managed Account Performance')));
$ssrs = new SSRS_Report('http://test/ReportServer');
$ssrs->setSoapService($soapMock);
$result = $ssrs->getItemDefinition('/Reports/Managed Account Performance');
}
public function testLoadReportReturnsCorrectObject() {
require(dirname(__FILE__) . '/ReportTest/LoadReportObject.php');
$soapMock = $this->getMockFromWsdl(dirname(__FILE__) . '/ReportTest/ReportExecution2005.wsdl', 'SoapClientMockLoadReport');
$soapMock->expects($this->any())
->method('loadReport')
->with($this->equalTo(array('Report' => '/Reports/Reference_Report', 'HistoryID' => null)))
->will($this->returnValue($testReport));
$ssrs = new SSRS_Report('http://test/ReportServer');
$ssrs->setSoapExecution($soapMock);
$expected = new SSRS_Object_Report($testReport);
$result = $ssrs->loadReport('/Reports/Reference_Report');
$this->assertEquals($expected, $result);
}
public function testSetExecutionParametersReturnsCorrectObject() {
require(dirname(__FILE__) . '/ReportTest/SetExecutionParametersObject.php');
$executionID = 'ybv45155dta00245nxlqfi55';
$soapMock = $this->getMockFromWsdl(dirname(__FILE__) . '/ReportTest/ReportExecution2005.wsdl', 'SoapClientMockExecutionParams');
$soapMock->expects($this->any())
->method('SetExecutionParameters')
->with($this->equalTo(array('Parameters' => $parameters->getParameterArrayForSoapCall(), 'ParameterLanguage' => 'en-us')))
->will($this->returnValue($returnExecParams));
$ssrs = new SSRS_Report('http://test/ReportServer');
$ssrs->setSoapExecution($soapMock)
->setSessionId($executionID);
$expected = new SSRS_Object_ExecutionInfo($returnExecParams);
$result = $ssrs->setExecutionParameters($parameters);
$this->assertInstanceOf('SSRS_Object_ExecutionInfo', $result);
$this->assertEquals($expected, $result);
}
public function testRenderOutputsReport() {
$executionID = 'ybv45155dta00245nxlqfi55';
$soapMock = $this->getMockFromWsdl(dirname(__FILE__) . '/ReportTest/ReportExecution2005.wsdl', 'SoapClientMockRender');
$soapMock->expects($this->any())->method('Render2')
->with($this->equalTo(array(
'Format' => 'HTML4.0',
'DeviceInfo' => '<DeviceInfo><Toolbar>false</Toolbar></DeviceInfo>',
'PaginationMode' => 'Estimate'
)));
$ssrs = new SSRS_Report('http://test/ReportServer');
$ssrs->setSoapExecution($soapMock)
->setSessionId($executionID);
$result = $ssrs->render('HTML4.0');
}
public function testRenderConvertsDeviceInfo() {
$soapMock = $this->getMockFromWsdl(dirname(__FILE__) . '/ReportTest/ReportExecution2005.wsdl', 'SoapClientMockRender2');
$soapMock->expects($this->any())->method('Render2')
->with($this->equalTo(array(
'Format' => 'CSV',
'DeviceInfo' => '<DeviceInfo><Toolbar>true</Toolbar><Recurse><Test>works</Test></Recurse></DeviceInfo>',
'PaginationMode' => 'Another'
)));
$ssrs = new SSRS_Report('http://test/ReportServer');
$ssrs->setSoapExecution($soapMock)
->setSessionId('test');
$result = $ssrs->render('CSV', array('Toolbar' => true, 'Recurse' => array('Test' => 'works')), 'Another');
}
}
|