-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #121 from silinternational/feature/add-domain-list
Add domain list
- Loading branch information
Showing
7 changed files
with
70 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
<?php | ||
|
||
namespace SilMock\Google\Service\Directory\Resource; | ||
|
||
use Google\Service\Directory\Domains as GoogleDirectory_Domains; | ||
use Google\Service\Directory\Domains2 as GoogleDirectory_Domains2; | ||
use SilMock\Google\Service\DbClass; | ||
|
||
class Domains extends DbClass | ||
{ | ||
// default to the same as Group and Members | ||
public function __construct(?string $dbFile = DATAFILE5) | ||
{ | ||
parent::__construct($dbFile, 'directory', 'domains'); | ||
} | ||
|
||
public function listDomains(string $customer, array $options = []): GoogleDirectory_Domains2 | ||
{ | ||
// no need to store anything at this time. | ||
$domainNamesString = getenv('DOMAIN_NAMES'); | ||
$domainNames = explode(',', $domainNamesString); | ||
$domains = []; | ||
foreach ($domainNames as $domainName) { | ||
$domain = new GoogleDirectory_Domains(); | ||
$domain->setDomainName($domainName); | ||
$domains[] = $domain; | ||
} | ||
$domains2 = new GoogleDirectory_Domains2(); | ||
$domains2->setDomains($domains); | ||
return $domains2; | ||
} | ||
} |
28 changes: 28 additions & 0 deletions
28
SilMock/tests/Google/Service/Directory/Resource/DomainsTest.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
<?php | ||
|
||
namespace Service\Directory\Resource; | ||
|
||
use PHPUnit\Framework\TestCase; | ||
use SilMock\Google\Service\Directory\Resource\Domains; | ||
|
||
class DomainsTest extends TestCase | ||
{ | ||
public function testListDomains() | ||
{ | ||
$domainsApi = new Domains(); | ||
$domainNameListObject = $domainsApi->listDomains('any_customer'); | ||
$arrayOfDomainsObjects = $domainNameListObject->getDomains(); | ||
$domainNameList = []; | ||
foreach ($arrayOfDomainsObjects as $domainObject) { | ||
$domainNameList[$domainObject->getDomainName()] = $domainObject->getDomainName(); | ||
} | ||
// This should match the values in docker-compose.yml when testing locally | ||
// This should match the values in run-tests.sh when testing is triggered by GitHub actions | ||
// This is the keyed array version of the list. | ||
$expected = [ | ||
'groups.example.org' => 'groups.example.org', | ||
'example.org' => 'example.org', | ||
]; | ||
self::assertEquals($expected, $domainNameList, 'Domain name list does not match expected values'); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters