ConfigTest.php 4.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115
  1. <?php
  2. /**
  3. * Copyright © Magento, Inc. All rights reserved.
  4. * See COPYING.txt for license details.
  5. */
  6. namespace Magento\Webapi\Model\Soap;
  7. use Magento\TestFramework\Helper\Bootstrap;
  8. use Magento\Customer\Api\AccountManagementInterface;
  9. use Magento\Customer\Api\CustomerRepositoryInterface;
  10. use Magento\Framework\Exception\LocalizedException;
  11. class ConfigTest extends \PHPUnit\Framework\TestCase
  12. {
  13. /**
  14. * @var Config
  15. */
  16. private $soapConfig;
  17. protected function setUp()
  18. {
  19. $objectManager = Bootstrap::getObjectManager();
  20. $this->soapConfig = $objectManager->create(Config::class);
  21. }
  22. public function testGetRequestedSoapServices()
  23. {
  24. $expected = [
  25. 'customerAccountManagementV1' => [
  26. 'methods' => [
  27. 'activate' => [
  28. 'method' => 'activate',
  29. 'inputRequired' => false,
  30. 'isSecure' => false,
  31. 'resources' => [
  32. 'Magento_Customer::manage'
  33. ],
  34. 'documentation'
  35. => 'Activate a customer account using a key that was sent in a confirmation email.',
  36. 'interface' => [
  37. 'in' => [
  38. 'parameters' => [
  39. 'email' => [
  40. 'type' => 'string',
  41. 'required' => true,
  42. 'documentation' => null
  43. ],
  44. 'confirmationKey' => [
  45. 'type' => 'string',
  46. 'required' => true,
  47. 'documentation' => null
  48. ]
  49. ]
  50. ],
  51. 'out' => [
  52. 'parameters' => [
  53. 'result' => [
  54. 'type' => 'CustomerDataCustomerInterface',
  55. 'required' => true,
  56. 'documentation' => null
  57. ]
  58. ],
  59. 'throws' => [
  60. '\\' . LocalizedException::class
  61. ]
  62. ]
  63. ]
  64. ]
  65. ],
  66. 'class' => AccountManagementInterface::class,
  67. 'description' => 'Interface for managing customers accounts.',
  68. ]
  69. ];
  70. $actual = $this->soapConfig->getRequestedSoapServices(
  71. [
  72. 'customerAccountManagementV1',
  73. 'NonExistentService'
  74. ]
  75. );
  76. $this->assertEquals(array_replace_recursive($actual, $expected), $actual);
  77. }
  78. public function testGetServiceMethodInfo()
  79. {
  80. $expected = [
  81. 'class' => CustomerRepositoryInterface::class,
  82. 'method' => 'getById',
  83. 'isSecure' => false,
  84. 'resources' => [
  85. 'Magento_Customer::customer',
  86. 'self'
  87. ],
  88. ];
  89. $actual = $this->soapConfig->getServiceMethodInfo(
  90. 'customerCustomerRepositoryV1GetById',
  91. [
  92. 'customerCustomerRepositoryV1',
  93. 'NonExistentService'
  94. ]
  95. );
  96. $this->assertEquals($expected, $actual);
  97. }
  98. public function testGetSoapOperation()
  99. {
  100. $expected = 'customerAccountManagementV1Activate';
  101. $actual = $this->soapConfig
  102. ->getSoapOperation(
  103. AccountManagementInterface::class,
  104. 'activate',
  105. 'V1'
  106. );
  107. $this->assertEquals($expected, $actual);
  108. }
  109. }