示例#1
0
 /**
  * Remove generated namespaces and groups
  */
 public static function cleanup()
 {
     $pn = new Pubnub(static::$keys);
     $result = $pn->channelGroupListGroups();
     $groups = $result["payload"]["groups"];
     foreach ($groups as $groupName) {
         // WARNING: Check $groups for temporary generated groups if some tests fails.
         if (strpos($groupName, 'ptest') !== false) {
             $result = $pn->channelGroupRemoveGroup($groupName);
             if ($result['message'] === "OK") {
                 //                    print_r("Successfully removed group " . $groupName . "\n");
             }
         }
     }
     $result = $pn->channelGroupListNamespaces();
     $namespaces = $result["payload"]["namespaces"];
     foreach ($namespaces as $namespace) {
         if (strpos($namespace, 'ptest') !== false) {
             $result = $pn->channelGroupRemoveNamespace($namespace);
             if ($result['message'] === "OK") {
                 //                    print_r("Successfully removed namespace " . $namespace . "\n");
             }
         }
     }
 }