/**
  * Revoke access for a group from an API key that has access to all groups
  */
 public function testKeyRemoveLibraryFromAllGroupsNotification()
 {
     API::useAPIKey("");
     $removedGroup = self::$config['ownedPrivateGroupID'];
     $json = $this->createKeyWithAllGroupAccess(self::$config['userID']);
     $apiKey = $json['key'];
     try {
         // Get list of available groups
         API::useAPIKey($apiKey);
         $response = API::userGet(self::$config['userID'], 'groups');
         $groupIDs = array_map(function ($group) {
             return $group['id'];
         }, API::getJSONFromResponse($response));
         // Remove one group, and replace access array with new set
         $groupIDs = array_diff($groupIDs, [$removedGroup]);
         unset($json['access']['groups']['all']);
         foreach ($groupIDs as $groupID) {
             $json['access']['groups'][$groupID]['library'] = true;
         }
         // Post new JSON, which should trigger topicRemoved for the removed group
         API::useAPIKey("");
         $response = API::superPut("keys/{$apiKey}", json_encode($json));
         $this->assert200($response);
         $this->assertCountNotifications(1, $response);
         foreach ($groupIDs as $groupID) {
             $this->assertHasNotification(['event' => 'topicRemoved', 'apiKey' => $apiKey, 'topic' => '/groups/' . $removedGroup], $response);
         }
     } finally {
         $response = API::superDelete("keys/{$apiKey}");
     }
 }