diff --git a/Dockerfile b/Dockerfile index c7c5c2c..cd1c394 100644 --- a/Dockerfile +++ b/Dockerfile @@ -9,10 +9,12 @@ RUN apt-get update -y \ && echo "America/New_York" > /etc/timezone \ && apt-get install -y tzdata \ && apt-get upgrade -y \ -# Install some basics - && apt-get install -y zip unzip wget \ -# Needed for GoogleMock objects +# Install + && apt-get install -y \ +# things needed for GoogleMock objects sqlite3 \ +# some basics + unzip wget zip \ # Clean up to reduce docker image size && apt-get clean \ && rm -rf /var/lib/apt/lists/* diff --git a/SilMock/DataStore/Sqlite/SqliteUtils.php b/SilMock/DataStore/Sqlite/SqliteUtils.php index 0699900..595018a 100644 --- a/SilMock/DataStore/Sqlite/SqliteUtils.php +++ b/SilMock/DataStore/Sqlite/SqliteUtils.php @@ -6,20 +6,19 @@ class SqliteUtils { - /** * The PDO connection to the database (or null if unititialized). * @var PDO|null */ - private $_db = null; + private $db = null; /** * The SQLite database file (path with file name). * @var string */ - private $_dbFile; + private $dbFile; - private $_dbTable = 'google_service'; + private $dbTable = 'google_service'; /** * @@ -29,11 +28,11 @@ class SqliteUtils public function __construct($dbFile = null) { // default database path - $this->_dbFile = __DIR__ . '/Google_Service_Data.db'; + $this->dbFile = __DIR__ . '/Google_Service_Data.db'; // if database path given, use it instead if ($dbFile) { - $this->_dbFile = $dbFile; + $this->dbFile = $dbFile; } $this->createDbStructureAsNecessary(); @@ -52,7 +51,7 @@ public function __construct($dbFile = null) */ public function getData($dataType, $dataClass) { - if (! file_exists($this->_dbFile)) { + if (! file_exists($this->dbFile)) { return null; } @@ -71,7 +70,7 @@ public function getData($dataType, $dataClass) if (! $whereClause) { return $this->runSql( - "SELECT * FROM " . $this->_dbTable, + "SELECT * FROM " . $this->dbTable, array(), false, true @@ -79,7 +78,7 @@ public function getData($dataType, $dataClass) } return $this->runSql( - "SELECT * FROM " . $this->_dbTable . $whereClause, + "SELECT * FROM " . $this->dbTable . $whereClause, $whereArray, false, true @@ -144,7 +143,7 @@ public function getAllRecordsByDataKey($dataType, $dataClass, $dataKey, $dataVal public function deleteRecordById($recordId) { $this->runSql( - "DELETE FROM " . $this->_dbTable . " WHERE id = :id", + "DELETE FROM " . $this->dbTable . " WHERE id = :id", [':id' => $recordId], true ); @@ -164,7 +163,7 @@ public function deleteRecordById($recordId) */ public function deleteDataByEmail(string $dataType, string $dataClass, string $emailAddress) { - if (! file_exists($this->_dbFile)) { + if (! file_exists($this->dbFile)) { return null; } if (empty($dataType)) { @@ -187,12 +186,12 @@ public function deleteDataByEmail(string $dataType, string $dataClass, string $e * the input value * @param $recordId int * @param $newData string - * @return null + * @return void */ - public function updateRecordById($recordId, $newData) + public function updateRecordById($recordId, $newData): void { $this->runSql( - "UPDATE " . $this->_dbTable . " SET data = :data WHERE id = :id", + "UPDATE " . $this->dbTable . " SET data = :data WHERE id = :id", [':id' => $recordId, ':data' => $newData], true ); @@ -205,7 +204,7 @@ public function updateRecordById($recordId, $newData) public function deleteAllData() { return $this->runSql( - "DELETE FROM " . $this->_dbTable . " WHERE id > -1" + "DELETE FROM " . $this->dbTable . " WHERE id > -1" ); } @@ -231,7 +230,7 @@ public function recordData($dataType, $dataClass, $data) // Add the record. $this->runSql( - 'INSERT INTO ' . $this->_dbTable . ' (type, class, data)' . + 'INSERT INTO ' . $this->dbTable . ' (type, class, data)' . ' VALUES (:type, :class, :data)', [':type' => $dataType, ':class' => $dataClass, ':data' => $data], true @@ -247,9 +246,9 @@ public function recordData($dataType, $dataClass, $data) */ public function createDbIfNotExists() { - if (! file_exists($this->_dbFile)) { - file_put_contents($this->_dbFile, ''); - chmod($this->_dbFile, 0644); + if (! file_exists($this->dbFile)) { + file_put_contents($this->dbFile, ''); + chmod($this->dbFile, 0644); } } @@ -266,7 +265,7 @@ public function createDbStructureAsNecessary() $this->createDbIfNotExists(); $this->runSql( - "CREATE TABLE IF NOT EXISTS " . $this->_dbTable . " (" . + "CREATE TABLE IF NOT EXISTS " . $this->dbTable . " (" . "id INTEGER PRIMARY KEY, " . "type TEXT, " . // e.g. "directory" "class TEXT, " . // e.g. "user" @@ -310,7 +309,7 @@ protected function runSql( $this->setupDbConnIfNeeded(); // Update the record in the database. - $stmt = $this->_db->prepare($sql); + $stmt = $this->db->prepare($sql); // Execute the prepared update statement with the desired data. $stmtSuccess = $stmt->execute($data); @@ -340,15 +339,15 @@ protected function runSql( protected function setupDbConnIfNeeded() { // If we have not yet setup the database connection... - if (is_null($this->_db)) { + if (is_null($this->db)) { // Make sure the database itself exists. $this->createDbIfNotExists(); // Connect to the SQLite database file. - $this->_db = new PDO('sqlite:' . $this->_dbFile); + $this->db = new PDO('sqlite:' . $this->dbFile); // Set errormode to exceptions. - $this->_db->setAttribute( + $this->db->setAttribute( PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION ); diff --git a/SilMock/Google/Service/Directory.php b/SilMock/Google/Service/Directory.php index 7be0cc3..3955ffe 100644 --- a/SilMock/Google/Service/Directory.php +++ b/SilMock/Google/Service/Directory.php @@ -6,6 +6,7 @@ use SilMock\Google\Http\Batch; use SilMock\Google\Service\Directory\Asps; use SilMock\Google\Service\Directory\Resource\Groups; +use SilMock\Google\Service\Directory\Resource\GroupsAliases; use SilMock\Google\Service\Directory\Resource\Members; use SilMock\Google\Service\Directory\Resource\TwoStepVerification; use SilMock\Google\Service\Directory\Tokens; @@ -19,6 +20,7 @@ class Directory public $asps; public Members $members; public Groups $groups; + public GroupsAliases $groups_aliases; public $tokens; public $users; public $users_aliases; @@ -38,6 +40,7 @@ public function __construct($client, ?string $dbFile = null) $this->asps = new Asps($dbFile); $this->members = new Members($dbFile); $this->groups = new Groups($dbFile); + $this->groups_aliases = new GroupsAliases($dbFile); $this->tokens = new Tokens($dbFile); $this->users = new UsersResource($dbFile); $this->users_aliases = new UsersAliasesResource($dbFile); diff --git a/SilMock/Google/Service/Directory/Asps.php b/SilMock/Google/Service/Directory/Asps.php index 039e9d7..bd993c7 100644 --- a/SilMock/Google/Service/Directory/Asps.php +++ b/SilMock/Google/Service/Directory/Asps.php @@ -11,11 +11,9 @@ public function __construct(?string $dbFile = null) { parent::__construct($dbFile, 'directory', 'asps'); } - + public function listAsps($userKey, $optParams = array()) { - return new Google_Service_Directory_Asps(array( - 'items' => array(), - )); + return new Google_Service_Directory_Asps(['items' => []]); } } diff --git a/SilMock/Google/Service/Directory/Resource/Groups.php b/SilMock/Google/Service/Directory/Resource/Groups.php index 61f29c6..05a1a91 100644 --- a/SilMock/Google/Service/Directory/Resource/Groups.php +++ b/SilMock/Google/Service/Directory/Resource/Groups.php @@ -45,7 +45,8 @@ public function get(string $groupKey): ?GoogleDirectory_Group public function insert(GoogleDirectory_Group $postBody, $optParams = []) { if ($this->isNewGroup($postBody->getEmail())) { - $postBody['id'] = $postBody['id'] ?? microtime(); + $id = str_replace(array(' ', '.'), '', microtime()); + $postBody['id'] = $postBody['id'] ?? $id; $dataAsJson = json_encode(get_object_vars($postBody)); $this->addRecord($dataAsJson); } diff --git a/SilMock/Google/Service/Directory/Resource/GroupsAliases.php b/SilMock/Google/Service/Directory/Resource/GroupsAliases.php new file mode 100644 index 0000000..fbfb9bb --- /dev/null +++ b/SilMock/Google/Service/Directory/Resource/GroupsAliases.php @@ -0,0 +1,92 @@ +getRecords(); + foreach ($groupAliasRecords as $groupAliasRecord) { + $groupAliasRecordData = json_decode($groupAliasRecord['data'], true); + if ( + $groupAliasRecordData['primaryEmail'] === $groupKey + && $groupAliasRecordData['alias'] === $alias + ) { + $this->deleteRecordById($groupAliasRecordData['id']); + } + } + } + + /** + * @throws Exception + */ + public function insert( + string $groupKey, + GoogleDirectory_GroupsAlias $postBody, + array $optParams = [] + ): GoogleDirectory_GroupsAlias { + if ($this->isNewGroupAlias($groupKey, $postBody->getAlias())) { + $id = str_replace(array(' ', '.'), '', microtime()); + $postBody['id'] = $postBody['id'] ?? $id; + $dataAsJson = json_encode(get_object_vars($postBody)); + $this->addRecord($dataAsJson); + } + + $newGroupAlias = new GoogleDirectory_GroupsAlias(); + ObjectUtils::initialize($newGroupAlias, $postBody); + + return $newGroupAlias; + } + + /** + * @param $optParams -- Initial implementation ignores this. + * @return GoogleDirectory_GroupsAliases + */ + public function listGroupsAliases(string $groupKey, array $optParams = []): GoogleDirectory_GroupsAliases + { + $groupAliases = []; + $groupAliasRecords = $this->getRecords(); + $groupAliasCounter = 0; + foreach ($groupAliasRecords as $groupAliasRecord) { + $groupRecordData = json_decode($groupAliasRecord['data'], true); + if ($groupRecordData['primaryEmail'] === $groupKey) { + $currentGroup = new GoogleDirectory_GroupsAlias(); + ObjectUtils::initialize($currentGroup, $groupRecordData); + $groupAliases[] = $currentGroup; + $groupAliasCounter = $groupAliasCounter + 1; + } + } + $groupsAliasesObject = new GoogleDirectory_GroupsAliases(); + $groupsAliasesObject->setEtag(''); + $groupsAliasesObject->setKind('groupAliases'); + $groupsAliasesObject->setAliases($groupAliases); + return $groupsAliasesObject; + } + + protected function isNewGroupAlias(string $groupKey, string $alias): bool + { + $mockGroupsObject = new GroupsAliases($this->dbFile); + $groupsAliasesObject = $mockGroupsObject->listGroupsAliases($groupKey); + /** @var GoogleDirectory_GroupsAlias[] $aliasObjects */ + $aliasObjects = $groupsAliasesObject->getAliases(); + $lowercaseAliasEmailAddress = mb_strtolower($alias); + foreach ($aliasObjects as $aliasObject) { + if (mb_strtolower($aliasObject->getAlias()) === $lowercaseAliasEmailAddress) { + return false; + } + } + return true; + } +} diff --git a/SilMock/Google/Service/Directory/Resource/Members.php b/SilMock/Google/Service/Directory/Resource/Members.php index 156c8fa..56b8658 100644 --- a/SilMock/Google/Service/Directory/Resource/Members.php +++ b/SilMock/Google/Service/Directory/Resource/Members.php @@ -117,7 +117,12 @@ protected function extractRoles(?string $roles): array { if (! empty($roles)) { $allExpectedRoles = explode(',', $roles); - $expectedRoles = array_map(function ($role) { return mb_strtoupper(trim($role)); }, $allExpectedRoles); + $expectedRoles = array_map( + function ($role) { + return mb_strtoupper(trim($role)); + }, + $allExpectedRoles + ); } else { $expectedRoles = []; } diff --git a/SilMock/Google/Service/Directory/Resource/TwoStepVerification.php b/SilMock/Google/Service/Directory/Resource/TwoStepVerification.php index 1571d72..206bdbb 100644 --- a/SilMock/Google/Service/Directory/Resource/TwoStepVerification.php +++ b/SilMock/Google/Service/Directory/Resource/TwoStepVerification.php @@ -40,4 +40,4 @@ public function turnOff($userKey, $optParams = []) $sqliteUtils->updateRecordById($recordId, json_encode($twoStepVerificationRecord)); } } -} \ No newline at end of file +} diff --git a/SilMock/Google/Service/Directory/Tokens.php b/SilMock/Google/Service/Directory/Tokens.php index b3cd1ea..9973e11 100644 --- a/SilMock/Google/Service/Directory/Tokens.php +++ b/SilMock/Google/Service/Directory/Tokens.php @@ -13,7 +13,7 @@ public function __construct(?string $dbFile = null) { parent::__construct($dbFile, 'directory', 'tokens'); } - + public function listTokens($userKey, $optParams = []): Google_Service_Directory_Tokens { return new Google_Service_Directory_Tokens([ 'items' => [] ]); diff --git a/SilMock/Google/Service/Directory/UsersResource.php b/SilMock/Google/Service/Directory/UsersResource.php index 474d65d..596dbd4 100644 --- a/SilMock/Google/Service/Directory/UsersResource.php +++ b/SilMock/Google/Service/Directory/UsersResource.php @@ -81,7 +81,7 @@ public function get($userKey) return $newUser; } - + /** * @param $userKey * @return Google_Service_Directory_Aliases|null @@ -93,11 +93,11 @@ protected function getAliasesForUser($userKey): ?Google_Service_Directory_Aliase if (! filter_var($userKey, FILTER_VALIDATE_EMAIL)) { $key = 'id'; } - + $usersAliases = new UsersAliasesResource($this->dbFile); return $usersAliases->fetchAliasesByUser($key, $userKey); } - + /** * Get the database record of the user (if any) that has the given email * address as an alias. @@ -115,7 +115,7 @@ protected function getDbUserByAlias($userKey) // This function only makes sense for actual email addresses. return null; } - + $allUsers = $this->getAllDbUsers(); $usersWithData = array_filter( $allUsers, @@ -129,9 +129,9 @@ function ($user) { if ($userData === null) { continue; } - + $primaryEmail = $userData['primaryEmail'] ?? null; - + $aliasesResource = $this->getAliasesForUser($primaryEmail); if ($aliasesResource) { foreach ($aliasesResource['aliases'] as $aliasResource) { @@ -142,16 +142,16 @@ function ($user) { } } } - + return null; } - + protected function getAllDbUsers() { $sqliteUtils = new SqliteUtils($this->dbFile); return $sqliteUtils->getData($this->dataType, $this->dataClass); } - + /** * Creates a user (users.insert) and sets its aliases property if any * are given. @@ -361,15 +361,15 @@ public function listUsers($parameters = []) $familyName = $nameEntry['familyName'] ?? null; $fullName = $nameEntry['fullName'] ?? trim($givenName . ' ' . $familyName); $newName = new \Google_Service_Directory_UserName([ - 'familyName' => $familyName, - 'fullName' => $fullName, - 'givenName' => $givenName, + 'familyName' => $familyName, + 'fullName' => $fullName, + 'givenName' => $givenName, ]); $userEntry['customerId'] = $userEntry['primaryEmail']; /** @var \Google_Service_Directory_User $newEntry */ $newEntry = new \Google_Service_Directory_User($userEntry); $newEntry->setName($newName); - + $allResultsUsers = $results->getUsers(); $allResultsUsers[] = $newEntry; $results->setUsers($allResultsUsers); @@ -438,13 +438,15 @@ private function doesUserMatch($entry, $query = '') $checkValue = $checkValue ? 'true' : 'false'; } if (! is_string($checkValue)) { - throw new \Exception(sprintf( - "Expecting a string.\nGot Entry: %s\nGot Field: %s\nGot VALUE: %s (%s)", - var_export($entry, true), - var_export($field, true), - var_export($checkValue, true), - gettype($checkValue) - )); + throw new \Exception( + sprintf( + "Expecting a string.\nGot Entry: %s\nGot Field: %s\nGot VALUE: %s (%s)", + var_export($entry, true), + var_export($field, true), + var_export($checkValue, true), + gettype($checkValue) + ) + ); } if (mb_strpos($checkValue, $value) === 0) { return true; diff --git a/SilMock/Google/Service/Gmail.php b/SilMock/Google/Service/Gmail.php index 0f6d671..fe5b8c7 100644 --- a/SilMock/Google/Service/Gmail.php +++ b/SilMock/Google/Service/Gmail.php @@ -11,7 +11,7 @@ class Gmail public $users_settings; public $users_settings_delegates; public $users_settings_forwardingAddresses; - + public function __construct($client, $dbFile = null) { $this->users_settings = new UsersSettings($dbFile); diff --git a/SilMock/Google/Service/Gmail/Resource/UsersSettings.php b/SilMock/Google/Service/Gmail/Resource/UsersSettings.php index 97edcce..f7197dc 100644 --- a/SilMock/Google/Service/Gmail/Resource/UsersSettings.php +++ b/SilMock/Google/Service/Gmail/Resource/UsersSettings.php @@ -12,12 +12,12 @@ public function __construct(?string $dbFile = null) { parent::__construct($dbFile, 'gmail', 'users_settings'); } - + public function updatePop($userId, Google_Service_Gmail_PopSettings $postBody, $optParams = array()) { // No action necessary, since we do not yet mock any way to check the pop settings. } - + public function updateImap($userId, Google_Service_Gmail_ImapSettings $postBody, $optParams = array()) { // No action necessary, since we do not yet mock any way to check the IMAP settings. diff --git a/SilMock/Google/Service/Gmail/Resource/UsersSettingsDelegates.php b/SilMock/Google/Service/Gmail/Resource/UsersSettingsDelegates.php index ee190a0..b646c99 100644 --- a/SilMock/Google/Service/Gmail/Resource/UsersSettingsDelegates.php +++ b/SilMock/Google/Service/Gmail/Resource/UsersSettingsDelegates.php @@ -28,14 +28,14 @@ public function __construct(?string $dbFile = null) 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); } - + return $this->addDelegate($userId, $postBody->delegateEmail); } - + protected function hasDelegate(string $userId, string $delegateEmail): bool { foreach ($this->listDelegatesFor($userId) as $delegate) { @@ -45,7 +45,7 @@ protected function hasDelegate(string $userId, string $delegateEmail): bool } return false; } - + protected function listDelegatesFor(string $userId): array { $matchingRecords = []; @@ -60,7 +60,7 @@ protected function listDelegatesFor(string $userId): array } return $matchingRecords; } - + /** * Get the delegate records. Example result: * @@ -80,7 +80,7 @@ protected function getDelegateRecords(): array { return $this->getRecords(); } - + protected function addDelegate(string $userId, string $delegateEmail) { $data = json_encode( @@ -94,26 +94,26 @@ protected function addDelegate(string $userId, string $delegateEmail) return $this->get($userId, $delegateEmail); } - + protected function getSqliteUtils(): SqliteUtils { return new SqliteUtils($this->dbFile); } - + protected function assertIsValidUserId(string $userId) { if (! $this->isValidEmailAddress($userId)) { 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); } } - + /** * Determine whether the given string is a valid email address. * @@ -124,12 +124,12 @@ protected function isValidEmailAddress($email) { return (filter_var($email, FILTER_VALIDATE_EMAIL) !== false); } - + public function get($userId, $delegateEmail, $optParams = array()) { $this->assertIsValidUserId($userId); $this->assertIsValidDelegateEmail($delegateEmail); - + foreach ($this->listDelegatesFor($userId) as $delegate) { if ($delegate->delegateEmail === $delegateEmail) { $matchingRecord = new \Google_Service_Gmail_Delegate(); @@ -140,12 +140,12 @@ public function get($userId, $delegateEmail, $optParams = array()) } throw new Google_Service_Exception('Invalid delegate', 404); } - + public function delete($userId, $delegateEmail, $optParams = array()) { $this->assertIsValidUserId($userId); $this->assertIsValidDelegateEmail($delegateEmail); - + foreach ($this->listDelegatesFor($userId) as $recordId => $delegate) { if ($delegate->delegateEmail === $delegateEmail) { $this->removeDelegate($recordId); @@ -154,12 +154,12 @@ public function delete($userId, $delegateEmail, $optParams = array()) } throw new Google_Service_Exception('Invalid delegate', 404); } - + protected function removeDelegate(int $recordId) { $this->deleteRecordById($recordId); } - + public function listUsersSettingsDelegates($userId, $optParams = array()) { $response = new Google_Service_Gmail_ListDelegatesResponse(); diff --git a/SilMock/Google/Service/GoogleFixtures.php b/SilMock/Google/Service/GoogleFixtures.php index 1abcd42..8bf1d4d 100644 --- a/SilMock/Google/Service/GoogleFixtures.php +++ b/SilMock/Google/Service/GoogleFixtures.php @@ -10,14 +10,14 @@ class GoogleFixtures * The SQLite database path and file. * @var string */ - private $_dbFile; + private $dbFile; /** * @param string $dbFile path and filename of the database for Mock Google */ public function __construct($dbFile = null) { - $this->_dbFile = $dbFile; + $this->dbFile = $dbFile; } /** @@ -31,7 +31,7 @@ public function __construct($dbFile = null) */ public function addFixtures($fixtures) { - $newSqlite = new SqliteUtils($this->_dbFile); + $newSqlite = new SqliteUtils($this->dbFile); foreach ($fixtures as $nextFixture) { $type = $nextFixture[0]; @@ -46,7 +46,7 @@ public function addFixtures($fixtures) */ public function removeAllFixtures() { - $newSqlite = new SqliteUtils($this->_dbFile); + $newSqlite = new SqliteUtils($this->dbFile); $newSqlite->deleteAllData(); } } diff --git a/SilMock/tests/Google/Service/Directory/Resource/GroupsAliasesTest.php b/SilMock/tests/Google/Service/Directory/Resource/GroupsAliasesTest.php new file mode 100644 index 0000000..16c2a24 --- /dev/null +++ b/SilMock/tests/Google/Service/Directory/Resource/GroupsAliasesTest.php @@ -0,0 +1,116 @@ +setPrimaryEmail(self::GROUP_EMAIL_ADDRESS); + $groupAlias->setAlias(self::GROUP_ALIAS_ADDRESS); + + $mockGoogleServiceDirectory = new GoogleMock_Directory('anyclient', $this->dataFile); + try { + $addedGroupAlias = $mockGoogleServiceDirectory->groups_aliases->insert( + self::GROUP_EMAIL_ADDRESS, + $groupAlias + ); + } catch (Exception $exception) { + self::fail( + sprintf( + 'Was expecting the groups_aliases.insert method to function, but got: %s', + $exception->getMessage() + ) + ); + } + self::assertTrue( + $addedGroupAlias->getAlias() === self::GROUP_ALIAS_ADDRESS + && $addedGroupAlias->getPrimaryEmail() === self::GROUP_EMAIL_ADDRESS, + 'Was expecting the groups_alias.insert method to return a match to the value passed' + ); + } + + public function testDelete() + { + // Set update a deletable email address + $groupAlias = new GoogleDirectory_GroupsAlias(); + $groupAlias->setPrimaryEmail(self::GROUP_EMAIL_ADDRESS . 'delete'); + $groupAlias->setAlias(self::GROUP_ALIAS_ADDRESS); + + $mockGoogleServiceDirectory = new GoogleMock_Directory('anyclient', $this->dataFile); + try { + $mockGoogleServiceDirectory->groups_aliases->insert(self::GROUP_EMAIL_ADDRESS, $groupAlias); + } catch (Exception $exception) { + self::fail( + sprintf( + 'Was expecting the groups_aliases.insert method to function for delete, but got: %s', + $exception->getMessage() + ) + ); + } + + // Now try to delete it + $mockGoogleServiceDirectory = new GoogleMock_Directory('anyclient', $this->dataFile); + try { + $mockGoogleServiceDirectory->groups->delete(self::GROUP_EMAIL_ADDRESS . 'delete'); + } catch (Exception $exception) { + self::fail( + sprintf( + 'Was expecting the groups.delete method to function, but got: %s', + $exception->getMessage() + ) + ); + } + + try { + $groupsAliasesObject = $mockGoogleServiceDirectory->groups_aliases->listGroupsAliases( + self::GROUP_EMAIL_ADDRESS . 'delete' + ); + $groupsAliases = $groupsAliasesObject->getAliases(); + self::assertEmpty( + $groupsAliases, + 'Was expecting the groups aliases to be deleted, but found something' + ); + } catch (Exception $exception) { + self::fail( + sprintf( + 'Was expecting to confirm the group\'s alias was deleted, but got: %s', + $exception->getMessage() + ) + ); + } + } + + public function testListGroupsAliases() + { + $mockGoogleServiceDirectory = new GoogleMock_Directory('anyclient', $this->dataFile); + $groups = []; + try { + $groups = $mockGoogleServiceDirectory->groups_aliases->listGroupsAliases(self::GROUP_EMAIL_ADDRESS); + } catch (Exception $exception) { + self::fail( + sprintf( + 'Was expecting the groups.list method to function, but got: %s', + $exception->getMessage() + ) + ); + } + self::assertNotEmpty( + $groups, + 'Was expecting the groups_aliases.list method to have at least one group alias.' + ); + } +} diff --git a/SilMock/tests/Google/Service/DirectoryTest.php b/SilMock/tests/Google/Service/DirectoryTest.php index 9897a9f..f5b593d 100644 --- a/SilMock/tests/Google/Service/DirectoryTest.php +++ b/SilMock/tests/Google/Service/DirectoryTest.php @@ -62,9 +62,9 @@ public function testDirectory() 'tokens', ]; $errorMessage = " *** Directory was not initialized properly"; - + $directory = new Directory('anyclient', $this->dataFile); - + $directoryAsJson = json_encode($directory); $directoryInfo = json_decode($directoryAsJson, true); foreach ($expectedKeys as $expectedKey) { @@ -122,7 +122,7 @@ public function testUsersInsert() $this->assertEquals($expected, $results, $msg); } - public function testUsersInsert_WithAliases() + public function testUsersInsertWithAliases() { $newUser = $this->setupSampleUser($this->dataFile, true); @@ -182,7 +182,7 @@ public function getFixtures(): array return [ [ 'directory', 'user', '{"primaryEmail":"user_test1@sil.org",' . - '"id":"999990"}' + '"id":"999990"}' ], ['directory', 'users_alias', json_encode($alias2)], ['app_engine', 'webapp', 'webapp3 test data'], @@ -238,7 +238,7 @@ public function testUsersGet() $this->assertEquals($expected, $results, $msg); } - public function testUsersGet_ById() + public function testUsersGetById() { $fixturesClass = new GoogleFixtures($this->dataFile); $fixturesClass->removeAllFixtures(); @@ -270,7 +270,7 @@ public function testUsersGet_ById() } - public function testUsersGet_Aliases() + public function testUsersGetAliases() { $fixturesClass = new GoogleFixtures($this->dataFile); $fixturesClass->removeAllFixtures(); @@ -311,27 +311,27 @@ public function testUsersGet_Aliases() $this->assertEquals($expected, $results, $msg); } - public function testUsersGet_ByAlias() + public function testUsersGetByAlias() { $fixturesClass = new GoogleFixtures($this->dataFile); $fixturesClass->removeAllFixtures(); $fixtures = $this->getFixtures(); $fixturesClass->addFixtures($fixtures); - + $email = "user_test4@sil.org"; - + $aliasA = $this->getAliasFixture("users_alias1A@sil.org", $email, null); $aliasB = $this->getAliasFixture("users_alias1B@sil.org", $email, null); - + $newFixtures = [ ['directory', 'users_alias', json_encode($aliasA)], ['directory', 'users_alias', json_encode($aliasB)], ]; $fixturesClass->addFixtures($newFixtures); - + $newDir = new Directory('anyclient', $this->dataFile); $newUser = $newDir->users->get('users_alias1A@sil.org'); - + $this->assertNotNull( $newUser, 'Failed to get user by an alias' @@ -342,7 +342,7 @@ public function testUsersGet_ByAlias() 'Failed to get correct user by an alias' ); } - + public function testUsersUpdate() { $fixturesClass = new GoogleFixtures($this->dataFile); @@ -379,7 +379,7 @@ public function testUsersUpdate() } - public function testUsersUpdate_ById() + public function testUsersUpdateById() { $fixturesClass = new GoogleFixtures($this->dataFile); $fixturesClass->removeAllFixtures(); @@ -414,7 +414,7 @@ public function testUsersUpdate_ById() $this->assertEquals($expected, $results, $msg); } - public function testUsersUpdate_ById_ChangeEmail() + public function testUsersUpdateByIdChangeEmail() { $fixturesClass = new GoogleFixtures($this->dataFile); $fixturesClass->removeAllFixtures(); @@ -458,7 +458,7 @@ public function testUsersUpdate_ById_ChangeEmail() $this->assertEquals($expected, $results, $msg); } - public function testUsersUpdate_WithAlias() + public function testUsersUpdateWithAlias() { $fixturesClass = new GoogleFixtures($this->dataFile); $fixturesClass->removeAllFixtures(); @@ -493,7 +493,7 @@ public function testUsersUpdate_WithAlias() $this->assertEquals($expected, $results, $msg); } - public function testUsersUpdate_WithDifferentAliases() + public function testUsersUpdateWithDifferentAliases() { $fixturesClass = new GoogleFixtures($this->dataFile); $fixturesClass->removeAllFixtures(); @@ -541,7 +541,7 @@ public function testUsersUpdate_WithDifferentAliases() $this->assertEquals($expected, $results, $msg); } - public function testUsersUpdate_NotThere() + public function testUsersUpdateNotThere() { $fixturesClass = new GoogleFixtures($this->dataFile); $fixturesClass->removeAllFixtures(); @@ -564,7 +564,7 @@ public function testUsersUpdate_NotThere() ObjectUtils::initialize($newUser, $userData); $newDir = new Directory('anyclient', $this->dataFile); - + $this->expectExceptionCode(201407101130); $newDir->users->update($userId, $newUser); } @@ -589,13 +589,13 @@ public function testUsersDelete() [ 'id' => 1, 'type' => 'directory', 'class' => 'user', 'data' => '{"primaryEmail":"user_test1@sil.org",' . - '"id":"999990"}' + '"id":"999990"}' ], [ 'id' => 2, 'type' => 'directory', 'class' => 'users_alias', 'data' => '{"alias":"users_alias2@sil.org","etag":null,' . - '"id":null,"kind":null,' . - '"primaryEmail":"user_test1@sil.org"}' + '"id":null,"kind":null,' . + '"primaryEmail":"user_test1@sil.org"}' ], [ 'id' => 3, 'type' => 'app_engine', 'class' => 'webapp', @@ -608,7 +608,7 @@ public function testUsersDelete() [ 'id' => 6, 'type' => 'directory', 'class' => 'users_alias', 'data' => '{"alias":"users_alias6@sil.org","etag":null,' . - '"id":"1","kind":null,"primaryEmail":null}' + '"id":"1","kind":null,"primaryEmail":null}' ], ]; @@ -616,7 +616,7 @@ public function testUsersDelete() $this->assertEquals($expected, $results, $msg); } - public function testUsersDelete_ById() + public function testUsersDeleteById() { $fixturesClass = new GoogleFixtures($this->dataFile); $fixturesClass->removeAllFixtures(); @@ -636,13 +636,13 @@ public function testUsersDelete_ById() [ 'id' => 1, 'type' => 'directory', 'class' => 'user', 'data' => '{"primaryEmail":"user_test1@sil.org",' . - '"id":"999990"}' + '"id":"999990"}' ], [ 'id' => 2, 'type' => 'directory', 'class' => 'users_alias', 'data' => '{"alias":"users_alias2@sil.org","etag":null,' . - '"id":null,"kind":null,' . - '"primaryEmail":"user_test1@sil.org"}' + '"id":null,"kind":null,' . + '"primaryEmail":"user_test1@sil.org"}' ], [ 'id' => 3, 'type' => 'app_engine', 'class' => 'webapp', @@ -655,7 +655,7 @@ public function testUsersDelete_ById() [ 'id' => 6, 'type' => 'directory', 'class' => 'users_alias', 'data' => '{"alias":"users_alias6@sil.org","etag":null,' . - '"id":"1","kind":null,"primaryEmail":null}' + '"id":"1","kind":null,"primaryEmail":null}' ], ]; @@ -681,7 +681,7 @@ public function testUsersAliasesInsert() $results = json_encode($newAlias); $expected = '{"alias":"users_alias1@sil.org","etag":null,"id":null,' . - '"kind":"personal","primaryEmail":"user_test1@sil.org"}' + '"kind":"personal","primaryEmail":"user_test1@sil.org"}' ; $msg = " *** Bad returned alias"; $this->assertEquals($expected, $results, $msg); @@ -697,7 +697,7 @@ public function testUsersAliasesInsert() $this->assertEquals($expected, $results, $msg); } - public function testUsersAliasesInsert_UserNotThere() + public function testUsersAliasesInsertUserNotThere() { $fixturesClass = new GoogleFixtures($this->dataFile); $fixturesClass->removeAllFixtures(); @@ -710,12 +710,12 @@ public function testUsersAliasesInsert_UserNotThere() $newAlias->kind = "personal"; $newDir = new Directory('anyclient', $this->dataFile); - + $this->expectExceptionCode(201407110830); $newDir->users_aliases->insert("no_user@sil.org", $newAlias); } - public function testUsersAliasesListUsersAliases_Email() + public function testUsersAliasesListUsersAliasesEmail() { $fixturesClass = new GoogleFixtures($this->dataFile); $fixturesClass->removeAllFixtures(); @@ -744,16 +744,16 @@ public function testUsersAliasesListUsersAliases_Email() $expected = [ '{"alias":"users_alias2@sil.org","etag":null,"id":null,' . - '"kind":null,"primaryEmail":"user_test1@sil.org"}', + '"kind":null,"primaryEmail":"user_test1@sil.org"}', '{"alias":"users_alias7@sil.org","etag":null,"id":"1",' . - '"kind":null,"primaryEmail":"user_test1@sil.org"}' + '"kind":null,"primaryEmail":"user_test1@sil.org"}' ]; $msg = " *** Bad returned Aliases"; $this->assertEquals($expected, $results, $msg); } - public function testUsersAliasesListUsersAliases_ID() + public function testUsersAliasesListUsersAliasesId() { $fixturesClass = new GoogleFixtures($this->dataFile); $fixturesClass->removeAllFixtures(); @@ -769,7 +769,7 @@ public function testUsersAliasesListUsersAliases_ID() [ 'directory', 'user', '{"id":"7","primaryEmail":"' . $email . '",' . - '"aliases":[]}' + '"aliases":[]}' ], ['directory', 'users_alias', json_encode($aliasB)], ['directory', 'users_alias', json_encode($aliasC)], @@ -786,16 +786,16 @@ public function testUsersAliasesListUsersAliases_ID() $expected = [ '{"alias":"users_alias7b@sil.org","etag":null,"id":"7","kind":null,' . - '"primaryEmail":"user_test7@sil.org"}', + '"primaryEmail":"user_test7@sil.org"}', '{"alias":"users_alias7c@sil.org","etag":null,"id":"7","kind":null,' . - '"primaryEmail":null}', + '"primaryEmail":null}', ]; $msg = " *** Bad returned Aliases"; $this->assertEquals($expected, $results, $msg); } - public function testUsersAliasesListUsersAliases_Structure() + public function testUsersAliasesListUsersAliasesStructure() { $fixturesClass = new GoogleFixtures($this->dataFile); $fixturesClass->removeAllFixtures(); @@ -832,7 +832,7 @@ public function testUsersAliasesListUsersAliases_Structure() $this->assertEquals($expected, $results, $msg); } - public function testUsersAliasesListUsersAliases_UserNotThere() + public function testUsersAliasesListUsersAliasesUserNotThere() { $fixturesClass = new GoogleFixtures($this->dataFile); $fixturesClass->removeAllFixtures(); @@ -850,7 +850,7 @@ public function testUsersAliasesListUsersAliases_UserNotThere() $fixturesClass->addFixtures($newFixtures); $newDir = new Directory('anyclient', $this->dataFile); - + $this->expectExceptionCode(201407101420); $newDir->users_aliases->listUsersAliases("no_user@sil.org"); } @@ -888,14 +888,14 @@ public function testUsersAliasesDelete() 'type' => 'directory', 'class' => 'users_alias', 'data' => '{"alias":"users_alias6@sil.org","etag":null,' . - '"id":"1","kind":null,"primaryEmail":null}', + '"id":"1","kind":null,"primaryEmail":null}', ], [ 'id' => '7', 'type' => 'directory', 'class' => 'users_alias', 'data' => '{"alias":"users_alias7@sil.org","etag":null,' . - '"id":"1","kind":null,"primaryEmail":"' . $email . '"}' + '"id":"1","kind":null,"primaryEmail":"' . $email . '"}' ], ]; $msg = " *** Mismatching users_aliases in db"; diff --git a/SilMock/tests/Google/Service/Gmail/Resource/UsersSettingsDelegatesTest.php b/SilMock/tests/Google/Service/Gmail/Resource/UsersSettingsDelegatesTest.php index d779ce7..ae13bdc 100644 --- a/SilMock/tests/Google/Service/Gmail/Resource/UsersSettingsDelegatesTest.php +++ b/SilMock/tests/Google/Service/Gmail/Resource/UsersSettingsDelegatesTest.php @@ -12,41 +12,41 @@ class UsersSettingsDelegatesTest extends TestCase { public $dataFile = DATAFILE4; - + protected function setUp(): void { $this->emptyFixturesDataFile(); } - + private function emptyFixturesDataFile() { $fixturesClass = new GoogleFixtures($this->dataFile); $fixturesClass->removeAllFixtures(); } - + protected function tearDown(): void { $this->emptyFixturesDataFile(); } - + public function testListUsersSettingsDelegates() { // Arrange: $accountEmail = 'john_smith@example.org'; $delegateEmail = 'mike_manager@example.org'; - + // Act $before = $this->getDelegatesForAccount($accountEmail); $this->delegateAccessToAccountBy($accountEmail, $delegateEmail); $after = $this->getDelegatesForAccount($accountEmail); - + // Assert: $delegatesBefore = $before->getDelegates(); Assert::assertEmpty($delegatesBefore); - + $delegatesAfter = $after->getDelegates(); Assert::assertNotEmpty($delegatesAfter); - + $foundExpectedDelegate = false; foreach ($delegatesAfter as $delegate) { if ($delegate->delegateEmail === $delegateEmail) { @@ -60,7 +60,7 @@ public function testListUsersSettingsDelegates() json_encode($delegatesAfter) )); } - + private function delegateAccessToAccountBy( string $accountEmail, string $delegateEmail @@ -73,7 +73,7 @@ private function delegateAccessToAccountBy( $gmailDelegate ); } - + private function getDelegatesForAccount(string $emailAddress): Google_Service_Gmail_ListDelegatesResponse { $userSettingsDelegates = new UsersSettingsDelegates($this->dataFile); diff --git a/SilMock/tests/Google/Service/Gmail/Resource/UsersSettingsForwardingAddressesTest.php b/SilMock/tests/Google/Service/Gmail/Resource/UsersSettingsForwardingAddressesTest.php index 84b181a..9fa1ef6 100644 --- a/SilMock/tests/Google/Service/Gmail/Resource/UsersSettingsForwardingAddressesTest.php +++ b/SilMock/tests/Google/Service/Gmail/Resource/UsersSettingsForwardingAddressesTest.php @@ -10,23 +10,23 @@ class UsersSettingsForwardingAddressesTest extends TestCase { public $dataFile = DATAFILE4; - + protected function setUp(): void { $this->emptyFixturesDataFile(); } - + private function emptyFixturesDataFile() { $fixturesClass = new GoogleFixtures($this->dataFile); $fixturesClass->removeAllFixtures(); } - + protected function tearDown(): void { $this->emptyFixturesDataFile(); } - + public function testListUsersSettingsForwardingAddresses() { $accountEmail = 'john_smith@example.org'; @@ -35,7 +35,7 @@ public function testListUsersSettingsForwardingAddresses() // Because this is totally a skeleton. Assert::assertEmpty($result); } - + public function testDelete() { $accountEmail = 'john_smith@example.org'; diff --git a/SilMock/tests/Sqlite/SqliteUtilsTest.php b/SilMock/tests/Sqlite/SqliteUtilsTest.php index a195159..9f52563 100644 --- a/SilMock/tests/Sqlite/SqliteUtilsTest.php +++ b/SilMock/tests/Sqlite/SqliteUtilsTest.php @@ -8,7 +8,20 @@ class SqliteUtilsTest extends TestCase { 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 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() { @@ -65,33 +78,33 @@ public function loadData(): SqliteUtils return $newSql; } - public function testGetData_All() + public function testGetDataAll() { $newSql = $this->loadData(); $results = $newSql->getData('', ''); $expected = array( array('id' => '1', - 'type' => 'directory', - 'class' => 'user', - 'data' => '{"primaryEmail":"user_test1@sil.org",' . - '"id":1,"password":"testPass1"}', - ), + 'type' => 'directory', + 'class' => 'user', + 'data' => '{"primaryEmail":"user_test1@sil.org",' . + '"id":1,"password":"testPass1"}', + ), array('id' => '2', - 'type' => 'directory', - 'class' => 'users_alias', - 'data' => '{"primaryEmail":"user_test1@sil.org",' . - '"alias":"users_alias2@sil.org"}', + 'type' => 'directory', + 'class' => 'users_alias', + 'data' => '{"primaryEmail":"user_test1@sil.org",' . + '"alias":"users_alias2@sil.org"}', ), array('id' => '3', - 'type' => 'app_engine', - 'class' => 'webapp', - 'data' => 'webapp3 test data', + 'type' => 'app_engine', + 'class' => 'webapp', + 'data' => 'webapp3 test data', ), array('id' => '4', - 'type' => 'directory', - 'class' => 'user', - 'data' => '{"primaryEmail":"user_test4@sil.org",' . - '"id":4,"password":"testPass4"}', + 'type' => 'directory', + 'class' => 'user', + 'data' => '{"primaryEmail":"user_test4@sil.org",' . + '"id":4,"password":"testPass4"}', ), array('id' => '5', 'type' => 'directory', @@ -110,7 +123,7 @@ public function testGetData_All() $this->assertEquals($expected, $results, $msg); } - public function testGetData_Directory() + public function testGetDataDirectory() { $newSql = $this->loadData(); $results = $newSql->getData('directory', ''); @@ -119,25 +132,25 @@ public function testGetData_Directory() 'type' => 'directory', 'class' => 'user', 'data' => '{"primaryEmail":"user_test1@sil.org",' . - '"id":1,"password":"testPass1"}', + '"id":1,"password":"testPass1"}', ), array('id' => '2', 'type' => 'directory', 'class' => 'users_alias', 'data' => '{"primaryEmail":"user_test1@sil.org",' . - '"alias":"users_alias2@sil.org"}', + '"alias":"users_alias2@sil.org"}', ), array('id' => '4', 'type' => 'directory', 'class' => 'user', 'data' => '{"primaryEmail":"user_test4@sil.org",' . - '"id":4,"password":"testPass4"}', + '"id":4,"password":"testPass4"}', ), array('id' => '5', 'type' => 'directory', 'class' => 'users_alias', 'data' => '{"primaryEmail":"user_test1@sil.org",' . - '"alias":"users_alias5@sil.org"}', + '"alias":"users_alias5@sil.org"}', ), array( 'id' => '6', @@ -150,29 +163,29 @@ public function testGetData_Directory() $this->assertEquals($expected, $results, $msg); } - public function testGetData_DirectoryUser() + public function testGetDataDirectoryUser() { $newSql = $this->loadData(); $results = $newSql->getData('directory', 'user'); $expected = array( array('id' => '1', - 'type' => 'directory', - 'class' => 'user', - 'data' => '{"primaryEmail":"user_test1@sil.org",' . - '"id":1,"password":"testPass1"}', + 'type' => 'directory', + 'class' => 'user', + 'data' => '{"primaryEmail":"user_test1@sil.org",' . + '"id":1,"password":"testPass1"}', ), array('id' => '4', 'type' => 'directory', 'class' => 'user', 'data' => '{"primaryEmail":"user_test4@sil.org",' . - '"id":4,"password":"testPass4"}', + '"id":4,"password":"testPass4"}', ), ); $msg = " *** Mismatched data results for user data."; $this->assertEquals($expected, $results, $msg); } - public function testGetData_NoMatches() + public function testGetDataNoMatches() { $newSql = $this->loadData(); $results = $newSql->getData('directory', 'no_there'); @@ -181,7 +194,7 @@ public function testGetData_NoMatches() $this->assertEquals($expected, $results, $msg); } - public function testGetData_EmptyFile() + public function testGetDataEmptyFile() { file_put_contents($this->dataFile, ''); $newSql = new SqliteUtils($this->dataFile); @@ -193,21 +206,21 @@ public function testGetData_EmptyFile() $this->assertEquals($expected, $results, $msg); } - public function testGetRecordByDataKey_DirectoryUserId() + public function testGetRecordByDataKeyDirectoryUserId() { $newSql = $this->loadData(); $results = $newSql->getRecordByDataKey('directory', 'user', 'id', 4); $expected = array('id' => '4', - 'type' => 'directory', - 'class' => 'user', - 'data' => '{"primaryEmail":"user_test4@sil.org",' . - '"id":4,"password":"testPass4"}', - ); + 'type' => 'directory', + 'class' => 'user', + 'data' => '{"primaryEmail":"user_test4@sil.org",' . + '"id":4,"password":"testPass4"}', + ); $msg = " *** Mismatched data results for user data."; $this->assertEquals($expected, $results, $msg); } - public function testGetRecordByDataKey_DirectoryUserPrimaryEmail() + public function testGetRecordByDataKeyDirectoryUserPrimaryEmail() { $newSql = $this->loadData(); $results = $newSql->getRecordByDataKey( @@ -226,7 +239,7 @@ public function testGetRecordByDataKey_DirectoryUserPrimaryEmail() $this->assertEquals($expected, $results, $msg); } - public function testGetAllRecordsByDataKey_DirectoryUsersAliasPrimaryEmail() + public function testGetAllRecordsByDataKeyDirectoryUsersAliasPrimaryEmail() { $newSql = $this->loadData(); $results = $newSql->getAllRecordsByDataKey( @@ -308,7 +321,7 @@ public function testDeleteRecordById() public function testDeleteDataByEmail() { $newSql = $this->loadData(); - $newSql->deleteDataByEmail('directory','', 'user_test1@sil.org'); + $newSql->deleteDataByEmail('directory', '', 'user_test1@sil.org'); $results = $newSql->getData('', ''); $expected = [ diff --git a/composer.lock b/composer.lock index 9fe2de9..107c53b 100644 --- a/composer.lock +++ b/composer.lock @@ -184,23 +184,23 @@ }, { "name": "google/auth", - "version": "v1.40.0", + "version": "v1.43.0", "source": { "type": "git", "url": "https://github.com/googleapis/google-auth-library-php.git", - "reference": "bff9f2d01677e71a98394b5ac981b99523df5178" + "reference": "b6a80acd906492086db59aada9196dcfb9c512fe" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/googleapis/google-auth-library-php/zipball/bff9f2d01677e71a98394b5ac981b99523df5178", - "reference": "bff9f2d01677e71a98394b5ac981b99523df5178", + "url": "https://api.github.com/repos/googleapis/google-auth-library-php/zipball/b6a80acd906492086db59aada9196dcfb9c512fe", + "reference": "b6a80acd906492086db59aada9196dcfb9c512fe", "shasum": "" }, "require": { "firebase/php-jwt": "^6.0", "guzzlehttp/guzzle": "^7.4.5", "guzzlehttp/psr7": "^2.4.5", - "php": "^8.0", + "php": "^8.1", "psr/cache": "^2.0||^3.0", "psr/http-message": "^1.1||^2.0" }, @@ -238,28 +238,28 @@ "support": { "docs": "https://googleapis.github.io/google-auth-library-php/main/", "issues": "https://github.com/googleapis/google-auth-library-php/issues", - "source": "https://github.com/googleapis/google-auth-library-php/tree/v1.40.0" + "source": "https://github.com/googleapis/google-auth-library-php/tree/v1.43.0" }, - "time": "2024-05-31T19:16:15+00:00" + "time": "2024-11-07T19:35:20+00:00" }, { "name": "guzzlehttp/guzzle", - "version": "7.8.1", + "version": "7.9.2", "source": { "type": "git", "url": "https://github.com/guzzle/guzzle.git", - "reference": "41042bc7ab002487b876a0683fc8dce04ddce104" + "reference": "d281ed313b989f213357e3be1a179f02196ac99b" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/guzzle/guzzle/zipball/41042bc7ab002487b876a0683fc8dce04ddce104", - "reference": "41042bc7ab002487b876a0683fc8dce04ddce104", + "url": "https://api.github.com/repos/guzzle/guzzle/zipball/d281ed313b989f213357e3be1a179f02196ac99b", + "reference": "d281ed313b989f213357e3be1a179f02196ac99b", "shasum": "" }, "require": { "ext-json": "*", - "guzzlehttp/promises": "^1.5.3 || ^2.0.1", - "guzzlehttp/psr7": "^1.9.1 || ^2.5.1", + "guzzlehttp/promises": "^1.5.3 || ^2.0.3", + "guzzlehttp/psr7": "^2.7.0", "php": "^7.2.5 || ^8.0", "psr/http-client": "^1.0", "symfony/deprecation-contracts": "^2.2 || ^3.0" @@ -270,9 +270,9 @@ "require-dev": { "bamarni/composer-bin-plugin": "^1.8.2", "ext-curl": "*", - "php-http/client-integration-tests": "dev-master#2c025848417c1135031fdf9c728ee53d0a7ceaee as 3.0.999", + "guzzle/client-integration-tests": "3.0.2", "php-http/message-factory": "^1.1", - "phpunit/phpunit": "^8.5.36 || ^9.6.15", + "phpunit/phpunit": "^8.5.39 || ^9.6.20", "psr/log": "^1.1 || ^2.0 || ^3.0" }, "suggest": { @@ -350,7 +350,7 @@ ], "support": { "issues": "https://github.com/guzzle/guzzle/issues", - "source": "https://github.com/guzzle/guzzle/tree/7.8.1" + "source": "https://github.com/guzzle/guzzle/tree/7.9.2" }, "funding": [ { @@ -366,20 +366,20 @@ "type": "tidelift" } ], - "time": "2023-12-03T20:35:24+00:00" + "time": "2024-07-24T11:22:20+00:00" }, { "name": "guzzlehttp/promises", - "version": "2.0.2", + "version": "2.0.4", "source": { "type": "git", "url": "https://github.com/guzzle/promises.git", - "reference": "bbff78d96034045e58e13dedd6ad91b5d1253223" + "reference": "f9c436286ab2892c7db7be8c8da4ef61ccf7b455" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/guzzle/promises/zipball/bbff78d96034045e58e13dedd6ad91b5d1253223", - "reference": "bbff78d96034045e58e13dedd6ad91b5d1253223", + "url": "https://api.github.com/repos/guzzle/promises/zipball/f9c436286ab2892c7db7be8c8da4ef61ccf7b455", + "reference": "f9c436286ab2892c7db7be8c8da4ef61ccf7b455", "shasum": "" }, "require": { @@ -387,7 +387,7 @@ }, "require-dev": { "bamarni/composer-bin-plugin": "^1.8.2", - "phpunit/phpunit": "^8.5.36 || ^9.6.15" + "phpunit/phpunit": "^8.5.39 || ^9.6.20" }, "type": "library", "extra": { @@ -433,7 +433,7 @@ ], "support": { "issues": "https://github.com/guzzle/promises/issues", - "source": "https://github.com/guzzle/promises/tree/2.0.2" + "source": "https://github.com/guzzle/promises/tree/2.0.4" }, "funding": [ { @@ -449,20 +449,20 @@ "type": "tidelift" } ], - "time": "2023-12-03T20:19:20+00:00" + "time": "2024-10-17T10:06:22+00:00" }, { "name": "guzzlehttp/psr7", - "version": "2.6.2", + "version": "2.7.0", "source": { "type": "git", "url": "https://github.com/guzzle/psr7.git", - "reference": "45b30f99ac27b5ca93cb4831afe16285f57b8221" + "reference": "a70f5c95fb43bc83f07c9c948baa0dc1829bf201" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/guzzle/psr7/zipball/45b30f99ac27b5ca93cb4831afe16285f57b8221", - "reference": "45b30f99ac27b5ca93cb4831afe16285f57b8221", + "url": "https://api.github.com/repos/guzzle/psr7/zipball/a70f5c95fb43bc83f07c9c948baa0dc1829bf201", + "reference": "a70f5c95fb43bc83f07c9c948baa0dc1829bf201", "shasum": "" }, "require": { @@ -477,8 +477,8 @@ }, "require-dev": { "bamarni/composer-bin-plugin": "^1.8.2", - "http-interop/http-factory-tests": "^0.9", - "phpunit/phpunit": "^8.5.36 || ^9.6.15" + "http-interop/http-factory-tests": "0.9.0", + "phpunit/phpunit": "^8.5.39 || ^9.6.20" }, "suggest": { "laminas/laminas-httphandlerrunner": "Emit PSR-7 responses" @@ -549,7 +549,7 @@ ], "support": { "issues": "https://github.com/guzzle/psr7/issues", - "source": "https://github.com/guzzle/psr7/tree/2.6.2" + "source": "https://github.com/guzzle/psr7/tree/2.7.0" }, "funding": [ { @@ -565,20 +565,20 @@ "type": "tidelift" } ], - "time": "2023-12-03T20:05:35+00:00" + "time": "2024-07-18T11:15:46+00:00" }, { "name": "monolog/monolog", - "version": "2.9.3", + "version": "2.10.0", "source": { "type": "git", "url": "https://github.com/Seldaek/monolog.git", - "reference": "a30bfe2e142720dfa990d0a7e573997f5d884215" + "reference": "5cf826f2991858b54d5c3809bee745560a1042a7" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/Seldaek/monolog/zipball/a30bfe2e142720dfa990d0a7e573997f5d884215", - "reference": "a30bfe2e142720dfa990d0a7e573997f5d884215", + "url": "https://api.github.com/repos/Seldaek/monolog/zipball/5cf826f2991858b54d5c3809bee745560a1042a7", + "reference": "5cf826f2991858b54d5c3809bee745560a1042a7", "shasum": "" }, "require": { @@ -655,7 +655,7 @@ ], "support": { "issues": "https://github.com/Seldaek/monolog/issues", - "source": "https://github.com/Seldaek/monolog/tree/2.9.3" + "source": "https://github.com/Seldaek/monolog/tree/2.10.0" }, "funding": [ { @@ -667,7 +667,7 @@ "type": "tidelift" } ], - "time": "2024-04-12T20:52:51+00:00" + "time": "2024-11-12T12:43:37+00:00" }, { "name": "paragonie/constant_time_encoding", @@ -788,16 +788,16 @@ }, { "name": "phpseclib/phpseclib", - "version": "3.0.38", + "version": "3.0.42", "source": { "type": "git", "url": "https://github.com/phpseclib/phpseclib.git", - "reference": "b18b8788e51156c4dd97b7f220a31149a0052067" + "reference": "db92f1b1987b12b13f248fe76c3a52cadb67bb98" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/phpseclib/phpseclib/zipball/b18b8788e51156c4dd97b7f220a31149a0052067", - "reference": "b18b8788e51156c4dd97b7f220a31149a0052067", + "url": "https://api.github.com/repos/phpseclib/phpseclib/zipball/db92f1b1987b12b13f248fe76c3a52cadb67bb98", + "reference": "db92f1b1987b12b13f248fe76c3a52cadb67bb98", "shasum": "" }, "require": { @@ -878,7 +878,7 @@ ], "support": { "issues": "https://github.com/phpseclib/phpseclib/issues", - "source": "https://github.com/phpseclib/phpseclib/tree/3.0.38" + "source": "https://github.com/phpseclib/phpseclib/tree/3.0.42" }, "funding": [ { @@ -894,7 +894,7 @@ "type": "tidelift" } ], - "time": "2024-06-17T10:11:32+00:00" + "time": "2024-09-16T03:06:04+00:00" }, { "name": "psr/cache", @@ -1398,16 +1398,16 @@ }, { "name": "myclabs/deep-copy", - "version": "1.12.0", + "version": "1.12.1", "source": { "type": "git", "url": "https://github.com/myclabs/DeepCopy.git", - "reference": "3a6b9a42cd8f8771bd4295d13e1423fa7f3d942c" + "reference": "123267b2c49fbf30d78a7b2d333f6be754b94845" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/myclabs/DeepCopy/zipball/3a6b9a42cd8f8771bd4295d13e1423fa7f3d942c", - "reference": "3a6b9a42cd8f8771bd4295d13e1423fa7f3d942c", + "url": "https://api.github.com/repos/myclabs/DeepCopy/zipball/123267b2c49fbf30d78a7b2d333f6be754b94845", + "reference": "123267b2c49fbf30d78a7b2d333f6be754b94845", "shasum": "" }, "require": { @@ -1446,7 +1446,7 @@ ], "support": { "issues": "https://github.com/myclabs/DeepCopy/issues", - "source": "https://github.com/myclabs/DeepCopy/tree/1.12.0" + "source": "https://github.com/myclabs/DeepCopy/tree/1.12.1" }, "funding": [ { @@ -1454,20 +1454,20 @@ "type": "tidelift" } ], - "time": "2024-06-12T14:39:25+00:00" + "time": "2024-11-08T17:47:46+00:00" }, { "name": "nikic/php-parser", - "version": "v5.0.2", + "version": "v5.3.1", "source": { "type": "git", "url": "https://github.com/nikic/PHP-Parser.git", - "reference": "139676794dc1e9231bf7bcd123cfc0c99182cb13" + "reference": "8eea230464783aa9671db8eea6f8c6ac5285794b" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/nikic/PHP-Parser/zipball/139676794dc1e9231bf7bcd123cfc0c99182cb13", - "reference": "139676794dc1e9231bf7bcd123cfc0c99182cb13", + "url": "https://api.github.com/repos/nikic/PHP-Parser/zipball/8eea230464783aa9671db8eea6f8c6ac5285794b", + "reference": "8eea230464783aa9671db8eea6f8c6ac5285794b", "shasum": "" }, "require": { @@ -1478,7 +1478,7 @@ }, "require-dev": { "ircmaxell/php-yacc": "^0.0.7", - "phpunit/phpunit": "^7.0 || ^8.0 || ^9.0" + "phpunit/phpunit": "^9.0" }, "bin": [ "bin/php-parse" @@ -1510,9 +1510,9 @@ ], "support": { "issues": "https://github.com/nikic/PHP-Parser/issues", - "source": "https://github.com/nikic/PHP-Parser/tree/v5.0.2" + "source": "https://github.com/nikic/PHP-Parser/tree/v5.3.1" }, - "time": "2024-03-05T20:51:40+00:00" + "time": "2024-10-08T18:51:32+00:00" }, { "name": "phar-io/manifest", @@ -1634,35 +1634,35 @@ }, { "name": "phpunit/php-code-coverage", - "version": "9.2.31", + "version": "9.2.32", "source": { "type": "git", "url": "https://github.com/sebastianbergmann/php-code-coverage.git", - "reference": "48c34b5d8d983006bd2adc2d0de92963b9155965" + "reference": "85402a822d1ecf1db1096959413d35e1c37cf1a5" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/sebastianbergmann/php-code-coverage/zipball/48c34b5d8d983006bd2adc2d0de92963b9155965", - "reference": "48c34b5d8d983006bd2adc2d0de92963b9155965", + "url": "https://api.github.com/repos/sebastianbergmann/php-code-coverage/zipball/85402a822d1ecf1db1096959413d35e1c37cf1a5", + "reference": "85402a822d1ecf1db1096959413d35e1c37cf1a5", "shasum": "" }, "require": { "ext-dom": "*", "ext-libxml": "*", "ext-xmlwriter": "*", - "nikic/php-parser": "^4.18 || ^5.0", + "nikic/php-parser": "^4.19.1 || ^5.1.0", "php": ">=7.3", - "phpunit/php-file-iterator": "^3.0.3", - "phpunit/php-text-template": "^2.0.2", - "sebastian/code-unit-reverse-lookup": "^2.0.2", - "sebastian/complexity": "^2.0", - "sebastian/environment": "^5.1.2", - "sebastian/lines-of-code": "^1.0.3", - "sebastian/version": "^3.0.1", - "theseer/tokenizer": "^1.2.0" + "phpunit/php-file-iterator": "^3.0.6", + "phpunit/php-text-template": "^2.0.4", + "sebastian/code-unit-reverse-lookup": "^2.0.3", + "sebastian/complexity": "^2.0.3", + "sebastian/environment": "^5.1.5", + "sebastian/lines-of-code": "^1.0.4", + "sebastian/version": "^3.0.2", + "theseer/tokenizer": "^1.2.3" }, "require-dev": { - "phpunit/phpunit": "^9.3" + "phpunit/phpunit": "^9.6" }, "suggest": { "ext-pcov": "PHP extension that provides line coverage", @@ -1671,7 +1671,7 @@ "type": "library", "extra": { "branch-alias": { - "dev-master": "9.2-dev" + "dev-main": "9.2.x-dev" } }, "autoload": { @@ -1700,7 +1700,7 @@ "support": { "issues": "https://github.com/sebastianbergmann/php-code-coverage/issues", "security": "https://github.com/sebastianbergmann/php-code-coverage/security/policy", - "source": "https://github.com/sebastianbergmann/php-code-coverage/tree/9.2.31" + "source": "https://github.com/sebastianbergmann/php-code-coverage/tree/9.2.32" }, "funding": [ { @@ -1708,7 +1708,7 @@ "type": "github" } ], - "time": "2024-03-02T06:37:42+00:00" + "time": "2024-08-22T04:23:01+00:00" }, { "name": "phpunit/php-file-iterator", @@ -1953,45 +1953,45 @@ }, { "name": "phpunit/phpunit", - "version": "9.6.19", + "version": "9.6.21", "source": { "type": "git", "url": "https://github.com/sebastianbergmann/phpunit.git", - "reference": "a1a54a473501ef4cdeaae4e06891674114d79db8" + "reference": "de6abf3b6f8dd955fac3caad3af7a9504e8c2ffa" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/sebastianbergmann/phpunit/zipball/a1a54a473501ef4cdeaae4e06891674114d79db8", - "reference": "a1a54a473501ef4cdeaae4e06891674114d79db8", + "url": "https://api.github.com/repos/sebastianbergmann/phpunit/zipball/de6abf3b6f8dd955fac3caad3af7a9504e8c2ffa", + "reference": "de6abf3b6f8dd955fac3caad3af7a9504e8c2ffa", "shasum": "" }, "require": { - "doctrine/instantiator": "^1.3.1 || ^2", + "doctrine/instantiator": "^1.5.0 || ^2", "ext-dom": "*", "ext-json": "*", "ext-libxml": "*", "ext-mbstring": "*", "ext-xml": "*", "ext-xmlwriter": "*", - "myclabs/deep-copy": "^1.10.1", - "phar-io/manifest": "^2.0.3", - "phar-io/version": "^3.0.2", + "myclabs/deep-copy": "^1.12.0", + "phar-io/manifest": "^2.0.4", + "phar-io/version": "^3.2.1", "php": ">=7.3", - "phpunit/php-code-coverage": "^9.2.28", - "phpunit/php-file-iterator": "^3.0.5", + "phpunit/php-code-coverage": "^9.2.32", + "phpunit/php-file-iterator": "^3.0.6", "phpunit/php-invoker": "^3.1.1", - "phpunit/php-text-template": "^2.0.3", - "phpunit/php-timer": "^5.0.2", - "sebastian/cli-parser": "^1.0.1", - "sebastian/code-unit": "^1.0.6", + "phpunit/php-text-template": "^2.0.4", + "phpunit/php-timer": "^5.0.3", + "sebastian/cli-parser": "^1.0.2", + "sebastian/code-unit": "^1.0.8", "sebastian/comparator": "^4.0.8", - "sebastian/diff": "^4.0.3", - "sebastian/environment": "^5.1.3", - "sebastian/exporter": "^4.0.5", - "sebastian/global-state": "^5.0.1", - "sebastian/object-enumerator": "^4.0.3", - "sebastian/resource-operations": "^3.0.3", - "sebastian/type": "^3.2", + "sebastian/diff": "^4.0.6", + "sebastian/environment": "^5.1.5", + "sebastian/exporter": "^4.0.6", + "sebastian/global-state": "^5.0.7", + "sebastian/object-enumerator": "^4.0.4", + "sebastian/resource-operations": "^3.0.4", + "sebastian/type": "^3.2.1", "sebastian/version": "^3.0.2" }, "suggest": { @@ -2036,7 +2036,7 @@ "support": { "issues": "https://github.com/sebastianbergmann/phpunit/issues", "security": "https://github.com/sebastianbergmann/phpunit/security/policy", - "source": "https://github.com/sebastianbergmann/phpunit/tree/9.6.19" + "source": "https://github.com/sebastianbergmann/phpunit/tree/9.6.21" }, "funding": [ { @@ -2052,7 +2052,7 @@ "type": "tidelift" } ], - "time": "2024-04-05T04:35:58+00:00" + "time": "2024-09-19T10:50:18+00:00" }, { "name": "sebastian/cli-parser",