From ecbf1290ad01c1621411280d0840bb017616b581 Mon Sep 17 00:00:00 2001 From: Mark Tompsett Date: Mon, 18 May 2020 17:11:41 -0400 Subject: [PATCH 01/16] Attempt to add codeship CI --- codeship-services.yml | 5 +++++ codeship-steps.yml | 3 +++ 2 files changed, 8 insertions(+) create mode 100644 codeship-services.yml create mode 100644 codeship-steps.yml diff --git a/codeship-services.yml b/codeship-services.yml new file mode 100644 index 0000000..3d116e3 --- /dev/null +++ b/codeship-services.yml @@ -0,0 +1,5 @@ +cli: + build: ./ + volumes: + - ./:/data + working_dir: /data diff --git a/codeship-steps.yml b/codeship-steps.yml new file mode 100644 index 0000000..3038c08 --- /dev/null +++ b/codeship-steps.yml @@ -0,0 +1,3 @@ +- name: test + service: cli + command: "cd /data/SilMock/tests; ./phpunit" From 4a3a4c4b425df5929c895b1d78f9482c13e2392b Mon Sep 17 00:00:00 2001 From: Mark Tompsett Date: Thu, 17 Mar 2022 14:46:15 -0400 Subject: [PATCH 02/16] Update composer dependencies and add psr3logger --- composer.json | 3 +- composer.lock | 256 ++++++++++++++++++++++++++++++++++++-------------- 2 files changed, 186 insertions(+), 73 deletions(-) diff --git a/composer.json b/composer.json index 5888c83..388cae2 100644 --- a/composer.json +++ b/composer.json @@ -30,7 +30,8 @@ "google/apiclient-services": "^0.176" }, "require-dev": { - "phpunit/phpunit": "^9.5.4" + "phpunit/phpunit": "^9.5.4", + "silinternational/psr3-adapters": "^3.0" }, "autoload": { "psr-0": { diff --git a/composer.lock b/composer.lock index 4e4d407..dce9bfa 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": "4085068b5c7875c82b3790c181fccbce", + "content-hash": "9848b2bcdc52e08decf9560b177e1056", "packages": [ { "name": "google/apiclient", @@ -98,29 +98,30 @@ "packages-dev": [ { "name": "doctrine/instantiator", - "version": "1.4.0", + "version": "1.4.1", "source": { "type": "git", "url": "https://github.com/doctrine/instantiator.git", - "reference": "d56bf6102915de5702778fe20f2de3b2fe570b5b" + "reference": "10dcfce151b967d20fde1b34ae6640712c3891bc" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/doctrine/instantiator/zipball/d56bf6102915de5702778fe20f2de3b2fe570b5b", - "reference": "d56bf6102915de5702778fe20f2de3b2fe570b5b", + "url": "https://api.github.com/repos/doctrine/instantiator/zipball/10dcfce151b967d20fde1b34ae6640712c3891bc", + "reference": "10dcfce151b967d20fde1b34ae6640712c3891bc", "shasum": "" }, "require": { "php": "^7.1 || ^8.0" }, "require-dev": { - "doctrine/coding-standard": "^8.0", + "doctrine/coding-standard": "^9", "ext-pdo": "*", "ext-phar": "*", - "phpbench/phpbench": "^0.13 || 1.0.0-alpha2", - "phpstan/phpstan": "^0.12", - "phpstan/phpstan-phpunit": "^0.12", - "phpunit/phpunit": "^7.0 || ^8.0 || ^9.0" + "phpbench/phpbench": "^0.16 || ^1", + "phpstan/phpstan": "^1.4", + "phpstan/phpstan-phpunit": "^1", + "phpunit/phpunit": "^7.5 || ^8.5 || ^9.5", + "vimeo/psalm": "^4.22" }, "type": "library", "autoload": { @@ -147,7 +148,7 @@ ], "support": { "issues": "https://github.com/doctrine/instantiator/issues", - "source": "https://github.com/doctrine/instantiator/tree/1.4.0" + "source": "https://github.com/doctrine/instantiator/tree/1.4.1" }, "funding": [ { @@ -163,38 +164,42 @@ "type": "tidelift" } ], - "time": "2020-11-10T18:47:58+00:00" + "time": "2022-03-03T08:28:38+00:00" }, { "name": "myclabs/deep-copy", - "version": "1.10.2", + "version": "1.11.0", "source": { "type": "git", "url": "https://github.com/myclabs/DeepCopy.git", - "reference": "776f831124e9c62e1a2c601ecc52e776d8bb7220" + "reference": "14daed4296fae74d9e3201d2c4925d1acb7aa614" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/myclabs/DeepCopy/zipball/776f831124e9c62e1a2c601ecc52e776d8bb7220", - "reference": "776f831124e9c62e1a2c601ecc52e776d8bb7220", + "url": "https://api.github.com/repos/myclabs/DeepCopy/zipball/14daed4296fae74d9e3201d2c4925d1acb7aa614", + "reference": "14daed4296fae74d9e3201d2c4925d1acb7aa614", "shasum": "" }, "require": { "php": "^7.1 || ^8.0" }, + "conflict": { + "doctrine/collections": "<1.6.8", + "doctrine/common": "<2.13.3 || >=3,<3.2.2" + }, "require-dev": { - "doctrine/collections": "^1.0", - "doctrine/common": "^2.6", - "phpunit/phpunit": "^7.1" + "doctrine/collections": "^1.6.8", + "doctrine/common": "^2.13.3 || ^3.2.2", + "phpunit/phpunit": "^7.5.20 || ^8.5.23 || ^9.5.13" }, "type": "library", "autoload": { - "psr-4": { - "DeepCopy\\": "src/DeepCopy/" - }, "files": [ "src/DeepCopy/deep_copy.php" - ] + ], + "psr-4": { + "DeepCopy\\": "src/DeepCopy/" + } }, "notification-url": "https://packagist.org/downloads/", "license": [ @@ -210,7 +215,7 @@ ], "support": { "issues": "https://github.com/myclabs/DeepCopy/issues", - "source": "https://github.com/myclabs/DeepCopy/tree/1.10.2" + "source": "https://github.com/myclabs/DeepCopy/tree/1.11.0" }, "funding": [ { @@ -218,7 +223,7 @@ "type": "tidelift" } ], - "time": "2020-11-13T09:40:50+00:00" + "time": "2022-03-03T13:19:32+00:00" }, { "name": "nikic/php-parser", @@ -338,16 +343,16 @@ }, { "name": "phar-io/version", - "version": "3.1.0", + "version": "3.2.1", "source": { "type": "git", "url": "https://github.com/phar-io/version.git", - "reference": "bae7c545bef187884426f042434e561ab1ddb182" + "reference": "4f7fd7836c6f332bb2933569e566a0d6c4cbed74" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/phar-io/version/zipball/bae7c545bef187884426f042434e561ab1ddb182", - "reference": "bae7c545bef187884426f042434e561ab1ddb182", + "url": "https://api.github.com/repos/phar-io/version/zipball/4f7fd7836c6f332bb2933569e566a0d6c4cbed74", + "reference": "4f7fd7836c6f332bb2933569e566a0d6c4cbed74", "shasum": "" }, "require": { @@ -383,9 +388,9 @@ "description": "Library for handling version information and constraints", "support": { "issues": "https://github.com/phar-io/version/issues", - "source": "https://github.com/phar-io/version/tree/3.1.0" + "source": "https://github.com/phar-io/version/tree/3.2.1" }, - "time": "2021-02-23T14:00:09+00:00" + "time": "2022-02-21T01:04:05+00:00" }, { "name": "phpdocumentor/reflection-common", @@ -616,16 +621,16 @@ }, { "name": "phpunit/php-code-coverage", - "version": "9.2.10", + "version": "9.2.15", "source": { "type": "git", "url": "https://github.com/sebastianbergmann/php-code-coverage.git", - "reference": "d5850aaf931743067f4bfc1ae4cbd06468400687" + "reference": "2e9da11878c4202f97915c1cb4bb1ca318a63f5f" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/sebastianbergmann/php-code-coverage/zipball/d5850aaf931743067f4bfc1ae4cbd06468400687", - "reference": "d5850aaf931743067f4bfc1ae4cbd06468400687", + "url": "https://api.github.com/repos/sebastianbergmann/php-code-coverage/zipball/2e9da11878c4202f97915c1cb4bb1ca318a63f5f", + "reference": "2e9da11878c4202f97915c1cb4bb1ca318a63f5f", "shasum": "" }, "require": { @@ -681,7 +686,7 @@ ], "support": { "issues": "https://github.com/sebastianbergmann/php-code-coverage/issues", - "source": "https://github.com/sebastianbergmann/php-code-coverage/tree/9.2.10" + "source": "https://github.com/sebastianbergmann/php-code-coverage/tree/9.2.15" }, "funding": [ { @@ -689,7 +694,7 @@ "type": "github" } ], - "time": "2021-12-05T09:12:13+00:00" + "time": "2022-03-07T09:28:20+00:00" }, { "name": "phpunit/php-file-iterator", @@ -934,16 +939,16 @@ }, { "name": "phpunit/phpunit", - "version": "9.5.11", + "version": "9.5.19", "source": { "type": "git", "url": "https://github.com/sebastianbergmann/phpunit.git", - "reference": "2406855036db1102126125537adb1406f7242fdd" + "reference": "35ea4b7f3acabb26f4bb640f8c30866c401da807" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/sebastianbergmann/phpunit/zipball/2406855036db1102126125537adb1406f7242fdd", - "reference": "2406855036db1102126125537adb1406f7242fdd", + "url": "https://api.github.com/repos/sebastianbergmann/phpunit/zipball/35ea4b7f3acabb26f4bb640f8c30866c401da807", + "reference": "35ea4b7f3acabb26f4bb640f8c30866c401da807", "shasum": "" }, "require": { @@ -959,7 +964,7 @@ "phar-io/version": "^3.0.2", "php": ">=7.3", "phpspec/prophecy": "^1.12.1", - "phpunit/php-code-coverage": "^9.2.7", + "phpunit/php-code-coverage": "^9.2.13", "phpunit/php-file-iterator": "^3.0.5", "phpunit/php-invoker": "^3.1.1", "phpunit/php-text-template": "^2.0.3", @@ -973,7 +978,7 @@ "sebastian/global-state": "^5.0.1", "sebastian/object-enumerator": "^4.0.3", "sebastian/resource-operations": "^3.0.3", - "sebastian/type": "^2.3.4", + "sebastian/type": "^3.0", "sebastian/version": "^3.0.2" }, "require-dev": { @@ -994,11 +999,11 @@ } }, "autoload": { - "classmap": [ - "src/" - ], "files": [ "src/Framework/Assert/Functions.php" + ], + "classmap": [ + "src/" ] }, "notification-url": "https://packagist.org/downloads/", @@ -1021,7 +1026,7 @@ ], "support": { "issues": "https://github.com/sebastianbergmann/phpunit/issues", - "source": "https://github.com/sebastianbergmann/phpunit/tree/9.5.11" + "source": "https://github.com/sebastianbergmann/phpunit/tree/9.5.19" }, "funding": [ { @@ -1033,7 +1038,57 @@ "type": "github" } ], - "time": "2021-12-25T07:07:57+00:00" + "time": "2022-03-15T09:57:31+00:00" + }, + { + "name": "psr/log", + "version": "1.1.4", + "source": { + "type": "git", + "url": "https://github.com/php-fig/log.git", + "reference": "d49695b909c3b7628b6289db5479a1c204601f11" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/php-fig/log/zipball/d49695b909c3b7628b6289db5479a1c204601f11", + "reference": "d49695b909c3b7628b6289db5479a1c204601f11", + "shasum": "" + }, + "require": { + "php": ">=5.3.0" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "1.1.x-dev" + } + }, + "autoload": { + "psr-4": { + "Psr\\Log\\": "Psr/Log/" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "PHP-FIG", + "homepage": "https://www.php-fig.org/" + } + ], + "description": "Common interface for logging libraries", + "homepage": "https://github.com/php-fig/log", + "keywords": [ + "log", + "psr", + "psr-3" + ], + "support": { + "source": "https://github.com/php-fig/log/tree/1.1.4" + }, + "time": "2021-05-03T11:20:27+00:00" }, { "name": "sebastian/cli-parser", @@ -1541,16 +1596,16 @@ }, { "name": "sebastian/global-state", - "version": "5.0.3", + "version": "5.0.5", "source": { "type": "git", "url": "https://github.com/sebastianbergmann/global-state.git", - "reference": "23bd5951f7ff26f12d4e3242864df3e08dec4e49" + "reference": "0ca8db5a5fc9c8646244e629625ac486fa286bf2" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/sebastianbergmann/global-state/zipball/23bd5951f7ff26f12d4e3242864df3e08dec4e49", - "reference": "23bd5951f7ff26f12d4e3242864df3e08dec4e49", + "url": "https://api.github.com/repos/sebastianbergmann/global-state/zipball/0ca8db5a5fc9c8646244e629625ac486fa286bf2", + "reference": "0ca8db5a5fc9c8646244e629625ac486fa286bf2", "shasum": "" }, "require": { @@ -1593,7 +1648,7 @@ ], "support": { "issues": "https://github.com/sebastianbergmann/global-state/issues", - "source": "https://github.com/sebastianbergmann/global-state/tree/5.0.3" + "source": "https://github.com/sebastianbergmann/global-state/tree/5.0.5" }, "funding": [ { @@ -1601,7 +1656,7 @@ "type": "github" } ], - "time": "2021-06-11T13:31:12+00:00" + "time": "2022-02-14T08:28:10+00:00" }, { "name": "sebastian/lines-of-code", @@ -1892,28 +1947,28 @@ }, { "name": "sebastian/type", - "version": "2.3.4", + "version": "3.0.0", "source": { "type": "git", "url": "https://github.com/sebastianbergmann/type.git", - "reference": "b8cd8a1c753c90bc1a0f5372170e3e489136f914" + "reference": "b233b84bc4465aff7b57cf1c4bc75c86d00d6dad" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/sebastianbergmann/type/zipball/b8cd8a1c753c90bc1a0f5372170e3e489136f914", - "reference": "b8cd8a1c753c90bc1a0f5372170e3e489136f914", + "url": "https://api.github.com/repos/sebastianbergmann/type/zipball/b233b84bc4465aff7b57cf1c4bc75c86d00d6dad", + "reference": "b233b84bc4465aff7b57cf1c4bc75c86d00d6dad", "shasum": "" }, "require": { "php": ">=7.3" }, "require-dev": { - "phpunit/phpunit": "^9.3" + "phpunit/phpunit": "^9.5" }, "type": "library", "extra": { "branch-alias": { - "dev-master": "2.3-dev" + "dev-master": "3.0-dev" } }, "autoload": { @@ -1936,7 +1991,7 @@ "homepage": "https://github.com/sebastianbergmann/type", "support": { "issues": "https://github.com/sebastianbergmann/type/issues", - "source": "https://github.com/sebastianbergmann/type/tree/2.3.4" + "source": "https://github.com/sebastianbergmann/type/tree/3.0.0" }, "funding": [ { @@ -1944,7 +1999,7 @@ "type": "github" } ], - "time": "2021-06-15T12:49:02+00:00" + "time": "2022-03-15T09:54:48+00:00" }, { "name": "sebastian/version", @@ -1999,23 +2054,80 @@ ], "time": "2020-09-28T06:39:44+00:00" }, + { + "name": "silinternational/psr3-adapters", + "version": "3.0.2", + "source": { + "type": "git", + "url": "https://github.com/silinternational/psr3-adapters.git", + "reference": "9aea95d2fb5a83fcde5340c50a73b508d6daf81d" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/silinternational/psr3-adapters/zipball/9aea95d2fb5a83fcde5340c50a73b508d6daf81d", + "reference": "9aea95d2fb5a83fcde5340c50a73b508d6daf81d", + "shasum": "" + }, + "require": { + "php": "^7.2", + "psr/log": "^1.0" + }, + "require-dev": { + "monolog/monolog": "^1.22", + "phpunit/phpunit": "^9.0", + "roave/security-advisories": "dev-master", + "simplesamlphp/simplesamlphp": "^1.15.2", + "yiisoft/yii2": "^2.0" + }, + "suggest": { + "monolog/monolog": "^1.22", + "simplesamlphp/simplesamlphp": "^1.15.2", + "yiisoft/yii2": "^2.0" + }, + "type": "library", + "autoload": { + "psr-4": { + "Sil\\Psr3Adapters\\": "src/", + "Sil\\Psr3Adapters\\tests\\": "tests/" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Matt Henderson", + "email": "matt_henderson@sil.org" + } + ], + "description": "Various PSR3-compatible logging adapters.", + "support": { + "issues": "https://github.com/silinternational/psr3-adapters/issues", + "source": "https://github.com/silinternational/psr3-adapters/tree/3.0.2" + }, + "time": "2022-01-03T18:24:29+00:00" + }, { "name": "symfony/polyfill-ctype", - "version": "v1.23.0", + "version": "v1.25.0", "source": { "type": "git", "url": "https://github.com/symfony/polyfill-ctype.git", - "reference": "46cd95797e9df938fdd2b03693b5fca5e64b01ce" + "reference": "30885182c981ab175d4d034db0f6f469898070ab" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/polyfill-ctype/zipball/46cd95797e9df938fdd2b03693b5fca5e64b01ce", - "reference": "46cd95797e9df938fdd2b03693b5fca5e64b01ce", + "url": "https://api.github.com/repos/symfony/polyfill-ctype/zipball/30885182c981ab175d4d034db0f6f469898070ab", + "reference": "30885182c981ab175d4d034db0f6f469898070ab", "shasum": "" }, "require": { "php": ">=7.1" }, + "provide": { + "ext-ctype": "*" + }, "suggest": { "ext-ctype": "For best performance" }, @@ -2030,12 +2142,12 @@ } }, "autoload": { - "psr-4": { - "Symfony\\Polyfill\\Ctype\\": "" - }, "files": [ "bootstrap.php" - ] + ], + "psr-4": { + "Symfony\\Polyfill\\Ctype\\": "" + } }, "notification-url": "https://packagist.org/downloads/", "license": [ @@ -2060,7 +2172,7 @@ "portable" ], "support": { - "source": "https://github.com/symfony/polyfill-ctype/tree/v1.23.0" + "source": "https://github.com/symfony/polyfill-ctype/tree/v1.25.0" }, "funding": [ { @@ -2076,7 +2188,7 @@ "type": "tidelift" } ], - "time": "2021-02-19T12:13:01+00:00" + "time": "2021-10-20T20:35:02+00:00" }, { "name": "theseer/tokenizer", From cc1613bc4bab8e4d96b9c930178a5ce13e518b5b Mon Sep 17 00:00:00 2001 From: Mark Tompsett Date: Thu, 17 Mar 2022 14:47:19 -0400 Subject: [PATCH 03/16] Add a database base class --- SilMock/Google/Service/DbClass.php | 67 ++++++++++++++++++++++++++++++ 1 file changed, 67 insertions(+) create mode 100644 SilMock/Google/Service/DbClass.php diff --git a/SilMock/Google/Service/DbClass.php b/SilMock/Google/Service/DbClass.php new file mode 100644 index 0000000..ef979bd --- /dev/null +++ b/SilMock/Google/Service/DbClass.php @@ -0,0 +1,67 @@ +dbFile = $dbFile; + $this->dataType = $dataType; + $this->dataClass = $dataClass; + $this->logger = new Psr3EchoLogger(); + if (empty($dbFile)) { + $exception = new Exception(); + $exceptions = explode("\n", $exception->getTraceAsString()); + $previousLocationMessage = $exceptions[1]; + $this->logger->warning( + sprintf( + "Empty dbFile provided:\n%s", + $previousLocationMessage + ) + ); + } + } + + protected function getSqliteUtils(): SqliteUtils + { + return new SqliteUtils($this->dbFile); + } + + protected function getRecords(): array + { + $sqliteUtils = $this->getSqliteUtils(); + return $sqliteUtils->getData($this->dataType, $this->dataClass); + } + + protected function deleteRecordById(int $recordId) + { + $sqliteUtils = $this->getSqliteUtils(); + $sqliteUtils->deleteRecordById($recordId); + } + + protected function addRecord(string $data) + { + $sqliteUtils = $this->getSqliteUtils(); + $sqliteUtils->recordData( + $this->dataType, + $this->dataClass, + $data + ); + } +} From a315d0ffa1c1407fead5f71020a9e8991831e3d5 Mon Sep 17 00:00:00 2001 From: Mark Tompsett Date: Thu, 17 Mar 2022 14:48:42 -0400 Subject: [PATCH 04/16] Properly pass the dbFile parameter to the subclasses Add missing dbFile parameter --- SilMock/Google/Service/Gmail.php | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/SilMock/Google/Service/Gmail.php b/SilMock/Google/Service/Gmail.php index bf02f40..0f6d671 100644 --- a/SilMock/Google/Service/Gmail.php +++ b/SilMock/Google/Service/Gmail.php @@ -1,4 +1,5 @@ users_settings = new UsersSettings(); - $this->users_settings_delegates = new UsersSettingsDelegates(); - $this->users_settings_forwardingAddresses = new UsersSettingsForwardingAddresses(); + $this->users_settings = new UsersSettings($dbFile); + $this->users_settings_delegates = new UsersSettingsDelegates($dbFile); + $this->users_settings_forwardingAddresses = new UsersSettingsForwardingAddresses($dbFile); } } From 73785f520492d5fc27805725efd30b962a3d1445 Mon Sep 17 00:00:00 2001 From: Mark Tompsett Date: Thu, 17 Mar 2022 14:52:00 -0400 Subject: [PATCH 05/16] Use the new DbClass --- .../Service/Gmail/Resource/UsersSettings.php | 19 ++----- .../Gmail/Resource/UsersSettingsDelegates.php | 52 +++++++------------ .../UsersSettingsForwardingAddresses.php | 25 ++------- 3 files changed, 29 insertions(+), 67 deletions(-) diff --git a/SilMock/Google/Service/Gmail/Resource/UsersSettings.php b/SilMock/Google/Service/Gmail/Resource/UsersSettings.php index d6e0284..97edcce 100644 --- a/SilMock/Google/Service/Gmail/Resource/UsersSettings.php +++ b/SilMock/Google/Service/Gmail/Resource/UsersSettings.php @@ -4,24 +4,13 @@ use Google_Service_Gmail_ImapSettings; use Google_Service_Gmail_PopSettings; -use SilMock\DataStore\Sqlite\SqliteUtils; -use SilMock\Google\Service\Directory\ObjectUtils; -use Webmozart\Assert\Assert; +use SilMock\Google\Service\DbClass; -class UsersSettings +class UsersSettings extends DbClass { - /** @var string - The path (with file name) to the SQLite database. */ - private $dbFile; - - /** @var string - The 'type' field to use in the database. */ - private $dataType = 'gmail'; - - /** @var string - The 'class' field to use in the database */ - private $dataClass = 'users_settings'; - - public function __construct($dbFile = null) + public function __construct(?string $dbFile = null) { - $this->dbFile = $dbFile; + parent::__construct($dbFile, 'gmail', 'users_settings'); } public function updatePop($userId, Google_Service_Gmail_PopSettings $postBody, $optParams = array()) diff --git a/SilMock/Google/Service/Gmail/Resource/UsersSettingsDelegates.php b/SilMock/Google/Service/Gmail/Resource/UsersSettingsDelegates.php index 27c4663..ee190a0 100644 --- a/SilMock/Google/Service/Gmail/Resource/UsersSettingsDelegates.php +++ b/SilMock/Google/Service/Gmail/Resource/UsersSettingsDelegates.php @@ -2,27 +2,19 @@ namespace SilMock\Google\Service\Gmail\Resource; +use Google_Service_Exception; +use Google_Service_Gmail_Delegate; use Google_Service_Gmail_ListDelegatesResponse; use SilMock\DataStore\Sqlite\SqliteUtils; -use SilMock\Google\Service\Directory\ObjectUtils; -use Webmozart\Assert\Assert; +use SilMock\Google\Service\DbClass; -class UsersSettingsDelegates +class UsersSettingsDelegates extends DbClass { - /** @var string - The path (with file name) to the SQLite database. */ - private $dbFile; - - /** @var string - The 'type' field to use in the database. */ - private $dataType = 'gmail'; - - /** @var string - The 'class' field to use in the database */ - private $dataClass = 'users_settings_delegate'; - - public function __construct($dbFile = null) + public function __construct(?string $dbFile = null) { - $this->dbFile = $dbFile; + parent::__construct($dbFile, 'gmail', 'users_settings_delegate'); } - + /** * Add a delegate to the specified user account. * @@ -31,14 +23,14 @@ public function __construct($dbFile = null) * for that delegate. * @return Google_Service_Gmail_Delegate - A real * Google_Service_Gmail_Delegate instance. - * @throws \Google_Service_Exception - If something went wrong. + * @throws Google_Service_Exception - If something went wrong. */ public function create($userId, \Google_Service_Gmail_Delegate $postBody, $optParams = array()) { $this->assertIsValidUserId($userId); if ($this->hasDelegate($userId, $postBody->delegateEmail)) { - throw new \Google_Service_Exception('Already has delegate', 409); + throw new Google_Service_Exception('Already has delegate', 409); } return $this->addDelegate($userId, $postBody->delegateEmail); @@ -86,23 +78,20 @@ protected function listDelegatesFor(string $userId): array */ protected function getDelegateRecords(): array { - $sqliteUtils = $this->getSqliteUtils(); - return $sqliteUtils->getData($this->dataType, $this->dataClass); + return $this->getRecords(); } protected function addDelegate(string $userId, string $delegateEmail) { - $sqliteUtils = $this->getSqliteUtils(); - $sqliteUtils->recordData( - $this->dataType, - $this->dataClass, - json_encode([ + $data = json_encode( + [ 'primaryEmail' => $userId, 'delegateEmail' => $delegateEmail, 'verificationStatus' => 'accepted', - ]) + ] ); - + $this->addRecord($data); + return $this->get($userId, $delegateEmail); } @@ -114,14 +103,14 @@ protected function getSqliteUtils(): SqliteUtils protected function assertIsValidUserId(string $userId) { if (! $this->isValidEmailAddress($userId)) { - throw new \Google_Service_Exception('Invalid userId: ' . $userId, 400); + throw new Google_Service_Exception('Invalid userId: ' . $userId, 400); } } protected function assertIsValidDelegateEmail($delegateEmail) { if (! $this->isValidEmailAddress($delegateEmail)) { - throw new \Google_Service_Exception('Invalid delegate: ' . $delegateEmail, 400); + throw new Google_Service_Exception('Invalid delegate: ' . $delegateEmail, 400); } } @@ -149,7 +138,7 @@ public function get($userId, $delegateEmail, $optParams = array()) return $matchingRecord; } } - throw new \Google_Service_Exception('Invalid delegate', 404); + throw new Google_Service_Exception('Invalid delegate', 404); } public function delete($userId, $delegateEmail, $optParams = array()) @@ -163,13 +152,12 @@ public function delete($userId, $delegateEmail, $optParams = array()) return; } } - throw new \Google_Service_Exception('Invalid delegate', 404); + throw new Google_Service_Exception('Invalid delegate', 404); } protected function removeDelegate(int $recordId) { - $sqliteUtils = $this->getSqliteUtils(); - $sqliteUtils->deleteRecordById($recordId); + $this->deleteRecordById($recordId); } public function listUsersSettingsDelegates($userId, $optParams = array()) diff --git a/SilMock/Google/Service/Gmail/Resource/UsersSettingsForwardingAddresses.php b/SilMock/Google/Service/Gmail/Resource/UsersSettingsForwardingAddresses.php index ee4e769..0867b3f 100644 --- a/SilMock/Google/Service/Gmail/Resource/UsersSettingsForwardingAddresses.php +++ b/SilMock/Google/Service/Gmail/Resource/UsersSettingsForwardingAddresses.php @@ -4,22 +4,13 @@ use Google_Service_Exception; use Google_Service_Gmail_ListForwardingAddressesResponse; -use SilMock\DataStore\Sqlite\SqliteUtils; +use SilMock\Google\Service\DbClass; -class UsersSettingsForwardingAddresses +class UsersSettingsForwardingAddresses extends DbClass { - /** @var string - The path (with file name) to the SQLite database. */ - private $dbFile; - - /** @var string - The 'type' field to use in the database. */ - private $dataType = 'gmail'; - - /** @var string - The 'class' field to use in the database */ - private $dataClass = 'users_settings_forwardingAddresses'; - - public function __construct($dbFile = null) + public function __construct(?string $dbFile = null) { - $this->dbFile = $dbFile; + parent::__construct($dbFile, 'gmail', 'users_settings_forwardingAddresses'); } public function listUsersSettingsForwardingAddresses($userId, $optParams = array()) @@ -29,11 +20,6 @@ public function listUsersSettingsForwardingAddresses($userId, $optParams = array )); } - protected function getSqliteUtils(): SqliteUtils - { - return new SqliteUtils($this->dbFile); - } - protected function assertIsValidUserId(string $userId) { if (! $this->isValidEmailAddress($userId)) { @@ -82,7 +68,6 @@ protected function listForwardingAddressesFor(string $userId): array protected function removeForwardingAddress($recordId) { - $sqliteUtils = $this->getSqliteUtils(); - $sqliteUtils->deleteRecordById($recordId); + $this->deleteRecordById($recordId); } } From 4911b8e8783edd3ee6ff2df2574aceb44b2d965a Mon Sep 17 00:00:00 2001 From: Mark Tompsett Date: Thu, 17 Mar 2022 14:52:30 -0400 Subject: [PATCH 06/16] Pass the dataFile name when instantiating the mock object --- .../Gmail/Resource/UsersSettingsForwardingAddressesTest.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/SilMock/tests/Google/Service/Gmail/Resource/UsersSettingsForwardingAddressesTest.php b/SilMock/tests/Google/Service/Gmail/Resource/UsersSettingsForwardingAddressesTest.php index 40496da..84b181a 100644 --- a/SilMock/tests/Google/Service/Gmail/Resource/UsersSettingsForwardingAddressesTest.php +++ b/SilMock/tests/Google/Service/Gmail/Resource/UsersSettingsForwardingAddressesTest.php @@ -30,7 +30,7 @@ protected function tearDown(): void public function testListUsersSettingsForwardingAddresses() { $accountEmail = 'john_smith@example.org'; - $forwardingAddresses = new UsersSettingsForwardingAddresses(); + $forwardingAddresses = new UsersSettingsForwardingAddresses($this->dataFile); $result = $forwardingAddresses->listUsersSettingsForwardingAddresses($accountEmail); // Because this is totally a skeleton. Assert::assertEmpty($result); @@ -39,7 +39,7 @@ public function testListUsersSettingsForwardingAddresses() public function testDelete() { $accountEmail = 'john_smith@example.org'; - $forwardingAddresses = new UsersSettingsForwardingAddresses(); + $forwardingAddresses = new UsersSettingsForwardingAddresses($this->dataFile); $forwardingAddresses->delete($accountEmail, $accountEmail); Assert::assertTrue(true, 'Because a skeleton should not explode.'); } From 4424603f62684087098a5b37cc058c58045f161d Mon Sep 17 00:00:00 2001 From: Mark Tompsett Date: Thu, 17 Mar 2022 16:21:23 -0400 Subject: [PATCH 07/16] PSR-12 cleanup on tests --- .../Directory/VerificationCodesTest.php | 4 +- .../Resource/UsersSettingsDelegatesTest.php | 5 +- .../Google/Service/GoogleFixturesTest.php | 51 +++--- SilMock/tests/Google/Service/SampleUser.php | 2 +- SilMock/tests/Sqlite/SqliteUtilsTest.php | 164 ++++++++++-------- SilMock/tests/bootstrap.php | 17 +- 6 files changed, 137 insertions(+), 106 deletions(-) diff --git a/SilMock/tests/Google/Service/Directory/VerificationCodesTest.php b/SilMock/tests/Google/Service/Directory/VerificationCodesTest.php index 85842d5..dd19888 100644 --- a/SilMock/tests/Google/Service/Directory/VerificationCodesTest.php +++ b/SilMock/tests/Google/Service/Directory/VerificationCodesTest.php @@ -10,6 +10,7 @@ class VerificationCodesTest extends TestCase { use SampleUser; + public $dataFile = DATAFILE2; public function testVerificationCodesGenerateAndList() @@ -31,5 +32,4 @@ public function testVerificationCodesGenerateAndList() 'Expecting Google_Service_Directory_VerificationCodes class' ); } - -} +} diff --git a/SilMock/tests/Google/Service/Gmail/Resource/UsersSettingsDelegatesTest.php b/SilMock/tests/Google/Service/Gmail/Resource/UsersSettingsDelegatesTest.php index f599e11..d779ce7 100644 --- a/SilMock/tests/Google/Service/Gmail/Resource/UsersSettingsDelegatesTest.php +++ b/SilMock/tests/Google/Service/Gmail/Resource/UsersSettingsDelegatesTest.php @@ -2,6 +2,7 @@ namespace SilMock\tests\Google\Service\Gmail\Resource; +use Google_Service_Gmail_ListDelegatesResponse; use PHPUnit\Framework\Assert; use PHPUnit\Framework\TestCase; use Google_Service_Gmail_Delegate; @@ -73,9 +74,9 @@ private function delegateAccessToAccountBy( ); } - private function getDelegatesForAccount(string $emailAddress) + private function getDelegatesForAccount(string $emailAddress): Google_Service_Gmail_ListDelegatesResponse { $userSettingsDelegates = new UsersSettingsDelegates($this->dataFile); return $userSettingsDelegates->listUsersSettingsDelegates($emailAddress); } -} +} diff --git a/SilMock/tests/Google/Service/GoogleFixturesTest.php b/SilMock/tests/Google/Service/GoogleFixturesTest.php index d10442d..fa436e3 100644 --- a/SilMock/tests/Google/Service/GoogleFixturesTest.php +++ b/SilMock/tests/Google/Service/GoogleFixturesTest.php @@ -17,37 +17,41 @@ public function testAddFixtures() $fixturesClass = new GoogleFixtures($this->dataFile); - $fixtures = array( - array('directory', 'user', 'user1 test data'), - array('directory', 'users_alias', 'users_alias2 test data'), - array('app_engine', 'webapp', 'webapp3 test data'), - array('directory', 'user', 'user4 test data'), - ); + $fixtures = [ + ['directory', 'user', 'user1 test data'], + ['directory', 'users_alias', 'users_alias2 test data'], + ['app_engine', 'webapp', 'webapp3 test data'], + ['directory', 'user', 'user4 test data'], + ]; $fixturesClass->addFixtures($fixtures); - $expected = array( - array('id' => 1, - 'type' => 'directory', - 'class' => 'user', - 'data' => 'user1 test data', - ), - array('id' => 2, + $expected = [ + [ + 'id' => 1, + 'type' => 'directory', + 'class' => 'user', + 'data' => 'user1 test data', + ], + [ + 'id' => 2, 'type' => 'directory', 'class' => 'users_alias', 'data' => 'users_alias2 test data', - ), - array('id' => 3, + ], + [ + 'id' => 3, 'type' => 'app_engine', 'class' => 'webapp', 'data' => 'webapp3 test data', - ), - array('id' => 4, + ], + [ + 'id' => 4, 'type' => 'directory', 'class' => 'user', 'data' => 'user4 test data', - ), - ); + ], + ]; $results = $sqliteClass->getData('', ''); $msg = " *** Mismatching fixtures arrays"; @@ -58,19 +62,16 @@ public function testRemoveAllFixtures() { $fixturesClass = new GoogleFixtures($this->dataFile); - $fixtures = array( - array('directory', 'user', 'user1 test data'), - ); + $fixtures = [ ['directory', 'user', 'user1 test data'] ]; $fixturesClass->addFixtures($fixtures); $fixturesClass->removeAllFixtures(); $sqliteClass = new SqliteUtils($this->dataFile); - $results = $sqliteClass->getData('',''); + $results = $sqliteClass->getData('', ''); $expected = array(); $msg = " *** Mismatching fixtures arrays"; $this->assertEquals($expected, $results, $msg); } - -} \ No newline at end of file +} diff --git a/SilMock/tests/Google/Service/SampleUser.php b/SilMock/tests/Google/Service/SampleUser.php index 048b45f..04b9aca 100644 --- a/SilMock/tests/Google/Service/SampleUser.php +++ b/SilMock/tests/Google/Service/SampleUser.php @@ -38,4 +38,4 @@ public function setupSampleUser(string $dataFile, bool $withAliases = false): ?G $newDir = new Directory('anyclient', $dataFile); return $newDir->users->insert($newUser); } -} \ No newline at end of file +} diff --git a/SilMock/tests/Sqlite/SqliteUtilsTest.php b/SilMock/tests/Sqlite/SqliteUtilsTest.php index be62d47..a195159 100644 --- a/SilMock/tests/Sqlite/SqliteUtilsTest.php +++ b/SilMock/tests/Sqlite/SqliteUtilsTest.php @@ -7,8 +7,8 @@ class SqliteUtilsTest extends TestCase { - public $dataFile = DATAFILE1; - public const verificationRecordData = '{"primaryEmail":"user_test1@sil.org","data":{"etag":null,"kind":null,"items":[{"etag":null,"kind":null,"userId":null,"verificationCode":59837946},{"etag":null,"kind":null,"userId":null,"verificationCode":70637639},{"etag":null,"kind":null,"userId":null,"verificationCode":28377580},{"etag":null,"kind":null,"userId":null,"verificationCode":50819149},{"etag":null,"kind":null,"userId":null,"verificationCode":91732989},{"etag":null,"kind":null,"userId":null,"verificationCode":90318716},{"etag":null,"kind":null,"userId":null,"verificationCode":40781363},{"etag":null,"kind":null,"userId":null,"verificationCode":85614013},{"etag":null,"kind":null,"userId":null,"verificationCode":37077320},{"etag":null,"kind":null,"userId":null,"verificationCode":68994617}]}}'; + public string $dataFile = DATAFILE1; + public const VERIFICATION_RECORD_DATA = '{"primaryEmail":"user_test1@sil.org","data":{"etag":null,"kind":null,"items":[{"etag":null,"kind":null,"userId":null,"verificationCode":59837946},{"etag":null,"kind":null,"userId":null,"verificationCode":70637639},{"etag":null,"kind":null,"userId":null,"verificationCode":28377580},{"etag":null,"kind":null,"userId":null,"verificationCode":50819149},{"etag":null,"kind":null,"userId":null,"verificationCode":91732989},{"etag":null,"kind":null,"userId":null,"verificationCode":90318716},{"etag":null,"kind":null,"userId":null,"verificationCode":40781363},{"etag":null,"kind":null,"userId":null,"verificationCode":85614013},{"etag":null,"kind":null,"userId":null,"verificationCode":37077320},{"etag":null,"kind":null,"userId":null,"verificationCode":68994617}]}}'; public function testRecordData() { @@ -16,32 +16,50 @@ public function testRecordData() $newSql = new SqliteUtils($this->dataFile); $newSql->createDbStructureAsNecessary(); - $results = $newSql->recordData('directory', 'user', - 'test data'); + $results = $newSql->recordData( + 'directory', + 'user', + 'test data' + ); $msg = " *** Expected to add data successfully."; $this->assertTrue($results, $msg); } - public function loadData() + public function loadData(): SqliteUtils { file_put_contents($this->dataFile, ''); $newSql = new SqliteUtils($this->dataFile); $newSql->createDbStructureAsNecessary(); - $results = $newSql->recordData('directory', 'user', - '{"primaryEmail":"user_test1@sil.org","id":1,"password":"testPass1"}'); - $results = $newSql->recordData('directory', 'users_alias', - '{"primaryEmail":"user_test1@sil.org","alias":"users_alias2@sil.org"}'); - $results = $newSql->recordData('app_engine', 'webapp', - 'webapp3 test data'); - $results = $newSql->recordData('directory', 'user', - '{"primaryEmail":"user_test4@sil.org","id":4,"password":"testPass4"}'); - $results = $newSql->recordData('directory', 'users_alias', - '{"primaryEmail":"user_test1@sil.org","alias":"users_alias5@sil.org"}'); - $results = $newSql->recordData( + $newSql->recordData( + 'directory', + 'user', + '{"primaryEmail":"user_test1@sil.org","id":1,"password":"testPass1"}' + ); + $newSql->recordData( + 'directory', + 'users_alias', + '{"primaryEmail":"user_test1@sil.org","alias":"users_alias2@sil.org"}' + ); + $newSql->recordData( + 'app_engine', + 'webapp', + 'webapp3 test data' + ); + $newSql->recordData( + 'directory', + 'user', + '{"primaryEmail":"user_test4@sil.org","id":4,"password":"testPass4"}' + ); + $newSql->recordData( + 'directory', + 'users_alias', + '{"primaryEmail":"user_test1@sil.org","alias":"users_alias5@sil.org"}' + ); + $newSql->recordData( 'directory', 'verification_codes', - self::verificationRecordData + self::VERIFICATION_RECORD_DATA ); return $newSql; @@ -85,7 +103,7 @@ public function testGetData_All() 'id' => '6', 'type' => 'directory', 'class' => 'verification_codes', - 'data' => self::verificationRecordData, + 'data' => self::VERIFICATION_RECORD_DATA, ) ); $msg = " *** Mismatched data results for all data."; @@ -125,7 +143,7 @@ public function testGetData_Directory() 'id' => '6', 'type' => 'directory', 'class' => 'verification_codes', - 'data' => self::verificationRecordData, + 'data' => self::VERIFICATION_RECORD_DATA, ) ); $msg = " *** Mismatched data results for directory data."; @@ -192,14 +210,18 @@ public function testGetRecordByDataKey_DirectoryUserId() public function testGetRecordByDataKey_DirectoryUserPrimaryEmail() { $newSql = $this->loadData(); - $results = $newSql->getRecordByDataKey('directory', 'user', - 'primaryEmail', 'user_test1@sil.org'); - $expected = array('id' => '1', + $results = $newSql->getRecordByDataKey( + 'directory', + 'user', + 'primaryEmail', + 'user_test1@sil.org' + ); + $expected = [ + 'id' => '1', 'type' => 'directory', 'class' => 'user', - 'data' => '{"primaryEmail":"user_test1@sil.org",' . - '"id":1,"password":"testPass1"}', - ); + 'data' => '{"primaryEmail":"user_test1@sil.org","id":1,"password":"testPass1"}', + ]; $msg = " *** Mismatched data results for user data."; $this->assertEquals($expected, $results, $msg); } @@ -207,22 +229,26 @@ public function testGetRecordByDataKey_DirectoryUserPrimaryEmail() public function testGetAllRecordsByDataKey_DirectoryUsersAliasPrimaryEmail() { $newSql = $this->loadData(); - $results = $newSql->getAllRecordsByDataKey('directory', 'users_alias', - 'primaryEmail', 'user_test1@sil.org'); - $expected = array( - array('id' => '2', - 'type' => 'directory', - 'class' => 'users_alias', - 'data' => '{"primaryEmail":"user_test1@sil.org",' . - '"alias":"users_alias2@sil.org"}', - ), - array('id' => '5', - 'type' => 'directory', - 'class' => 'users_alias', - 'data' => '{"primaryEmail":"user_test1@sil.org",' . - '"alias":"users_alias5@sil.org"}', - ), + $results = $newSql->getAllRecordsByDataKey( + 'directory', + 'users_alias', + 'primaryEmail', + 'user_test1@sil.org' ); + $expected = [ + [ + 'id' => '2', + 'type' => 'directory', + 'class' => 'users_alias', + 'data' => '{"primaryEmail":"user_test1@sil.org","alias":"users_alias2@sil.org"}', + ], + [ + 'id' => '5', + 'type' => 'directory', + 'class' => 'users_alias', + 'data' => '{"primaryEmail":"user_test1@sil.org","alias":"users_alias5@sil.org"}', + ], + ]; $msg = " *** Mismatched data results for user data."; $this->assertEquals($expected, $results, $msg); } @@ -243,37 +269,38 @@ public function testDeleteRecordById() $newSql->deleteRecordById(2); $results = $newSql->getData('', ''); - $expected = array( - array('id' => '1', + $expected = [ + [ + 'id' => '1', 'type' => 'directory', 'class' => 'user', - 'data' => '{"primaryEmail":"user_test1@sil.org",' . - '"id":1,"password":"testPass1"}', - ), - array('id' => '3', + 'data' => '{"primaryEmail":"user_test1@sil.org","id":1,"password":"testPass1"}', + ], + [ + 'id' => '3', 'type' => 'app_engine', 'class' => 'webapp', 'data' => 'webapp3 test data', - ), - array('id' => '4', + ], + [ + 'id' => '4', 'type' => 'directory', 'class' => 'user', - 'data' => '{"primaryEmail":"user_test4@sil.org",' . - '"id":4,"password":"testPass4"}', - ), - array('id' => '5', + 'data' => '{"primaryEmail":"user_test4@sil.org","id":4,"password":"testPass4"}', + ], + [ + 'id' => '5', 'type' => 'directory', 'class' => 'users_alias', - 'data' => '{"primaryEmail":"user_test1@sil.org",' . - '"alias":"users_alias5@sil.org"}', - ), - array( + 'data' => '{"primaryEmail":"user_test1@sil.org","alias":"users_alias5@sil.org"}', + ], + [ 'id' => '6', 'type' => 'directory', 'class' => 'verification_codes', - 'data' => self::verificationRecordData, - ) - ); + 'data' => self::VERIFICATION_RECORD_DATA, + ] + ]; $msg = " *** Mismatched data results for remaining data."; $this->assertEquals($expected, $results, $msg); } @@ -284,20 +311,21 @@ public function testDeleteDataByEmail() $newSql->deleteDataByEmail('directory','', 'user_test1@sil.org'); $results = $newSql->getData('', ''); - $expected = array( - array('id' => '3', + $expected = [ + [ + 'id' => '3', 'type' => 'app_engine', 'class' => 'webapp', 'data' => 'webapp3 test data', - ), - array('id' => '4', + ], + [ + 'id' => '4', 'type' => 'directory', 'class' => 'user', - 'data' => '{"primaryEmail":"user_test4@sil.org",' . - '"id":4,"password":"testPass4"}', - ), - ); + 'data' => '{"primaryEmail":"user_test4@sil.org","id":4,"password":"testPass4"}', + ], + ]; $msg = " *** Mismatched data results for remaining data."; $this->assertEquals($expected, $results, $msg); } -} \ No newline at end of file +} diff --git a/SilMock/tests/bootstrap.php b/SilMock/tests/bootstrap.php index 22364cc..79ce727 100644 --- a/SilMock/tests/bootstrap.php +++ b/SilMock/tests/bootstrap.php @@ -1,25 +1,26 @@ Date: Thu, 17 Mar 2022 16:24:49 -0400 Subject: [PATCH 08/16] Clean up on GoogleFixtures --- SilMock/Google/Service/GoogleFixtures.php | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/SilMock/Google/Service/GoogleFixtures.php b/SilMock/Google/Service/GoogleFixtures.php index bd022f3..1abcd42 100644 --- a/SilMock/Google/Service/GoogleFixtures.php +++ b/SilMock/Google/Service/GoogleFixtures.php @@ -1,10 +1,11 @@ _dbFile = $dbFile; } @@ -48,5 +49,4 @@ public function removeAllFixtures() $newSqlite = new SqliteUtils($this->_dbFile); $newSqlite->deleteAllData(); } - -} \ No newline at end of file +} From e32c74432362117cc577ec1701f20084bd29cee6 Mon Sep 17 00:00:00 2001 From: Mark Tompsett Date: Thu, 17 Mar 2022 16:25:07 -0400 Subject: [PATCH 09/16] PHPDoc and PSR12 cleanup on Directory --- SilMock/Google/Service/Directory.php | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/SilMock/Google/Service/Directory.php b/SilMock/Google/Service/Directory.php index 5221bef..5690494 100644 --- a/SilMock/Google/Service/Directory.php +++ b/SilMock/Google/Service/Directory.php @@ -1,4 +1,5 @@ asps = new Asps($dbFile); $this->tokens = new Tokens($dbFile); From e6a1f329f1083af09206fcd58ea4e4b4b9d5c652 Mon Sep 17 00:00:00 2001 From: Mark Tompsett Date: Thu, 17 Mar 2022 16:26:06 -0400 Subject: [PATCH 10/16] Clean up conditionals using ??, and PSR-12 cleanup --- SilMock/DataStore/Sqlite/SqliteUtils.php | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/SilMock/DataStore/Sqlite/SqliteUtils.php b/SilMock/DataStore/Sqlite/SqliteUtils.php index 3a324ee..0699900 100644 --- a/SilMock/DataStore/Sqlite/SqliteUtils.php +++ b/SilMock/DataStore/Sqlite/SqliteUtils.php @@ -1,4 +1,5 @@ Date: Thu, 17 Mar 2022 16:26:48 -0400 Subject: [PATCH 11/16] Cleanup Tokens and add delete() --- SilMock/Google/Service/Directory/Tokens.php | 66 ++++++++++++++++----- 1 file changed, 51 insertions(+), 15 deletions(-) diff --git a/SilMock/Google/Service/Directory/Tokens.php b/SilMock/Google/Service/Directory/Tokens.php index 20dac59..8977c3d 100644 --- a/SilMock/Google/Service/Directory/Tokens.php +++ b/SilMock/Google/Service/Directory/Tokens.php @@ -2,28 +2,64 @@ namespace SilMock\Google\Service\Directory; +use Google_Service_Directory_Token; use Google_Service_Directory_Tokens; +use Google_Service_Exception; +use SilMock\Google\Service\DbClass; -class Tokens +class Tokens extends DbClass { - /** @var string - The path (with file name) to the SQLite database. */ - private $dbFile; - - /** @var string - The 'type' field to use in the database. */ - private $dataType = 'directory'; - - /** @var string - The 'class' field to use in the database */ - private $dataClass = 'tokens'; - public function __construct($dbFile = null) { - $this->dbFile = $dbFile; + parent::__construct($dbFile, 'directory', 'tokens'); } - public function listTokens($userKey, $optParams = array()) + public function listTokens($userKey, $optParams = []): Google_Service_Directory_Tokens + { + return new Google_Service_Directory_Tokens([ 'items' => [] ]); + } + + /** + * @throws Google_Service_Exception + */ + public function delete($userKey, $clientId) + { + $this->assertIsValidUserKey($userKey); + + foreach ($this->listTokensFor($userKey) as $recordId => $token) { + /** @var Google_Service_Directory_Token $token */ + if ($token->clientId === $clientId) { + $this->removeToken($recordId); + return; + } + } + } + + protected function assertIsValidUserKey(string $userId) + { + if (! $this->isValidEmailAddress($userId)) { + throw new Google_Service_Exception('Invalid userId: ' . $userId, 400); + } + } + + /** + * Determine whether the given string is a valid email address. + * + * @param string $email The email address to check. + * @return bool Whether the string is a valid email address. + */ + protected function isValidEmailAddress(string $email): bool + { + return (filter_var($email, FILTER_VALIDATE_EMAIL) !== false); + } + + protected function listTokensFor(string $userId): array + { + return []; + } + + protected function removeToken($recordId) { - return new Google_Service_Directory_Tokens(array( - 'items' => array(), - )); + $this->deleteRecordById($recordId); } } From 242e7115c06cfbf31d4efa6152e863b973d88373 Mon Sep 17 00:00:00 2001 From: Mark Tompsett Date: Thu, 17 Mar 2022 17:22:33 -0400 Subject: [PATCH 12/16] Extend all Directory subclass mocks, and fix test to match --- SilMock/Google/Service/Directory/Asps.php | 14 +--- .../Directory/UsersAliasesResource.php | 65 +++++++++---------- .../Service/Directory/UsersResource.php | 47 +++++++------- .../Directory/VerificationCodesResource.php | 42 ++++++------ .../tests/Google/Service/DirectoryTest.php | 7 +- 5 files changed, 83 insertions(+), 92 deletions(-) diff --git a/SilMock/Google/Service/Directory/Asps.php b/SilMock/Google/Service/Directory/Asps.php index 73f43c4..4bb712e 100644 --- a/SilMock/Google/Service/Directory/Asps.php +++ b/SilMock/Google/Service/Directory/Asps.php @@ -3,21 +3,13 @@ namespace SilMock\Google\Service\Directory; use Google_Service_Directory_Asps; +use SilMock\Google\Service\DbClass; -class Asps +class Asps extends DbClass { - /** @var string - The path (with file name) to the SQLite database. */ - private $dbFile; - - /** @var string - The 'type' field to use in the database. */ - private $dataType = 'directory'; - - /** @var string - The 'class' field to use in the database */ - private $dataClass = 'asps'; - public function __construct($dbFile = null) { - $this->dbFile = $dbFile; + parent::__construct($dbFile, 'directory', 'asps'); } public function listAsps($userKey, $optParams = array()) diff --git a/SilMock/Google/Service/Directory/UsersAliasesResource.php b/SilMock/Google/Service/Directory/UsersAliasesResource.php index e1ac064..ea68180 100644 --- a/SilMock/Google/Service/Directory/UsersAliasesResource.php +++ b/SilMock/Google/Service/Directory/UsersAliasesResource.php @@ -2,19 +2,18 @@ namespace SilMock\Google\Service\Directory; +use Exception; +use Google_Service_Directory_Alias as Alias; +use Google_Service_Directory_Aliases; use SilMock\DataStore\Sqlite\SqliteUtils; +use SilMock\Google\Service\DbClass; +use SilMock\Google\Service\Directory; -class UsersAliasesResource +class UsersAliasesResource extends DbClass { - - private $_dbFile; // string for the path (with file name) for the Sqlite database - private $_dataType = 'directory'; // string to put in the 'type' field in the database - private $_dataClass = 'users_alias'; // string to put in the 'class' field in the database - - public function __construct($dbFile = null) { - $this->_dbFile = $dbFile; + parent::__construct($dbFile, 'directory', 'users_alias'); } /** @@ -23,7 +22,7 @@ public function __construct($dbFile = null) * @param string $userKey The email or immutable Id of the user * @param string $alias The alias to be removed * @return true|null depending on if an alias was deleted - * @throws \Exception with code 201407101645 + * @throws Exception with code 201407101645 */ public function delete($userKey, $alias) { @@ -34,18 +33,18 @@ public function delete($userKey, $alias) } // ensure that user exists in db - $dir = new \SilMock\Google\Service\Directory('anything', $this->_dbFile); + $dir = new Directory('anything', $this->dbFile); $matchingUsers = $dir->users->get($userKey); if ($matchingUsers === null) { - throw new \Exception("Account doesn't exist: " . $userKey, 201407101645); + throw new Exception("Account doesn't exist: " . $userKey, 201407101645); } // Get all the aliases for that user - $sqliteUtils = new SqliteUtils($this->_dbFile); + $sqliteUtils = new SqliteUtils($this->dbFile); $aliases = $sqliteUtils->getAllRecordsByDataKey( - $this->_dataType, - $this->_dataClass, + $this->dataType, + $this->dataClass, $key, $userKey ); @@ -73,7 +72,7 @@ public function delete($userKey, $alias) * @param string $userKey The email or immutable Id of the user * @param Alias $postBody The array/object with the data for that alias * @return Alias - a real Google_Service_Directory_Alias instance - * @throws \Exception with code 201407110830 if a matching user is not found. + * @throws Exception with code 201407110830 if a matching user is not found. */ public function insert($userKey, $postBody) { @@ -84,11 +83,11 @@ public function insert($userKey, $postBody) } // ensure that user exists in db - $dir = new \SilMock\Google\Service\Directory('anything', $this->_dbFile); + $dir = new Directory('anything', $this->dbFile); $matchingUsers = $dir->users->get($userKey); if ($matchingUsers === null) { - throw new \Exception("Account doesn't exist: " . $userKey, 201407110830); + throw new Exception("Account doesn't exist: " . $userKey, 201407110830); } if ($postBody->$key === null) { @@ -107,19 +106,19 @@ public function insert($userKey, $postBody) public function insertAssumingUserExists($postBody) { $entryData = json_encode(get_object_vars($postBody)); - $sqliteUtils = new SqliteUtils($this->_dbFile); + $sqliteUtils = new SqliteUtils($this->dbFile); $sqliteUtils->recordData( - $this->_dataType, - $this->_dataClass, + $this->dataType, + $this->dataClass, $entryData ); - $allAliases = $sqliteUtils->getData($this->_dataType, $this->_dataClass); + $allAliases = $sqliteUtils->getData($this->dataType, $this->dataClass); if (! $allAliases) { return null; } - $newAlias = new \Google_Service_Directory_Alias(); + $newAlias = new Alias(); ObjectUtils::initialize($newAlias, $postBody); return $newAlias; @@ -131,10 +130,10 @@ public function insertAssumingUserExists($postBody) * instances for that user * * @param string $userKey - The Email or immutable Id of the user - * @return a real Google_Service_Directory_Aliases instance - * @throws \Exception with code 201407101420 if a matching user is not found. + * @return Google_Service_Directory_Aliases|null + * @throws Exception with code 201407101420 if a matching user is not found. */ - public function listUsersAliases($userKey) + public function listUsersAliases($userKey): ?Google_Service_Directory_Aliases { // If the $userKey is not an email address, it must be an id $key = 'primaryEmail'; @@ -142,11 +141,11 @@ public function listUsersAliases($userKey) $key = 'id'; } // ensure that user exists in db - $dir = new \SilMock\Google\Service\Directory('anything', $this->_dbFile); + $dir = new Directory('anything', $this->dbFile); $matchingUsers = $dir->users->get($userKey); if ($matchingUsers === null) { - throw new \Exception("Account doesn't exist: " . $userKey, 201407101420); + throw new Exception("Account doesn't exist: " . $userKey, 201407101420); } $foundAliases = $this->fetchAliasesByUser($key, $userKey); @@ -161,14 +160,14 @@ public function listUsersAliases($userKey) * * @param string $keyType - "Email" or "Id" * @param string $userKey - The Email or immutable Id of the user - * @return null|Google_Service_Directory_Aliases + * @return Google_Service_Directory_Aliases|null */ - public function fetchAliasesByUser($keyType, $userKey) + public function fetchAliasesByUser($keyType, $userKey): ?Google_Service_Directory_Aliases { - $sqliteUtils = new SqliteUtils($this->_dbFile); + $sqliteUtils = new SqliteUtils($this->dbFile); $aliases = $sqliteUtils->getAllRecordsByDataKey( - $this->_dataType, - $this->_dataClass, + $this->dataType, + $this->dataClass, $keyType, $userKey ); @@ -180,7 +179,7 @@ public function fetchAliasesByUser($keyType, $userKey) $foundAliases = array(); foreach ($aliases as $nextAlias) { - $newAlias = new \Google_Service_Directory_Alias(); + $newAlias = new Alias(); ObjectUtils::initialize($newAlias, json_decode($nextAlias['data'], true)); $foundAliases[] = $newAlias; diff --git a/SilMock/Google/Service/Directory/UsersResource.php b/SilMock/Google/Service/Directory/UsersResource.php index 5efc882..98da575 100644 --- a/SilMock/Google/Service/Directory/UsersResource.php +++ b/SilMock/Google/Service/Directory/UsersResource.php @@ -2,18 +2,17 @@ namespace SilMock\Google\Service\Directory; +use Google_Service_Directory_Alias as Alias; +use Google_Service_Directory_Aliases; use SilMock\DataStore\Sqlite\SqliteUtils; use Google_Service_Directory_User; +use SilMock\Google\Service\DbClass; -class UsersResource +class UsersResource extends DbClass { - private $_dbFile; // path (with file name) for the Sqlite database - private $_dataType = 'directory'; // string to put in the 'type' field in the database - private $_dataClass = 'user'; // string to put in the 'class' field in the database - public function __construct($dbFile = null) { - $this->_dbFile = $dbFile; + parent::__construct($dbFile, 'directory', 'user'); } /** @@ -30,7 +29,7 @@ public function delete($userKey) return null; } - $sqliteUtils = new SqliteUtils($this->_dbFile); + $sqliteUtils = new SqliteUtils($this->dbFile); $sqliteUtils->deleteRecordById($userEntry['id']); return true; } @@ -81,7 +80,7 @@ public function get($userKey) * @param $userKey * @return Google_Service_Directory_Aliases|null */ - protected function getAliasesForUser($userKey) + protected function getAliasesForUser($userKey): ?Google_Service_Directory_Aliases { // If the $userKey is not an email address, then it's an id. $key = 'primaryEmail'; @@ -89,7 +88,7 @@ protected function getAliasesForUser($userKey) $key = 'id'; } - $usersAliases = new UsersAliasesResource($this->_dbFile); + $usersAliases = new UsersAliasesResource($this->dbFile); return $usersAliases->fetchAliasesByUser($key, $userKey); } @@ -141,8 +140,8 @@ protected function getDbUserByAlias($userKey) protected function getAllDbUsers() { - $sqliteUtils = new SqliteUtils($this->_dbFile); - return $sqliteUtils->getData($this->_dataType, $this->_dataClass); + $sqliteUtils = new SqliteUtils($this->dbFile); + return $sqliteUtils->getData($this->dataType, $this->dataClass); } /** @@ -187,12 +186,12 @@ public function insert($postBody) $userData = json_encode($newUser); // record the user in the database - $sqliteUtils = new SqliteUtils($this->_dbFile); - $sqliteUtils->recordData($this->_dataType, $this->_dataClass, $userData); + $sqliteUtils = new SqliteUtils($this->dbFile); + $sqliteUtils->recordData($this->dataType, $this->dataClass, $userData); // record the user's aliases in the database if ($postBody->aliases) { - $usersAliases = new UsersAliasesResource($this->_dbFile); + $usersAliases = new UsersAliasesResource($this->dbFile); foreach ($postBody->aliases as $alias) { $newAlias = new Alias(); @@ -240,7 +239,7 @@ public function update($userKey, $postBody) } // Delete the user's old aliases before adding the new ones - $usersAliases = new UsersAliasesResource($this->_dbFile); + $usersAliases = new UsersAliasesResource($this->dbFile); $aliasesObject = $usersAliases->listUsersAliases($userKey); if ($aliasesObject && isset($aliasesObject['aliases'])) { @@ -249,7 +248,7 @@ public function update($userKey, $postBody) } } - $sqliteUtils = new SqliteUtils($this->_dbFile); + $sqliteUtils = new SqliteUtils($this->dbFile); $sqliteUtils->updateRecordById($userEntry['id'], json_encode($dbUserProps)); // Save the user's aliases @@ -281,10 +280,10 @@ private function getDbUser(string $userKey) $key = 'id'; } - $sqliteUtils = new SqliteUtils($this->_dbFile); + $sqliteUtils = new SqliteUtils($this->dbFile); return $sqliteUtils->getRecordByDataKey( - $this->_dataType, - $this->_dataClass, + $this->dataType, + $this->dataClass, $key, $userKey ); @@ -318,8 +317,8 @@ public function listUsers($parameters = []) $parameters['query'] = ''; } $parameters['query'] = urldecode($parameters['query']); - $sqliteUtils = new SqliteUtils($this->_dbFile); - $allData = $sqliteUtils->getData($this->_dataType, $this->_dataClass); + $sqliteUtils = new SqliteUtils($this->dbFile); + $allData = $sqliteUtils->getData($this->dataType, $this->dataClass); foreach ($allData as $userRecord) { $userEntry = json_decode($userRecord['data'], true); if ($this->doesUserMatch($userEntry, $parameters['query'])) { @@ -394,9 +393,9 @@ private function doesUserMatch($entry, $query = '') if (! is_string($checkValue)) { throw new \Exception(sprintf( "Expecting a string.\nGot Entry: %s\nGot Field: %s\nGot VALUE: %s", - var_dump($entry), - var_dump($field), - var_dump($checkValue) + var_export($entry, true), + var_export($field, true), + var_export($checkValue, true) )); } if (mb_strpos($checkValue, $value) === 0) { diff --git a/SilMock/Google/Service/Directory/VerificationCodesResource.php b/SilMock/Google/Service/Directory/VerificationCodesResource.php index 125d8fc..dac8727 100644 --- a/SilMock/Google/Service/Directory/VerificationCodesResource.php +++ b/SilMock/Google/Service/Directory/VerificationCodesResource.php @@ -2,19 +2,17 @@ namespace SilMock\Google\Service\Directory; +use Google_Service_Directory_VerificationCode; +use Google_Service_Directory_VerificationCodes; use SilMock\DataStore\Sqlite\SqliteUtils; +use SilMock\Google\Service\DbClass; use SilMock\Google\Service\Directory; -class VerificationCodesResource +class VerificationCodesResource extends DbClass { - - private $_dbFile; // string for the path (with file name) for the Sqlite database - private $_dataType = 'directory'; // string to put in the 'type' field in the database - private $_dataClass = 'verification_codes'; // string to put in the 'class' field in the database - public function __construct($dbFile = null) { - $this->_dbFile = $dbFile; + parent::__construct($dbFile, 'directory', 'verification_codes'); } /** @@ -33,7 +31,7 @@ public function invalidate($userKey) } // ensure that user exists in db - $dir = new Directory('anything', $this->_dbFile); + $dir = new Directory('anything', $this->dbFile); $matchingUser = $dir->users->get($userKey); if ($matchingUser === null) { throw new \Exception("Account doesn't exist: " . $userKey); @@ -41,10 +39,10 @@ public function invalidate($userKey) $email = $matchingUser->getPrimaryEmail(); // Confirm verification codes exist. - $sqliteUtils = new SqliteUtils($this->_dbFile); + $sqliteUtils = new SqliteUtils($this->dbFile); $verificationCodes = $sqliteUtils->getAllRecordsByDataKey( - $this->_dataType, - $this->_dataClass, + $this->dataType, + $this->dataClass, $key, $userKey ); @@ -53,7 +51,7 @@ public function invalidate($userKey) } // Delete the verification codes for that email account. - return $sqliteUtils->deleteDataByEmail($this->_dataType, $this->_dataClass, $email); + return $sqliteUtils->deleteDataByEmail($this->dataType, $this->dataClass, $email); } /** @@ -61,7 +59,7 @@ public function invalidate($userKey) * items set to all the listed verification codes for that user. * * @param string|int $userKey - The Email or immutable Id of the user - * @return \Google_Service_Directory_VerificationCodes + * @return Google_Service_Directory_VerificationCodes */ public function listVerificationCodes($userKey) { @@ -71,14 +69,14 @@ public function listVerificationCodes($userKey) $key = 'id'; } - $sqliteUtils = new SqliteUtils($this->_dbFile); + $sqliteUtils = new SqliteUtils($this->dbFile); $data = $sqliteUtils->getAllRecordsByDataKey( - $this->_dataType, - $this->_dataClass, + $this->dataType, + $this->dataClass, $key, $userKey ); - $verificationCodes = new \Google_Service_Directory_VerificationCodes(); + $verificationCodes = new Google_Service_Directory_VerificationCodes(); if (! empty($data)) { $verificationCodeData = $data[0]['data']; $decodedVerificationCodeData = json_decode($verificationCodeData, true); @@ -99,9 +97,9 @@ public function generate($userKey) { // generate 10 new verification codes. - $newVerificationCodes = new \Google_Service_Directory_VerificationCodes(); + $newVerificationCodes = new Google_Service_Directory_VerificationCodes(); for ($count = 0; $count < 10; ++$count) { - $newVerificationCode = new \Google_Service_Directory_VerificationCode(); + $newVerificationCode = new Google_Service_Directory_VerificationCode(); $newVerificationCode->verificationCode = mt_rand(10000000, 99999999); $after = $newVerificationCodes->getItems(); $after[] = $newVerificationCode; @@ -123,10 +121,10 @@ public function generate($userKey) // save the new ones. $entryData = json_encode($keyedData); if ($entryData !== false) { - $sqliteUtils = new SqliteUtils($this->_dbFile); + $sqliteUtils = new SqliteUtils($this->dbFile); $sqliteUtils->recordData( - $this->_dataType, - $this->_dataClass, + $this->dataType, + $this->dataClass, $entryData ); } diff --git a/SilMock/tests/Google/Service/DirectoryTest.php b/SilMock/tests/Google/Service/DirectoryTest.php index e44f888..7afd5e0 100644 --- a/SilMock/tests/Google/Service/DirectoryTest.php +++ b/SilMock/tests/Google/Service/DirectoryTest.php @@ -5,6 +5,7 @@ use PHPUnit\Framework\TestCase; use Google_Service_Directory_Alias; use Google_Service_Directory_User; +use Sil\Psr3Adapters\Psr3EchoLogger; use SilMock\Google\Service\Directory; use SilMock\Google\Service\Directory\ObjectUtils; use SilMock\DataStore\Sqlite\SqliteUtils; @@ -43,12 +44,13 @@ public function getProperties($object, $propKeys = null) public function testDirectory() { + $logger = new Psr3EchoLogger(); $expectedKeys = array( 'asps', - 'tokens', 'users', 'users_aliases', 'verificationCodes', + 'tokens', ); $errorMessage = " *** Directory was not initialized properly"; @@ -57,8 +59,9 @@ public function testDirectory() $directoryAsJson = json_encode($directory); $directoryInfo = json_decode($directoryAsJson, true); foreach ($expectedKeys as $expectedKey) { + $logger->info($expectedKey); $this->assertArrayHasKey($expectedKey, $directoryInfo, $errorMessage); - $this->assertEmpty($directoryInfo[$expectedKey], $errorMessage); + $this->assertArrayHasKey('dbFile', $directoryInfo[$expectedKey], $errorMessage); } } From 1f295615535cb6535375df4922c85e54f149376d Mon Sep 17 00:00:00 2001 From: Mark Tompsett Date: Fri, 18 Mar 2022 14:18:51 -0400 Subject: [PATCH 13/16] Restore back to unchanged, with dbFile now protected --- SilMock/Google/Service/DbClass.php | 2 +- SilMock/tests/Google/Service/DirectoryTest.php | 5 +---- 2 files changed, 2 insertions(+), 5 deletions(-) diff --git a/SilMock/Google/Service/DbClass.php b/SilMock/Google/Service/DbClass.php index ef979bd..af2f393 100644 --- a/SilMock/Google/Service/DbClass.php +++ b/SilMock/Google/Service/DbClass.php @@ -9,7 +9,7 @@ class DbClass { /** @var string|null - The path (with file name) to the SQLite database. */ - public ?string $dbFile; + protected ?string $dbFile; /** @var string - The 'type' field to use in the database. */ protected string $dataType; diff --git a/SilMock/tests/Google/Service/DirectoryTest.php b/SilMock/tests/Google/Service/DirectoryTest.php index 7afd5e0..9457169 100644 --- a/SilMock/tests/Google/Service/DirectoryTest.php +++ b/SilMock/tests/Google/Service/DirectoryTest.php @@ -5,7 +5,6 @@ use PHPUnit\Framework\TestCase; use Google_Service_Directory_Alias; use Google_Service_Directory_User; -use Sil\Psr3Adapters\Psr3EchoLogger; use SilMock\Google\Service\Directory; use SilMock\Google\Service\Directory\ObjectUtils; use SilMock\DataStore\Sqlite\SqliteUtils; @@ -44,7 +43,6 @@ public function getProperties($object, $propKeys = null) public function testDirectory() { - $logger = new Psr3EchoLogger(); $expectedKeys = array( 'asps', 'users', @@ -59,9 +57,8 @@ public function testDirectory() $directoryAsJson = json_encode($directory); $directoryInfo = json_decode($directoryAsJson, true); foreach ($expectedKeys as $expectedKey) { - $logger->info($expectedKey); $this->assertArrayHasKey($expectedKey, $directoryInfo, $errorMessage); - $this->assertArrayHasKey('dbFile', $directoryInfo[$expectedKey], $errorMessage); + $this->assertEmpty($directoryInfo[$expectedKey], $errorMessage); } } From 5406e5fc6a037d8259d4c88ea9d562a82c4a85d3 Mon Sep 17 00:00:00 2001 From: Matt Henderson Date: Fri, 18 Mar 2022 14:40:49 -0400 Subject: [PATCH 14/16] Tweak codeship-steps command to run tests successfully --- codeship-steps.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/codeship-steps.yml b/codeship-steps.yml index 3038c08..98aeddc 100644 --- a/codeship-steps.yml +++ b/codeship-steps.yml @@ -1,3 +1,3 @@ - name: test service: cli - command: "cd /data/SilMock/tests; ./phpunit" + command: "bash -c \"cd /data/SilMock/tests; ./phpunit\"" From 9bd48f2678091e55df12c59d3986c350f89805f0 Mon Sep 17 00:00:00 2001 From: Matt Henderson Date: Fri, 18 Mar 2022 14:51:43 -0400 Subject: [PATCH 15/16] Stop volume-mapping host files for CI/CD tests --- codeship-services.yml | 2 -- 1 file changed, 2 deletions(-) diff --git a/codeship-services.yml b/codeship-services.yml index 3d116e3..29424f2 100644 --- a/codeship-services.yml +++ b/codeship-services.yml @@ -1,5 +1,3 @@ cli: build: ./ - volumes: - - ./:/data working_dir: /data From 52d424eba8759ec74cd3ecb672a0d13f11e5a152 Mon Sep 17 00:00:00 2001 From: Mark Tompsett Date: Fri, 18 Mar 2022 15:02:45 -0400 Subject: [PATCH 16/16] Run a composer install as part of the build --- Dockerfile | 1 + 1 file changed, 1 insertion(+) diff --git a/Dockerfile b/Dockerfile index d56a312..3be04d3 100644 --- a/Dockerfile +++ b/Dockerfile @@ -23,3 +23,4 @@ COPY ./ /data RUN cd /data && ./composer-install.sh RUN mv /data/composer.phar /usr/bin/composer +RUN /usr/bin/composer install