|
| 1 | +<?php |
| 2 | +/** |
| 3 | + * Copyright 2024 Adobe |
| 4 | + * All Rights Reserved. |
| 5 | + * |
| 6 | + * NOTICE: All information contained herein is, and remains |
| 7 | + * the property of Adobe and its suppliers, if any. The intellectual |
| 8 | + * and technical concepts contained herein are proprietary to Adobe |
| 9 | + * and its suppliers and are protected by all applicable intellectual |
| 10 | + * property laws, including trade secret and copyright laws. |
| 11 | + * Dissemination of this information or reproduction of this material |
| 12 | + * is strictly forbidden unless prior written permission is obtained from |
| 13 | + * Adobe. |
| 14 | + */ |
| 15 | +declare(strict_types=1); |
| 16 | + |
| 17 | +namespace Magento\GraphQl\IntegrationGraphQl; |
| 18 | + |
| 19 | +use Magento\TestFramework\TestCase\GraphQlAbstract; |
| 20 | +use Magento\TestFramework\Fixture\Config; |
| 21 | + |
| 22 | +/** |
| 23 | + * Class for Store Config Customer Access Token Lifetime settings |
| 24 | + */ |
| 25 | +class CustomerAccessTokenLifetimeResolverTest extends GraphQlAbstract |
| 26 | +{ |
| 27 | + #[ |
| 28 | + Config('oauth/access_token_lifetime/customer', '2') |
| 29 | + ] |
| 30 | + public function testGetCustomerAccessTokenLifetimeAsString() |
| 31 | + { |
| 32 | + $this->assertEquals( |
| 33 | + $this->graphQlQuery($this->getQuery()), |
| 34 | + [ |
| 35 | + 'storeConfig' => [ |
| 36 | + "customer_access_token_lifetime" => 2 |
| 37 | + ] |
| 38 | + ] |
| 39 | + ); |
| 40 | + } |
| 41 | + |
| 42 | + #[ |
| 43 | + Config('oauth/access_token_lifetime/customer', 2.5) |
| 44 | + ] |
| 45 | + public function testGetCustomerAccessTokenLifetimeAsFloat() |
| 46 | + { |
| 47 | + $this->assertEquals( |
| 48 | + $this->graphQlQuery($this->getQuery()), |
| 49 | + [ |
| 50 | + 'storeConfig' => [ |
| 51 | + "customer_access_token_lifetime" => 2.5 |
| 52 | + ] |
| 53 | + ] |
| 54 | + ); |
| 55 | + } |
| 56 | + |
| 57 | + #[ |
| 58 | + Config('oauth/access_token_lifetime/customer', null) |
| 59 | + ] |
| 60 | + public function testGetCustomerAccessTokenLifetimeNull() |
| 61 | + { |
| 62 | + $this->assertEquals( |
| 63 | + $this->graphQlQuery($this->getQuery()), |
| 64 | + [ |
| 65 | + 'storeConfig' => [ |
| 66 | + "customer_access_token_lifetime" => null |
| 67 | + ] |
| 68 | + ] |
| 69 | + ); |
| 70 | + } |
| 71 | + |
| 72 | + /** |
| 73 | + * @return string |
| 74 | + */ |
| 75 | + private function getQuery(): string |
| 76 | + { |
| 77 | + return <<<QUERY |
| 78 | + { |
| 79 | + storeConfig { |
| 80 | + customer_access_token_lifetime |
| 81 | + } |
| 82 | + } |
| 83 | +QUERY; |
| 84 | + } |
| 85 | +} |
0 commit comments