Skip to content

Commit a573952

Browse files
authored
added APSE to VALID_REGIONS (#717)
* added APSE to VALID_REGIONS * added unit test for valid regions * adjusted test to assert region and mapping separately, removed client in terminal endpoint from client.php and region.php mapping
1 parent 5b5a72e commit a573952

File tree

2 files changed

+72
-1
lines changed

2 files changed

+72
-1
lines changed

src/Adyen/Region.php

+30-1
Original file line numberDiff line numberDiff line change
@@ -4,18 +4,47 @@
44

55
class Region
66
{
7+
/**
8+
* European Union region
9+
*/
710
const EU = "eu";
11+
12+
/**
13+
* United States region
14+
*/
815
const US = "us";
16+
17+
/**
18+
* Australia region
19+
*/
920
const AU = "au";
21+
22+
/**
23+
* India region
24+
*/
1025
const IN = "in";
1126

27+
/**
28+
* Asia-Pacific, South East region
29+
*/
30+
const APSE = "apse";
31+
32+
/**
33+
* List of all valid regions
34+
* @var array<int,string>
35+
*/
1236
const VALID_REGIONS = [
1337
self::EU,
1438
self::US,
1539
self::AU,
16-
self::IN
40+
self::IN,
41+
self::APSE
1742
];
1843

44+
/**
45+
* Maps regions to their respective Terminal API endpoints.
46+
* @var array<string, string>
47+
*/
1948
const TERMINAL_API_ENDPOINTS_MAPPING = [
2049
self::EU => Client::ENDPOINT_TERMINAL_CLOUD_LIVE,
2150
self::US => Client::ENDPOINT_TERMINAL_CLOUD_US_LIVE,

tests/Unit/RegionTest.php

+42
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
<?php
2+
3+
namespace Adyen\Tests\Unit;
4+
5+
use PHPUnit\Framework\TestCase;
6+
use Adyen\Region;
7+
8+
class RegionTest extends TestCase
9+
{
10+
public function testValidRegions()
11+
{
12+
$expected = [
13+
"eu",
14+
"us",
15+
"au",
16+
"in",
17+
"apse",
18+
];
19+
20+
$this->assertEquals(
21+
$expected,
22+
Region::VALID_REGIONS,
23+
"VALID_REGIONS should match the expected regions."
24+
);
25+
}
26+
27+
public function testTerminalApiEndpointsMapping()
28+
{
29+
$expected = [
30+
"eu" => "https://terminal-api-live.adyen.com",
31+
"us" => "https://terminal-api-live-us.adyen.com",
32+
"au" => "https://terminal-api-live-au.adyen.com",
33+
"apse" => "https://terminal-api-live-apse.adyen.com",
34+
];
35+
36+
$this->assertEquals(
37+
$expected,
38+
Region::TERMINAL_API_ENDPOINTS_MAPPING,
39+
"TERMINAL_API_ENDPOINTS_MAPPING should match the expected mappings."
40+
);
41+
}
42+
}

0 commit comments

Comments
 (0)