-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
2 changed files
with
67 additions
and
5 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -81,7 +81,7 @@ public function testListMembersAll() | |
try { | ||
$members = $mockGoogleServiceDirectory->members->listMembers($groupEmailAddress); | ||
} catch (Exception $exception) { | ||
$this->failure($exception); | ||
$this->failure($exception, 'listMembersAll'); | ||
} | ||
self::assertNotEmpty( | ||
$members->getMembers(), | ||
|
@@ -102,7 +102,7 @@ public function testListMembersOnlyMember() | |
] | ||
); | ||
} catch (Exception $exception) { | ||
$this->failure($exception); | ||
$this->failure($exception, 'listMembersOnlyMember'); | ||
} | ||
self::assertNotEmpty( | ||
$members->getMembers(), | ||
|
@@ -123,19 +123,66 @@ public function testListMembersOnlyOwner() | |
] | ||
); | ||
} catch (Exception $exception) { | ||
$this->failure($exception); | ||
$this->failure($exception, 'listMembersOnlyOwner'); | ||
} | ||
self::assertEmpty( | ||
$members->getMembers(), | ||
'Was expecting the members.list method to have no owner types.' | ||
); | ||
} | ||
|
||
protected function failure(Exception $exception): void | ||
public function testDelete() | ||
{ | ||
$mockGoogleServiceDirectory = new GoogleMock_Directory('anyclient', $this->dataFile); | ||
$groupEmailAddress = '[email protected]'; | ||
$emailAddress = '[email protected]'; | ||
try { | ||
$result = $mockGoogleServiceDirectory->members->hasMember( | ||
$groupEmailAddress, | ||
$emailAddress | ||
); | ||
$hasMember = $result['isMember'] ?? false; | ||
} catch (Exception $exception) { | ||
self::fail( | ||
$exception->getMessage() | ||
); | ||
} | ||
|
||
if (! $hasMember) { | ||
$member = new GoogleDirectory_Member(); | ||
$member->setEmail($emailAddress); | ||
$member->setRole('MEMBER'); | ||
$mockGoogleServiceDirectory->members->insert($groupEmailAddress, $member); | ||
} | ||
$mockGoogleServiceDirectory->members->delete($groupEmailAddress, $emailAddress); | ||
|
||
try { | ||
$result = $mockGoogleServiceDirectory->members->hasMember( | ||
$groupEmailAddress, | ||
'[email protected]' | ||
); | ||
$hasMember = $result['isMember'] ?? false; | ||
} catch (Exception $exception) { | ||
self::fail( | ||
$exception->getMessage() | ||
); | ||
} | ||
self::assertFalse( | ||
$hasMember, | ||
sprintf( | ||
'Failed to delete %s from group %s', | ||
$emailAddress, | ||
$groupEmailAddress | ||
) | ||
); | ||
} | ||
|
||
protected function failure(Exception $exception, string $function): void | ||
{ | ||
self::fail( | ||
sprintf( | ||
'Was expecting the members.insert method to function, but got: %s', | ||
'Was expecting the %s method to function, but got: %s', | ||
$function, | ||
$exception->getMessage() | ||
) | ||
); | ||
|