Skip to content

Commit

Permalink
Added environment variable GREENSMS_BASE_URL (#13)
Browse files Browse the repository at this point in the history
  • Loading branch information
someAction authored Aug 10, 2024
1 parent 3a91082 commit 17de7d9
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 17de7d9

Please sign in to comment.