-
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.
Add groups.get and a corresponding test
- Loading branch information
Showing
2 changed files
with
30 additions
and
16 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 |
---|---|---|
|
@@ -12,51 +12,53 @@ class GroupsTest extends TestCase | |
// GroupsTest and MembersTest need to share same DB, also | ||
// They are very dependent on order run. | ||
// groups.insert, groups.listGroups, members.insert, members.listMembers | ||
public $dataFile = DATAFILE5; | ||
public string $dataFile = DATAFILE5; | ||
public const GROUP_EMAIL_ADDRESS = '[email protected]'; | ||
|
||
public function testInsert() | ||
{ | ||
$groupEmailAddress = '[email protected]'; | ||
|
||
$group = new GoogleDirectory_Group(); | ||
$group->setEmail($groupEmailAddress); | ||
$group->setEmail(self::GROUP_EMAIL_ADDRESS); | ||
$group->setAliases([]); | ||
$group->setName('Sample Group'); | ||
$group->setDescription('A Sample Group used for testing'); | ||
|
||
$mockGoogleServiceDirectory = new GoogleMock_Directory('anyclient', $this->dataFile); | ||
try { | ||
$groups = $mockGoogleServiceDirectory->groups->listGroups($groupEmailAddress); | ||
$addedGroup = $mockGoogleServiceDirectory->groups->insert($group); | ||
} catch (Exception $exception) { | ||
$this->assertFalse( | ||
true, | ||
self::fail( | ||
sprintf( | ||
'Was expecting the groups.insert method to function, but got: %s', | ||
$exception->getMessage() | ||
) | ||
); | ||
} | ||
$this->assertTrue($addedGroup instanceof GoogleDirectory_Group); | ||
self::assertTrue($addedGroup instanceof GoogleDirectory_Group); | ||
} | ||
|
||
public function testGet() | ||
{ | ||
$mockGoogleServiceDirectory = new GoogleMock_Directory('anyclient', $this->dataFile); | ||
$group = $mockGoogleServiceDirectory->groups->get(self::GROUP_EMAIL_ADDRESS); | ||
self::assertInstanceOf(GoogleDirectory_Group::class, $group); | ||
} | ||
|
||
public function testListGroups() | ||
{ | ||
$groupEmailAddress = '[email protected]'; | ||
$mockGoogleServiceDirectory = new GoogleMock_Directory('anyclient', $this->dataFile); | ||
$groups = []; | ||
try { | ||
$groups = $mockGoogleServiceDirectory->groups->listGroups($groupEmailAddress); | ||
$groups = $mockGoogleServiceDirectory->groups->listGroups(self::GROUP_EMAIL_ADDRESS); | ||
} catch (Exception $exception) { | ||
$this->assertFalse( | ||
true, | ||
self::fail( | ||
sprintf( | ||
'Was expecting the groups.list method to function, but got: %s', | ||
$exception->getMessage() | ||
) | ||
); | ||
} | ||
$this->assertNotEmpty( | ||
self::assertNotEmpty( | ||
$groups, | ||
'Was expecting the groups.list method to have at least one group.' | ||
); | ||
|