public function testAddRemoveGroupMemberNotification() { API::useAPIKey(""); $json = $this->createKeyWithAllGroupAccess(self::$config['userID']); $apiKey = $json['key']; try { // Get all keys with access to all groups $allGroupsKeys = $this->getKeysWithAllGroupAccess(self::$config['userID']); // Create group owned by another user $response = $this->createGroup(self::$config['userID2']); $xml = API::getXMLFromResponse($response); $groupID = (int) $xml->xpath("/atom:entry/zapi:groupID")[0]; try { // Add user to group $response = API::superPost("groups/{$groupID}/users", '<user id="' . self::$config['userID'] . '" role="member"/>'); $this->assert200($response); $this->assertCountNotifications(sizeOf($allGroupsKeys), $response); foreach ($allGroupsKeys as $key) { $this->assertHasNotification(['event' => 'topicAdded', 'apiKey' => $key, 'topic' => '/groups/' . $groupID], $response); } // Remove user from group $response = API::superDelete("groups/{$groupID}/users/" . self::$config['userID']); $this->assert204($response); $this->assertCountNotifications(sizeOf($allGroupsKeys), $response); foreach ($allGroupsKeys as $key) { $this->assertHasNotification(['event' => 'topicRemoved', 'apiKey' => $key, 'topic' => '/groups/' . $groupID], $response); } } finally { $response = API::superDelete("groups/{$groupID}"); $this->assert204($response); $this->assertCountNotifications(1, $response); $this->assertHasNotification(['event' => 'topicDeleted', 'topic' => '/groups/' . $groupID], $response); } } finally { $response = API::superDelete("keys/{$apiKey}"); try { $this->assert204($response); } catch (Exception $e) { var_dump($e); } } }