summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorArron Woods <aw@chartblocks.com>2015-03-02 16:55:55 +0000
committerArron Woods <aw@chartblocks.com>2015-03-02 16:55:55 +0000
commite267d21427aee0ab39169933dfbf0b7fbbe5bc4f (patch)
tree39ab2270729635647424a48e47353bf850f1b73d
parent8f5607a53e06c6d9567800dfe7e3cb94511634df (diff)
downloadphp-ssrs-e267d21427aee0ab39169933dfbf0b7fbbe5bc4f.zip
php-ssrs-e267d21427aee0ab39169933dfbf0b7fbbe5bc4f.tar.gz
php-ssrs-e267d21427aee0ab39169933dfbf0b7fbbe5bc4f.tar.bz2
Pass cache_wsdl_path down to client construct1.0.5
-rwxr-xr-xlibrary/SSRS/Report.php45
-rwxr-xr-xlibrary/SSRS/Soap/NTLM.php8
-rwxr-xr-xtests/library/SSRSTest/ReportTest.php18
3 files changed, 51 insertions, 20 deletions
diff --git a/library/SSRS/Report.php b/library/SSRS/Report.php
index 6aff53b..521a5e8 100755
--- a/library/SSRS/Report.php
+++ b/library/SSRS/Report.php
@@ -30,6 +30,7 @@ class Report {
public $servicePath = 'ReportService2010.asmx';
public $executionPath = 'ReportExecution2005.asmx';
+ public $options;
protected $_baseUri;
protected $_username;
protected $_passwd;
@@ -44,16 +45,28 @@ class Report {
* @param string $baseUri
* @param array $options
*/
- public function __construct($baseUri, $options = array()) {
+ public function __construct($baseUri, array $options = array()) {
$this->setBaseUri($baseUri);
if (array_key_exists('username', $options)) {
$this->setUsername($options['username']);
+ unset($options['username']);
}
if (array_key_exists('password', $options)) {
$this->setPassword($options['password']);
+ unset($options['password']);
}
+
+ $this->setOptions($options);
+ }
+
+ public function setOptions(array $options) {
+ $defaults = array(
+ 'cache_wsdl_path' => null
+ );
+
+ $this->options = array_merge($defaults, $options);
}
public function setBaseUri($uri) {
@@ -94,12 +107,7 @@ class Report {
*/
public function getSoapExecution($runInit = true) {
if ($this->_soapExecution === null) {
- $options = array('username' => $this->_username, 'password' => $this->_passwd);
- $client = new SoapNTLM($this->_baseUri . '/' . $this->executionPath, $options);
- if ($runInit) {
- $client->init();
- }
-
+ $client = $this->createNTLMClient($this->executionPath, $runInit);
$this->setSoapExecution($client);
}
@@ -114,12 +122,7 @@ class Report {
*/
public function getSoapService($runInit = true) {
if ($this->_soapService === null) {
- $options = array('username' => $this->_username, 'password' => $this->_passwd);
- $client = new SoapNTLM($this->_baseUri . '/' . $this->servicePath, $options);
- if ($runInit) {
- $client->init();
- }
-
+ $client = $this->createNTLMClient($this->servicePath, $runInit);
$this->setSoapService($client);
}
@@ -435,4 +438,20 @@ class Report {
return $xml;
}
+ protected function createNTLMClient($path, $runInit) {
+ $options = array(
+ 'username' => $this->_username,
+ 'password' => $this->_passwd,
+ 'cache_wsdl_path' => $this->options['cache_wsdl_path']
+ );
+
+ $client = new SoapNTLM($this->_baseUri . '/' . $path, $options);
+
+ if ($runInit) {
+ $client->init();
+ }
+
+ return $client;
+ }
+
}
diff --git a/library/SSRS/Soap/NTLM.php b/library/SSRS/Soap/NTLM.php
index 7f75db7..077c71e 100755
--- a/library/SSRS/Soap/NTLM.php
+++ b/library/SSRS/Soap/NTLM.php
@@ -13,7 +13,7 @@ class NTLM extends \SoapClient {
protected $_lastResponse;
function __construct($wsdl, $options = array()) {
- if (!array_key_exists('cache_wsdl_path', $options)) {
+ if (empty($options['cache_wsdl_path'])) {
$options['cache_wsdl_path'] = '/tmp/' . md5($wsdl) . '.wsdl';
}
@@ -114,9 +114,9 @@ class NTLM extends \SoapClient {
}
}
- public function __doRequest($data, $url, $action) {
- $this->_lastRequest = (string) $data;
- $this->_lastResponse = $this->callCurl($url, $data, $action);
+ public function __doRequest($request, $location, $action, $version = 1, $one_way = null) {
+ $this->_lastRequest = (string) $request;
+ $this->_lastResponse = $this->callCurl($location, $request, $action);
return $this->_lastResponse;
}
diff --git a/tests/library/SSRSTest/ReportTest.php b/tests/library/SSRSTest/ReportTest.php
index 4c79897..9071742 100755
--- a/tests/library/SSRSTest/ReportTest.php
+++ b/tests/library/SSRSTest/ReportTest.php
@@ -20,6 +20,19 @@ class ReportTest extends \PHPUnit_Framework_TestCase {
$this->assertEquals($options['username'], $ssrs->getUsername());
$this->assertEquals($options['password'], $ssrs->getPassword());
+ $this->assertArrayNotHasKey('password', $ssrs->options, 'Password should not remain in options');
+ }
+
+ public function testSetOptions() {
+ $options = array(
+ 'cache_wsdl_path' => '/opt/test',
+ );
+
+ $ssrs = new Report('http://test', $options);
+ $this->assertEquals('/opt/test', $ssrs->options['cache_wsdl_path']);
+
+ $ssrs->setOptions(array());
+ $this->assertEquals(null, $ssrs->options['cache_wsdl_path']);
}
public function testGetSoapServiceReturnsNTLMByDefault() {
@@ -143,7 +156,7 @@ class ReportTest extends \PHPUnit_Framework_TestCase {
'Format' => 'HTML4.0',
'DeviceInfo' => '<DeviceInfo></DeviceInfo>',
'PaginationMode' => 'Estimate'
- )));
+ )));
$ssrs = new Report('http://test/ReportServer');
$ssrs->setSoapExecution($soapMock)
@@ -159,7 +172,7 @@ class ReportTest extends \PHPUnit_Framework_TestCase {
'Format' => 'CSV',
'DeviceInfo' => '<DeviceInfo><Toolbar>true</Toolbar><Recurse><Test>works</Test></Recurse></DeviceInfo>',
'PaginationMode' => 'Another'
- )));
+ )));
$ssrs = new Report('http://test/ReportServer');
$ssrs->setSoapExecution($soapMock)
@@ -168,5 +181,4 @@ class ReportTest extends \PHPUnit_Framework_TestCase {
$result = $ssrs->render('CSV', array('Toolbar' => true, 'Recurse' => array('Test' => 'works')), 'Another');
}
-
}