RequestTest.php 1.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455
  1. <?php
  2. /**
  3. * Copyright © Magento, Inc. All rights reserved.
  4. * See COPYING.txt for license details.
  5. */
  6. namespace Magento\Framework\Webapi\Test\Unit;
  7. class RequestTest extends \PHPUnit\Framework\TestCase
  8. {
  9. /** @var \Magento\Framework\Webapi\Request */
  10. protected $request;
  11. protected function setUp()
  12. {
  13. /** Initialize SUT. */
  14. $objectManager = new \Magento\Framework\TestFramework\Unit\Helper\ObjectManager($this);
  15. $this->request = $objectManager->getObject(\Magento\Framework\Webapi\Request::class);
  16. }
  17. protected function tearDown()
  18. {
  19. unset($this->request);
  20. parent::tearDown();
  21. }
  22. /**
  23. * @dataProvider providerTestGetRequestedServicesSuccess
  24. * @param $requestParamServices
  25. * @param $expectedResult
  26. */
  27. public function testGetRequestedServicesSuccess($requestParamServices, $expectedResult)
  28. {
  29. $requestParams = [
  30. \Magento\Webapi\Model\Soap\Server::REQUEST_PARAM_WSDL => true,
  31. \Magento\Webapi\Model\Soap\Server::REQUEST_PARAM_SERVICES => $requestParamServices,
  32. ];
  33. $this->request->setParams($requestParams);
  34. $this->assertEquals($expectedResult, $this->request->getRequestedServices());
  35. }
  36. /**
  37. * @return array
  38. */
  39. public function providerTestGetRequestedServicesSuccess()
  40. {
  41. $testModuleA = 'testModule1AllSoapAndRestV1';
  42. $testModuleB = 'testModule1AllSoapAndRestV2';
  43. $testModuleC = 'testModule2AllSoapNoRestV1';
  44. return [
  45. ["{$testModuleA},{$testModuleB}", [$testModuleA, $testModuleB]],
  46. ["{$testModuleA},{$testModuleC}", [$testModuleA, $testModuleC]],
  47. ["{$testModuleA}", [$testModuleA]]
  48. ];
  49. }
  50. }