default_api.server_clients.crud.php #1

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

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

$api = apiAsJDoe();

$rand = generateRandomString();

$client_id = "test-client-$rand";

$client_command = new HelixWebServices\Model\ClientCommand([
    "client" => $client_id,
    "host" => null,
    "altRoots" => ['/alt/1', '/alt/2']
]);

$api->serverClientsPost("localhost", $client_command);

$all_clients = $api->serverClientsGet('localhost');

$has_client_id = array_filter($all_clients, function($b) {
    global $client_id;
    return $b->getClient() == $client_id;
});
assert(count($has_client_id) == 1);

$saved_client = $api->serverClientsClientGet('localhost', $client_id);

assert($saved_client->getAltRoots() == $client_command->getAltRoots());

$to_update = new HelixWebServices\Model\ClientCommand([
    "description" => "Update $rand"
]);

$api->serverClientsClientPatch('localhost', $client_id, $to_update);

$updated = $api->serverClientsClientGet('localhost', $client_id);

assert(trim($updated->getDescription()) == trim($to_update->getDescription()));

$api->serverClientsClientDelete('localhost', $client_id);

$all_clients2 = $api->serverClientsGet('localhost');

assert(empty($all_clients2));

# 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_clients.crud.php
#1 19242 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.