Skip to content
Snippets Groups Projects
Commit 57f037c0 authored by Andy Summers's avatar Andy Summers
Browse files

Merge branch 'multi-cbs' into 'master'

Define contract for creating SOAP clients with WSDLs

See merge request !64
parents 4bc3d120 49398c86
No related branches found
No related tags found
1 merge request!64Define contract for creating SOAP clients with WSDLs
Showing
with 157 additions and 26 deletions
{
"name": "adi-ia/cbs-techstore-client-php",
"description": "A PHP client used to connect with the CBS API and perform requests",
"version": "5.0.4",
"version": "6.0.0",
"license": "Apache-2.0",
"homepage": "https://wiki.doit.wisc.edu/confluence/display/ADIIA/CBS",
"authors": [
......
......@@ -13,7 +13,8 @@ interface SoapService extends Service
*
* @param string $username username
* @param string $password password
* @param string|null $wsdlPath path to WSDL for specifying CBS environment. Defaults to QA
* @param \SoapClient|null $soapClient Overriding SOAP client (for testing purposes)
*/
public function __construct($username, $password, \SoapClient $soapClient = null);
public function __construct($username, $password, $wsdlPath = null, \SoapClient $soapClient = null);
}
......@@ -14,17 +14,28 @@ use edu\wisc\services\cbs\order\OrderServiceResponse;
class SoapOrderHeaderService implements OrderHeaderService, SoapService
{
/** URL for QA WSDL */
const CBQA12 = 'http://pegasus.doit.wisc.edu:8018/webservices/SOAProvider/plsql/doit_soa_order_iface_h_v2/?wsdl';
/** URL for DV WSDL */
const CBDV12 = 'http://pegasus.doit.wisc.edu:8016/webservices/SOAProvider/plsql/doit_soa_order_iface_h_v2/?wsdl';
/** @var DOIT_SOA_ORDER_IFACE_H_V2_Service */
private $soapClient;
/**
* {@inheritdoc}
*/
public function __construct($username, $password, \SoapClient $headerSoapClient = null)
public function __construct($username, $password, $wsdlPath = null, \SoapClient $headerSoapClient = null)
{
if ($headerSoapClient !== null) {
$this->soapClient = $headerSoapClient;
return;
} else if ($wsdlPath !== null) {
$this->soapClient = new DOIT_SOA_ORDER_IFACE_H_V2_Service(
[],
$wsdlPath
);
$this->soapClient->__setSoapHeaders(WssSoapHeaderBuilder::buildUsernameToken($username, $password));
} else {
$this->soapClient = new DOIT_SOA_ORDER_IFACE_H_V2_Service(
[],
......
......@@ -13,20 +13,32 @@ use edu\wisc\services\cbs\order\OrderServiceResponse;
class SoapOrderInterfacingService implements OrderInterfacingService, SoapService
{
/** URL for QA WSDL */
const CBQA12 = 'http://pegasus.doit.wisc.edu:8018/webservices/SOAProvider/plsql/doit_soa_order_iface_i_v2/?wsdl';
/** URL for DV WSDL */
const CBDV12 = 'http://pegasus.doit.wisc.edu:8016/webservices/SOAProvider/plsql/doit_soa_order_iface_i_v2/?wsdl';
/** @var DOIT_SOA_ORDER_IFACE_I_V2_Service */
private $soapClient;
public function __construct($username, $password, \SoapClient $priceSoapClient = null)
public function __construct($username, $password, $wsdlPath = null, \SoapClient $priceSoapClient = null)
{
if ($priceSoapClient !== null) {
$this->soapClient = $priceSoapClient;
return;
} else if ($wsdlPath !== null) {
$this->soapClient = new DOIT_SOA_ORDER_IFACE_I_V2_Service(
[],
$wsdlPath
);
$this->soapClient->__setSoapHeaders(WssSoapHeaderBuilder::buildUsernameToken($username, $password));
} else {
$this->soapClient = new DOIT_SOA_ORDER_IFACE_I_V2_Service(
[],
__DIR__ . '/../../../../../../resources/doit_soa_order_iface_i_v2.xml'
);
$this->soapClient->__setSoapHeaders(WssSoapHeaderBuilder::buildUsernameToken($username, $password));
}
$this->soapClient = new DOIT_SOA_ORDER_IFACE_I_V2_Service(
[],
__DIR__ . '/../../../../../../resources/doit_soa_order_iface_i_v2.xml'
);
$this->soapClient->__setSoapHeaders(WssSoapHeaderBuilder::buildUsernameToken($username, $password));
}
public function interfaceOrder($orderNumber)
......
......@@ -10,17 +10,28 @@ use edu\wisc\services\cbs\order\OrderServiceResponse;
class SoapOrderLineService implements SoapService, OrderLineService
{
/** URL for QA WSDL */
const CBQA12 = 'http://pegasus.doit.wisc.edu:8018/webservices/SOAProvider/plsql/doit_soa_order_iface_l_v2/?wsdl';
/** URL for DV WSDL */
const CBDV12 = 'http://pegasus.doit.wisc.edu:8016/webservices/SOAProvider/plsql/doit_soa_order_iface_l_v2/?wsdl';
/** @var DOIT_SOA_ORDER_IFACE_L_V2_Service */
private $soapClient;
/**
* {@inheritdoc}
*/
public function __construct($username, $password, \SoapClient $lineSoapClient = null)
public function __construct($username, $password, $wsdlPath = null, \SoapClient $lineSoapClient = null)
{
if ($lineSoapClient !== null) {
$this->soapClient = $lineSoapClient;
return;
} else if ($wsdlPath !== null) {
$this->soapClient = new DOIT_SOA_ORDER_IFACE_L_V2_Service(
[],
$wsdlPath
);
$this->soapClient->__setSoapHeaders(WssSoapHeaderBuilder::buildUsernameToken($username, $password));
} else {
$this->soapClient = new DOIT_SOA_ORDER_IFACE_L_V2_Service(
[],
......
......@@ -15,23 +15,35 @@ use Money\Money;
class SoapOrderPaymentService implements OrderPaymentService, SoapService
{
/** URL for QA WSDL */
const CBQA12 = 'http://pegasus.doit.wisc.edu:8018/webservices/SOAProvider/plsql/doit_soa_payment_v2/?wsdl';
/** URL for DV WSDL */
const CBDV12 = 'http://pegasus.doit.wisc.edu:8016/webservices/SOAProvider/plsql/doit_soa_payment_v2/?wsdl';
/** @var DOIT_SOA_PAYMENT_V2_Service */
private $soapClient;
/**
* {@inheritdoc}
*/
public function __construct($username, $password, \SoapClient $paymentSoapClient = null)
public function __construct($username, $password, $wsdlPath = null, \SoapClient $paymentSoapClient = null)
{
if ($paymentSoapClient !== null) {
$this->soapClient = $paymentSoapClient;
return;
} else if ($wsdlPath !== null) {
$this->soapClient = new DOIT_SOA_PAYMENT_V2_Service(
[],
$wsdlPath
);
$this->soapClient->__setSoapHeaders(WssSoapHeaderBuilder::buildUsernameToken($username, $password));
} else {
$this->soapClient = new DOIT_SOA_PAYMENT_V2_Service(
[],
__DIR__ . '/../../../../../../resources/doit_soa_payment_v2.xml'
);
$this->soapClient->__setSoapHeaders(WssSoapHeaderBuilder::buildUsernameToken($username, $password));
}
$this->soapClient = new DOIT_SOA_PAYMENT_V2_Service(
[],
__DIR__ . '/../../../../../../resources/doit_soa_payment_v2.xml'
);
$this->soapClient->__setSoapHeaders(WssSoapHeaderBuilder::buildUsernameToken($username, $password));
}
/**
......
......@@ -14,23 +14,35 @@ use Money\Money;
class SoapPriceService implements PriceService, SoapService
{
/** URL for QA WSLD */
const CBQA12 = 'http://pegasus.doit.wisc.edu:8018/webservices/SOAProvider/plsql/doit_soa_pricing_v2/?wsdl';
/** URL for DV WSDL */
const CBDV12 = 'http://pegasus.doit.wisc.edu:8016/webservices/SOAProvider/plsql/doit_soa_pricing_v2/?wsdl';
/** @var \SoapClient */
private $soapClient;
/**
* @inheritdoc
*/
public function __construct($username, $password, \SoapClient $priceSoapClient = null)
public function __construct($username, $password, $wsdlPath = null, \SoapClient $priceSoapClient = null)
{
if ($priceSoapClient !== null) {
$this->soapClient = $priceSoapClient;
return;
} else if ($wsdlPath !== null) {
$this->soapClient = new DOIT_SOA_PRICING_V2_Service(
[],
$wsdlPath
);
$this->soapClient->__setSoapHeaders(WssSoapHeaderBuilder::buildUsernameToken($username, $password));
} else {
$this->soapClient = new DOIT_SOA_PRICING_V2_Service(
[],
__DIR__ . '/../../../../../resources/doit_soa_pricing_v2.xml'
);
$this->soapClient->__setSoapHeaders(WssSoapHeaderBuilder::buildUsernameToken($username, $password));
}
$this->soapClient = new DOIT_SOA_PRICING_V2_Service(
[],
__DIR__ . '/../../../../../resources/doit_soa_pricing_v2.xml'
);
$this->soapClient->__setSoapHeaders(WssSoapHeaderBuilder::buildUsernameToken($username, $password));
}
/**
......
......@@ -11,9 +11,16 @@ use edu\wisc\services\cbs\product\update\generated\DOIT_SOA_ITEM_UPDATE_V4_Servi
/**
* Class SoapTechstoreClient uses SOAP to create a product in the CBS database.
*/
class SoapProductService implements ProductService, SoapService
class SoapProductService implements ProductService
{
/** URLS for QA WSDLs */
const CBQA12_CREATE = 'http://pegasus.doit.wisc.edu:8018/webservices/SOAProvider/plsql/doit_soa_item_create_v4/?wsdl';
const CBQA12_UPDATE = 'http://pegasus.doit.wisc.edu:8018/webservices/SOAProvider/plsql/doit_soa_item_update_v4/?wsdl';
/** URLs for DV WSDLs */
const CBDV12_CREATE = 'http://pegasus.doit.wisc.edu:8016/webservices/SOAProvider/plsql/doit_soa_item_create_v4/?wsdl';
const CBDV12_UPDATE = 'http://pegasus.doit.wisc.edu:8016/webservices/SOAProvider/plsql/doit_soa_item_update_v4/?wsdl';
/** @var DOIT_SOA_ITEM_CREATE_V4_Service */
private $productCreateSoapClient;
......@@ -21,16 +28,38 @@ class SoapProductService implements ProductService, SoapService
private $productUpdateSoapClient;
/**
* @inheritdoc
* A SOAP service is constructed with a username and password. If a {@link \SoapClient} is provided, the username
* and password are ignored.
*
* @param string $username username
* @param string $password password
* @param string|null $createWsdlPath path to WSDL for specifying CBS environment. Defaults to QA
* @param string|null $updateWsdlPath path to WSDL for specifying CBS environment. Defaults to QA
* @param \SoapClient|null $productCreateSoapClient Overriding SOAP client (for testing purposes)
* @param \SoapClient|null $productUpdateSoapClient Overriding SOAP client (for testing purposes)
*/
public function __construct(
$username,
$password,
$createWsdlPath = null,
$updateWsdlPath = null,
\SoapClient $productCreateSoapClient = null,
\SoapClient $productUpdateSoapClient = null
)
{
if ($productCreateSoapClient === null || $productUpdateSoapClient === null) {
if ($createWsdlPath !== null && $updateWsdlPath !== null) {
$this->productCreateSoapClient = new DOIT_SOA_ITEM_CREATE_V4_Service(
[],
$createWsdlPath
);
$this->productCreateSoapClient->__setSoapHeaders(WssSoapHeaderBuilder::buildUsernameToken( $username, $password));
$this->productUpdateSoapClient = new DOIT_SOA_ITEM_UPDATE_V4_Service(
[],
$updateWsdlPath
);
$this->productUpdateSoapClient->__setSoapHeaders(WssSoapHeaderBuilder::buildUsernameToken($username, $password));
} else if ($productCreateSoapClient === null || $productUpdateSoapClient === null) {
$this->productCreateSoapClient = new DOIT_SOA_ITEM_CREATE_V4_Service(
[],
__DIR__ . '/../../../../../resources/doit_soa_item_create_v4.xml'
......
<?php
use \edu\wisc\services\cbs\api\SoapService;
use \edu\wisc\services\cbs\order\header\SoapOrderHeaderService;
use \edu\wisc\services\cbs\IntegrationTestCase;
/**
* Integration tests to test the various methods of instantiating a {@link SoapOrderHeaderService}.
* A {@link SoapOrderHeaderService} can be instantiated using:
*
* 1. Only username and password
* 2. Username, password and WSDL to specify a CBS environment
* 3. Username, password and instance of {@link MockOrderHeaderServiceClient}
*/
class SoapOrderHeaderServiceIT extends IntegrationTestCase
{
/**
* @test
*/
public function createsClientWithOnlyUsernameAndPassword()
{
$soapOrderHeaderService = new SoapOrderHeaderService(
static::$itData['cbs.username'],
static::$itData['cbs.password']
);
static::assertNotNull($soapOrderHeaderService);
}
/**
* @test
*/
public function createsClientWithWsdl()
{
$soapOrderHeaderService = new SoapOrderHeaderService(
static::$itData['cbs.username'],
static::$itData['cbs.password'],
SoapOrderHeaderService::CBQA12
);
static::assertNotNull($soapOrderHeaderService);
}
}
\ No newline at end of file
......@@ -23,7 +23,7 @@ class SoapOrderInterfacingServiceTest extends \PHPUnit_Framework_TestCase
protected function setUp()
{
$this->mockSoapClient = \Mockery::mock(DOIT_SOA_ORDER_IFACE_I_V2_Service::class);
$this->orderInterfacingService = new SoapOrderInterfacingService('', '', $this->mockSoapClient);
$this->orderInterfacingService = new SoapOrderInterfacingService('', '', null, $this->mockSoapClient);
}
/** Close/verify mock after each test */
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment