|
| 1 | +<?php |
| 2 | + |
| 3 | +/** |
| 4 | + * Aligent Consulting |
| 5 | + * Copyright (c) Aligent Consulting (https://www.aligent.com.au) |
| 6 | + */ |
| 7 | + |
| 8 | +declare(strict_types=1); |
| 9 | + |
| 10 | +namespace Aligent\AsyncEvents\Test\Api; |
| 11 | + |
| 12 | +use Magento\Framework\Webapi\Rest\Request; |
| 13 | +use Magento\TestFramework\TestCase\WebapiAbstract; |
| 14 | + |
| 15 | +class AsyncEventRepositoryTest extends WebapiAbstract |
| 16 | +{ |
| 17 | + /** |
| 18 | + * @magentoApiDataFixture Aligent_AsyncEvents::Test/_files/http_async_events.php |
| 19 | + */ |
| 20 | + public function testGet() |
| 21 | + { |
| 22 | + $serviceInfo = [ |
| 23 | + 'rest' => [ |
| 24 | + 'resourcePath' => '/V1/async_event/1', |
| 25 | + 'httpMethod' => Request::HTTP_METHOD_GET, |
| 26 | + ], |
| 27 | + ]; |
| 28 | + |
| 29 | + $response = $this->_webApiCall($serviceInfo); |
| 30 | + |
| 31 | + $this->assertArrayHasKey('subscription_id', $response); |
| 32 | + $this->assertArrayHasKey('event_name', $response); |
| 33 | + $this->assertArrayHasKey('recipient_url', $response); |
| 34 | + $this->assertArrayHasKey('status', $response); |
| 35 | + $this->assertArrayHasKey('subscribed_at', $response); |
| 36 | + |
| 37 | + // Make sure that the verification token is not exposed even if it is encrypted. |
| 38 | + $this->assertArrayNotHasKey('verification_token', $response); |
| 39 | + } |
| 40 | + |
| 41 | + public function testGetList() |
| 42 | + { |
| 43 | + $searchCriteria = [ |
| 44 | + 'searchCriteria' => '' |
| 45 | + ]; |
| 46 | + |
| 47 | + $serviceInfo = [ |
| 48 | + 'rest' => [ |
| 49 | + 'resourcePath' => '/V1/async_events' . '?' . http_build_query($searchCriteria), |
| 50 | + 'httpMethod' => Request::HTTP_METHOD_GET, |
| 51 | + ], |
| 52 | + ]; |
| 53 | + |
| 54 | + $response = $this->_webApiCall($serviceInfo, $searchCriteria); |
| 55 | + |
| 56 | + $this->assertIsArray($response); |
| 57 | + $this->assertArrayHasKey('items', $response); |
| 58 | + $this->assertIsArray($response['items'][0]); |
| 59 | + |
| 60 | + $this->assertArrayHasKey('subscription_id', $response['items'][0]); |
| 61 | + $this->assertArrayHasKey('event_name', $response['items'][0]); |
| 62 | + $this->assertArrayHasKey('recipient_url', $response['items'][0]); |
| 63 | + $this->assertArrayHasKey('status', $response['items'][0]); |
| 64 | + $this->assertArrayHasKey('subscribed_at', $response['items'][0]); |
| 65 | + |
| 66 | + // Make sure that the verification token is not exposed even if it is encrypted. |
| 67 | + $this->assertArrayNotHasKey('verification_token', $response['items'][0]); |
| 68 | + } |
| 69 | +} |
0 commit comments