function testGroupsController() { // Use a batch standin, which acts like a Google_Http_Batch, but // merely accumulates the requests added to it, and returns them // to us when requested. $batch = new BatchWrapper(); // Create a new Google Apps group controller, and add some users // and groups to it. $controller = new GoogleAppsGroupsController($this->client, $batch); $presidentProperties = array('group-email' => '*****@*****.**', 'group-id' => '*****@*****.**', 'group-name' => 'North President'); $vicePresidentProperties = array('group-email' => '*****@*****.**', 'group-id' => '*****@*****.**', 'group-name' => 'North Vice-President'); $op = new Operation('placeholderOperation', array()); $controller->insertOffice($op, 'north', 'president', $presidentProperties); $controller->configureOffice($op, 'north', 'president', $presidentProperties); $controller->insertMember($op, 'north', 'president', $presidentProperties['group-id'], '*****@*****.**'); $controller->insertGroupAlternateAddress($op, 'north', 'president', $presidentProperties['group-id'], '*****@*****.**'); $controller->removeMember($op, 'north', 'president', $presidentProperties['group-id'], '*****@*****.**'); $controller->removeGroupAlternateAddress($op, 'north', 'president', $presidentProperties['group-id'], '*****@*****.**'); $controller->insertMember($op, 'north', 'vice-president', $vicePresidentProperties['group-id'], '*****@*****.**'); $controller->removeMember($op, 'north', 'vice-president', $vicePresidentProperties['group-id'], '*****@*****.**'); $controller->deleteOffice($op, 'north', 'president', $presidentProperties); // The expected list of requests corresponding to the calls above: $expected = <<<EOT - requestMethod: POST url: /admin/directory/v1/groups email: north-president@testdomain.org name: 'North President' - requestMethod: PATCH url: /groups/v1/groups/north-president%40testdomain.org isArchived: true whoCanJoin: INVITED_CAN_JOIN whoCanPostMessage: ANYONE_CAN_POST - requestMethod: POST url: /admin/directory/v1/groups/north-president%40testdomain.org/members email: franklin@testdomain.org role: MEMBER type: USER - requestMethod: POST url: /admin/directory/v1/groups/north-president%40testdomain.org/aliases alias: elpresidente@testdomain.org - requestMethod: DELETE url: /admin/directory/v1/groups/north-president%40testdomain.org/members/franklin%40testdomain.org - requestMethod: DELETE url: /admin/directory/v1/groups/north-president%40testdomain.org/aliases/elpresidente%40testdomain.org - requestMethod: POST url: /admin/directory/v1/groups/north-vicepresident%40testdomain.org/members email: garner@testdomain.org role: MEMBER type: USER - requestMethod: DELETE url: /admin/directory/v1/groups/north-vicepresident%40testdomain.org/members/garner%40testdomain.org - requestMethod: DELETE url: /admin/directory/v1/groups/north-president%40testdomain.org EOT; $requests = $batch->getSimplifiedRequests(); $this->assertEquals(trim($expected), $this->arrayToYaml($requests)); }