diff --git a/composer.json b/composer.json index acc5b85c6259558664b6115a81b98c40b5a0b023..cfc89fd344fd23c2ac8c4de5990888a84116ea18 100755 --- a/composer.json +++ b/composer.json @@ -1,7 +1,7 @@ { "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": [ diff --git a/src/main/edu/wisc/services/cbs/api/SoapService.php b/src/main/edu/wisc/services/cbs/api/SoapService.php index a95788173000251abb9f85364123b2bcaeb153bb..ba11f825bf263f0cc2d777406016fb220e421bb7 100644 --- a/src/main/edu/wisc/services/cbs/api/SoapService.php +++ b/src/main/edu/wisc/services/cbs/api/SoapService.php @@ -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); } diff --git a/src/main/edu/wisc/services/cbs/order/header/SoapOrderHeaderService.php b/src/main/edu/wisc/services/cbs/order/header/SoapOrderHeaderService.php index c340902ddc5517d63181a79cb2c205570c4c2169..67dfaf6ec37dce11b7f13e2f393f22e136bb87bd 100644 --- a/src/main/edu/wisc/services/cbs/order/header/SoapOrderHeaderService.php +++ b/src/main/edu/wisc/services/cbs/order/header/SoapOrderHeaderService.php @@ -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( [], diff --git a/src/main/edu/wisc/services/cbs/order/interfacing/SoapOrderInterfacingService.php b/src/main/edu/wisc/services/cbs/order/interfacing/SoapOrderInterfacingService.php index 176ad2f679b21312e157d6437e6b161629d77cac..d0f4c60a4fe6fb8ba1d8f0b68225f6c226934cea 100644 --- a/src/main/edu/wisc/services/cbs/order/interfacing/SoapOrderInterfacingService.php +++ b/src/main/edu/wisc/services/cbs/order/interfacing/SoapOrderInterfacingService.php @@ -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) diff --git a/src/main/edu/wisc/services/cbs/order/line/SoapOrderLineService.php b/src/main/edu/wisc/services/cbs/order/line/SoapOrderLineService.php index 528aaf4b0eff4e869fe52c8235e7736245ecc7e4..d9700ed88482c18c0f8b51fc820917e2bb072389 100644 --- a/src/main/edu/wisc/services/cbs/order/line/SoapOrderLineService.php +++ b/src/main/edu/wisc/services/cbs/order/line/SoapOrderLineService.php @@ -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( [], diff --git a/src/main/edu/wisc/services/cbs/order/payment/SoapOrderPaymentService.php b/src/main/edu/wisc/services/cbs/order/payment/SoapOrderPaymentService.php index dce73ae2de4f4cd103449f7a0174afea3bee80ff..a2f2795118d97df09176ce23d60bbc9b5a92a8bc 100644 --- a/src/main/edu/wisc/services/cbs/order/payment/SoapOrderPaymentService.php +++ b/src/main/edu/wisc/services/cbs/order/payment/SoapOrderPaymentService.php @@ -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)); } /** diff --git a/src/main/edu/wisc/services/cbs/price/SoapPriceService.php b/src/main/edu/wisc/services/cbs/price/SoapPriceService.php index c980072b37b8f1499c39928c9ff3f8c3e75b6a3e..bc62667466df36c546b76425fa0150ce3199a2b0 100644 --- a/src/main/edu/wisc/services/cbs/price/SoapPriceService.php +++ b/src/main/edu/wisc/services/cbs/price/SoapPriceService.php @@ -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)); } /** diff --git a/src/main/edu/wisc/services/cbs/product/SoapProductService.php b/src/main/edu/wisc/services/cbs/product/SoapProductService.php index 95cf698f0e6c1e3460fc3a91d3f13643dde4956f..20f2a7b4aaedd3ab028a1384bba2df3e8cf0e2fb 100755 --- a/src/main/edu/wisc/services/cbs/product/SoapProductService.php +++ b/src/main/edu/wisc/services/cbs/product/SoapProductService.php @@ -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' diff --git a/src/test/edu/wisc/services/cbs/order/header/SoapOrderHeaderServiceIT.php b/src/test/edu/wisc/services/cbs/order/header/SoapOrderHeaderServiceIT.php new file mode 100644 index 0000000000000000000000000000000000000000..fccdf4dee5e61b90fb23f7374cfd0135f4ffba5f --- /dev/null +++ b/src/test/edu/wisc/services/cbs/order/header/SoapOrderHeaderServiceIT.php @@ -0,0 +1,43 @@ +<?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 diff --git a/src/test/edu/wisc/services/cbs/order/interfacing/SoapOrderInterfacingServiceTest.php b/src/test/edu/wisc/services/cbs/order/interfacing/SoapOrderInterfacingServiceTest.php index 54a30eeeff639b227c943cc83a893afadc23ad04..0747c0907dc704436a3a6932ee2af104d1c682f7 100644 --- a/src/test/edu/wisc/services/cbs/order/interfacing/SoapOrderInterfacingServiceTest.php +++ b/src/test/edu/wisc/services/cbs/order/interfacing/SoapOrderInterfacingServiceTest.php @@ -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 */