From a7868a79ec09e4d650c5d4e3550b605d8ecac7fd Mon Sep 17 00:00:00 2001 From: Mark Tompsett Date: Thu, 12 Dec 2024 11:22:16 -0500 Subject: [PATCH 1/8] Add list of dummy domains for testing --- docker-compose.yml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/docker-compose.yml b/docker-compose.yml index d993523..ee5e90e 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -5,6 +5,8 @@ services: volumes: - ./:/data working_dir: /data + environment: + - DOMAIN_NAMES=groups.example.org,example.org command: ["true"] networks: From c752f99134bd4387b39e1179799ce179d7b396b8 Mon Sep 17 00:00:00 2001 From: Mark Tompsett Date: Thu, 12 Dec 2024 11:23:03 -0500 Subject: [PATCH 2/8] Fake a list of domains from the environment variable list --- .../Service/Directory/Resource/Domains.php | 32 +++++++++++++++++++ 1 file changed, 32 insertions(+) create mode 100644 SilMock/Google/Service/Directory/Resource/Domains.php diff --git a/SilMock/Google/Service/Directory/Resource/Domains.php b/SilMock/Google/Service/Directory/Resource/Domains.php new file mode 100644 index 0000000..2ad2a95 --- /dev/null +++ b/SilMock/Google/Service/Directory/Resource/Domains.php @@ -0,0 +1,32 @@ +setDomainName($domainName); + $domains[] = $domain; + } + $domains2 = new GoogleDirectory_Domains2(); + $domains2->setDomains($domains); + return $domains2; + } +} From acf5c71ddf88b4056760c070f776e1bd61b388ab Mon Sep 17 00:00:00 2001 From: Mark Tompsett Date: Thu, 12 Dec 2024 11:23:38 -0500 Subject: [PATCH 3/8] Add link to reference new listDomains functionality --- SilMock/Google/Service/Directory.php | 3 +++ 1 file changed, 3 insertions(+) diff --git a/SilMock/Google/Service/Directory.php b/SilMock/Google/Service/Directory.php index 3955ffe..90b7bd5 100644 --- a/SilMock/Google/Service/Directory.php +++ b/SilMock/Google/Service/Directory.php @@ -5,6 +5,7 @@ use Google\Client; use SilMock\Google\Http\Batch; use SilMock\Google\Service\Directory\Asps; +use SilMock\Google\Service\Directory\Resource\Domains; use SilMock\Google\Service\Directory\Resource\Groups; use SilMock\Google\Service\Directory\Resource\GroupsAliases; use SilMock\Google\Service\Directory\Resource\Members; @@ -18,6 +19,7 @@ class Directory { public $asps; + public Domains $domains; public Members $members; public Groups $groups; public GroupsAliases $groups_aliases; @@ -38,6 +40,7 @@ class Directory public function __construct($client, ?string $dbFile = null) { $this->asps = new Asps($dbFile); + $this->domains = new Domains($dbFile); $this->members = new Members($dbFile); $this->groups = new Groups($dbFile); $this->groups_aliases = new GroupsAliases($dbFile); From bd20f7d12197a6ec884280fa44d99e378e7458af Mon Sep 17 00:00:00 2001 From: Mark Tompsett Date: Thu, 12 Dec 2024 11:24:03 -0500 Subject: [PATCH 4/8] Test the function. If there is a mismatch, it should be the environment variable value defined in the docker-compose.yml file. --- .../Directory/Resource/DomainsTest.php | 25 +++++++++++++++++++ 1 file changed, 25 insertions(+) create mode 100644 SilMock/tests/Google/Service/Directory/Resource/DomainsTest.php diff --git a/SilMock/tests/Google/Service/Directory/Resource/DomainsTest.php b/SilMock/tests/Google/Service/Directory/Resource/DomainsTest.php new file mode 100644 index 0000000..febe766 --- /dev/null +++ b/SilMock/tests/Google/Service/Directory/Resource/DomainsTest.php @@ -0,0 +1,25 @@ +listDomains('any_customer'); + $arrayOfDomainsObjects = $domainNameListObject->getDomains(); + $domainNameList = []; + foreach ($arrayOfDomainsObjects as $domainObject) { + $domainNameList[$domainObject->getDomainName()] = $domainObject->getDomainName(); + } + $expected = [ + 'groups.example.org' => 'groups.example.org', + 'example.org' => 'example.org', + ]; + self::assertEquals($expected, $domainNameList, 'Domain name list does not match expected values'); + } +} From 4958b2a4e6feb95f882cc06d946b417365ee109d Mon Sep 17 00:00:00 2001 From: Mark Tompsett Date: Thu, 12 Dec 2024 11:25:54 -0500 Subject: [PATCH 5/8] Update version and dependencies --- composer.json | 2 +- composer.lock | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/composer.json b/composer.json index e5c2b3d..af937bb 100644 --- a/composer.json +++ b/composer.json @@ -1,6 +1,6 @@ { "name": "silinternational/google-api-php-client-mock", - "version": "2.13.2", + "version": "2.14.0", "description": "Attempting to create an intelligent mock of the Google API PHP Client for unit and functional testing.", "type": "library", "keywords": [ diff --git a/composer.lock b/composer.lock index 48042bb..2b1d99f 100644 --- a/composer.lock +++ b/composer.lock @@ -4,7 +4,7 @@ "Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies", "This file is @generated automatically" ], - "content-hash": "6a6776cd80056ba0e3e3e1e8ae7f6e7d", + "content-hash": "1e021a94f9075dbd119cd1e3e5d7889a", "packages": [ { "name": "firebase/php-jwt", From baa2d486ddfbec7f65e8e8a25492409665f5e8c9 Mon Sep 17 00:00:00 2001 From: Mark Tompsett Date: Thu, 12 Dec 2024 11:29:47 -0500 Subject: [PATCH 6/8] Make sure the DOMAIN_NAMES is defined for github actions tests --- run-tests.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/run-tests.sh b/run-tests.sh index b822352..3896e87 100755 --- a/run-tests.sh +++ b/run-tests.sh @@ -2,4 +2,4 @@ cd /data/SilMock/tests -./phpunit +DOMAIN_NAMES=groups.example.org,example.org ./phpunit From 2f33ed1e90200f4df6f9518d63168fd6e04b4295 Mon Sep 17 00:00:00 2001 From: Mark Tompsett Date: Thu, 12 Dec 2024 11:34:57 -0500 Subject: [PATCH 7/8] Add comments to ensure remember to keep DOMAIN_NAMES synchronized --- docker-compose.yml | 1 + run-tests.sh | 1 + 2 files changed, 2 insertions(+) diff --git a/docker-compose.yml b/docker-compose.yml index ee5e90e..2b4617b 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -6,6 +6,7 @@ services: - ./:/data working_dir: /data environment: + # This should match the value in run-tests.sh - DOMAIN_NAMES=groups.example.org,example.org command: ["true"] diff --git a/run-tests.sh b/run-tests.sh index 3896e87..62f7ac9 100755 --- a/run-tests.sh +++ b/run-tests.sh @@ -2,4 +2,5 @@ cd /data/SilMock/tests +# This should match the value in docker-compose.yml DOMAIN_NAMES=groups.example.org,example.org ./phpunit From 87042f621af2b8bc687bae1715cd60c79044d61c Mon Sep 17 00:00:00 2001 From: Mark Tompsett Date: Thu, 12 Dec 2024 11:38:11 -0500 Subject: [PATCH 8/8] Add more comments for clarity --- .../tests/Google/Service/Directory/Resource/DomainsTest.php | 3 +++ 1 file changed, 3 insertions(+) diff --git a/SilMock/tests/Google/Service/Directory/Resource/DomainsTest.php b/SilMock/tests/Google/Service/Directory/Resource/DomainsTest.php index febe766..712b210 100644 --- a/SilMock/tests/Google/Service/Directory/Resource/DomainsTest.php +++ b/SilMock/tests/Google/Service/Directory/Resource/DomainsTest.php @@ -16,6 +16,9 @@ public function testListDomains() 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',