Skip to content

Commit

Permalink
Added environment variable GREENSMS_BASE_URL
Browse files Browse the repository at this point in the history
  • Loading branch information
John Doe committed Aug 8, 2024
1 parent b860cd5 commit 0ad87a7
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 3 deletions.
5 changes: 5 additions & 0 deletions src/Utils/Url.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,11 @@ class Url
{
public static function baseUrl(): string
{
$envBaseUrl = getenv('GREENSMS_BASE_URL');
if (is_string($envBaseUrl)) {
return $envBaseUrl;
}

return BASE_URL;
}

Expand Down
16 changes: 13 additions & 3 deletions tests/EnvTest.php
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
<?php



use GreenSMS\Http\RestException;
use GreenSMS\Tests\Utility;
use GreenSMS\GreenSMS;
use GreenSMS\Tests\TestCase;
Expand All @@ -21,4 +19,16 @@ public function testCanFetchLookup()
$response = $client->account->balance();
$this->assertObjectHasAttribute('balance', $response);
}

public function testBaseUrl()
{
$subDomain = (string) bin2hex(random_bytes(10));
putenv('GREENSMS_BASE_URL=https://'. $subDomain .'.greensms.io:');
$client = $this->utility->getInstance();
$response = $client->account->balance();
putenv('GREENSMS_BASE_URL');

$this->assertInstanceOf(RestException::class, $response);
$this->assertStringContainsString($subDomain, $response->getMessage());
}
}

0 comments on commit 0ad87a7

Please sign in to comment.