ServiceMetadataTest.php 3.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384
  1. <?php
  2. /**
  3. * Copyright © Magento, Inc. All rights reserved.
  4. * See COPYING.txt for license details.
  5. */
  6. namespace Magento\WebapiAsync\Plugin;
  7. use Magento\TestFramework\Helper\Bootstrap;
  8. use Magento\Customer\Api\AccountManagementInterface;
  9. use Magento\Webapi\Model\ServiceMetadata;
  10. use Magento\WebapiAsync\Controller\Rest\AsynchronousSchemaRequestProcessor;
  11. use Magento\WebapiAsync\Controller\Rest\AsynchronousSchemaRequestProcessorMock;
  12. class ServiceMetadataTest extends \PHPUnit\Framework\TestCase
  13. {
  14. /**
  15. * @var ServiceMetadata
  16. */
  17. private $serviceMetadata;
  18. protected function setUp()
  19. {
  20. $objectManager = Bootstrap::getObjectManager();
  21. $objectManager->configure([
  22. 'preferences' => [
  23. AsynchronousSchemaRequestProcessor::class => AsynchronousSchemaRequestProcessorMock::class
  24. ]
  25. ]);
  26. $this->serviceMetadata = $objectManager->create(ServiceMetadata::class);
  27. }
  28. public function testGetServiceMetadata()
  29. {
  30. $expected = [
  31. 'methods' => [
  32. 'activate' => [
  33. 'method' => 'activate',
  34. 'inputRequired' => false,
  35. 'isSecure' => false,
  36. 'resources' => [
  37. 'Magento_Customer::manage'
  38. ],
  39. 'documentation' => 'Activate a customer account using a key that was sent in a confirmation email.',
  40. 'interface' => [
  41. 'in' => [
  42. 'parameters' => [
  43. 'email' => [
  44. 'type' => 'string',
  45. 'required' => true,
  46. 'documentation' => null
  47. ],
  48. 'confirmationKey' => [
  49. 'type' => 'string',
  50. 'required' => true,
  51. 'documentation' => null
  52. ]
  53. ]
  54. ],
  55. 'out' => [
  56. 'parameters' => [
  57. 'result' => [
  58. 'type' => 'AsynchronousOperationsDataAsyncResponseInterface',
  59. 'required' => true,
  60. 'documentation' => 'Returns response information for the asynchronous request.',
  61. 'response_codes' => [
  62. 'success' => [
  63. 'code' => '202',
  64. 'description' => '202 Accepted.'
  65. ]
  66. ]
  67. ]
  68. ]
  69. ]
  70. ]
  71. ]
  72. ],
  73. 'class' => AccountManagementInterface::class,
  74. 'description' => 'Interface for managing customers accounts.',
  75. ];
  76. $actual = $this->serviceMetadata->getServiceMetadata('customerAccountManagementV1');
  77. $this->assertEquals(array_replace_recursive($actual, $expected), $actual);
  78. }
  79. }