@@ -37,6 +37,57 @@ public function testInsert()
3737 self ::assertTrue ($ addedGroup instanceof GoogleDirectory_Group);
3838 }
3939
40+ public function testDelete ()
41+ {
42+ // Set update a deletable email address
43+ $ group = new GoogleDirectory_Group ();
44+ $ group ->setEmail (self ::GROUP_EMAIL_ADDRESS . 'delete ' );
45+ $ group ->setAliases ([]);
46+ $ group ->setName ('Sample Deletable Group ' );
47+ $ group ->setDescription ('A Sample Deletable Group used for testing ' );
48+
49+ $ mockGoogleServiceDirectory = new GoogleMock_Directory ('anyclient ' , $ this ->dataFile );
50+ try {
51+ $ addedGroup = $ mockGoogleServiceDirectory ->groups ->insert ($ group );
52+ } catch (Exception $ exception ) {
53+ self ::fail (
54+ sprintf (
55+ 'Was expecting the groups.insert method to function, but got: %s ' ,
56+ $ exception ->getMessage ()
57+ )
58+ );
59+ }
60+ self ::assertTrue ($ addedGroup instanceof GoogleDirectory_Group);
61+
62+ // Now try to delete it
63+ $ mockGoogleServiceDirectory = new GoogleMock_Directory ('anyclient ' , $ this ->dataFile );
64+ try {
65+ $ mockGoogleServiceDirectory ->groups ->delete (self ::GROUP_EMAIL_ADDRESS . 'delete ' );
66+ } catch (Exception $ exception ) {
67+ self ::fail (
68+ sprintf (
69+ 'Was expecting the groups.delete method to function, but got: %s ' ,
70+ $ exception ->getMessage ()
71+ )
72+ );
73+ }
74+
75+ try {
76+ $ group = $ mockGoogleServiceDirectory ->groups ->get (self ::GROUP_EMAIL_ADDRESS . 'delete ' );
77+ self ::assertNull (
78+ $ group ,
79+ 'Was expecting the group to be deleted, but found something '
80+ );
81+ } catch (Exception $ exception ) {
82+ self ::fail (
83+ sprintf (
84+ 'Was expecting to confirm the group was deleted, but got: %s ' ,
85+ $ exception ->getMessage ()
86+ )
87+ );
88+ }
89+ }
90+
4091 public function testGet ()
4192 {
4293 $ mockGoogleServiceDirectory = new GoogleMock_Directory ('anyclient ' , $ this ->dataFile );
0 commit comments