default_api.server_groups.crud.php #1

  • //
  • guest/
  • perforce_software/
  • helix-web-services/
  • main/
  • source/
  • client-php/
  • tests/
  • default_api.server_groups.crud.php
  • View
  • Commits
  • Open Download .zip Download (1 KB)
<?php

include 'util/test_config.php';
include 'util/string_utils.php';

$api = apiAsSuper();

$rand = generateRandomString();

$group_id = "test-group-$rand";

$group_command = new HelixWebServices\Model\GroupCommand([
    "group" => $group_id,
    "users" => ["jdoe"],
    "owners"=> ["jdoe"]
]);

$api->serverGroupsPost("localhost", $group_command);

$all_groups = $api->serverGroupsGet('localhost');

$has_group_id = array_filter($all_groups, function($b) {
    global $group_id;
    return $b->getGroup() == $group_id;
});
assert(count($has_group_id) == 1);

$saved_group = $api->serverGroupsGroupGet('localhost', $group_id);

assert($saved_group->getUsers() == $group_command->getUsers());
assert($saved_group->getOwners() == $group_command->getOwners());

$to_update = new HelixWebServices\Model\GroupCommand([
    "users" => ["mmustermann"]
]);

$api->serverGroupsGroupPatch('localhost', $group_id, $to_update);

$updated = $api->serverGroupsGroupGet('localhost', $group_id);

assert($updated->getUsers() == $to_update->getUsers());

$api->serverGroupsGroupDelete('localhost', $group_id);

$all_groups2 = $api->serverGroupsGet('localhost');

if (!empty($all_groups2)) {
    $has_group_id2 = array_filter($all_groups2, function($b) {
        global $group_id;
        return $b->getGroup() == $group_id;
    });
    assert(count($has_group_id2) == 0);
}

# Change User Description Committed
#1 19553 swellard Move and rename clients
//guest/perforce_software/helix-web-services/main/source/clients/2016.1.0/php/tests/default_api.server_groups.crud.php
#1 19255 tjuricek Change, client, command tests for PHP Client SDK.

Changed how array-like query parameters were passed to the server to be consistent with other SDKs.