Beispiel #1
0
 public function testUpdateUser()
 {
     if (!$this->doTest(__FUNCTION__)) {
         return;
     }
     //perform assertion
     $this->assertEquals(GoCoin::getApiMode(), 'test');
     $this->assertNotEmpty(TOKEN);
     //get the current user
     $user = GoCoin::getUser(TOKEN, USER_ID);
     //show the results
     echo '[DEBUG]: Updating :' . $user->id . "\n";
     //create an array of fields to update, NOTE: id is required
     $last_name = $user->last_name;
     $updates = array('id' => $user->id, 'last_name' => $last_name . ' updated');
     //update the user
     $updated = GoCoin::updateUser(TOKEN, $updates);
     //make sure we got a successful response back
     $this->assertTrue(property_exists($updated, 'last_name'));
     //show the results
     echo '[DEBUG]: Updated last name: ' . $updated->last_name . "\n";
     //perform assertion
     $this->assertEquals($updated->last_name, $last_name . ' updated');
     //reset the last name
     $updates['last_name'] = $last_name;
     $updated = GoCoin::updateUser(TOKEN, $updates);
     //make sure we got a successful response back
     $this->assertTrue(property_exists($updated, 'last_name'));
     //show the results
     echo '[DEBUG]: Reset last name: ' . $updated->last_name . "\n";
     //perform assertion
     $this->assertEquals($updated->last_name, $last_name);
     echo '[DEBUG]: SUCCESS' . "\n";
 }
Beispiel #2
0
<?php

ini_set('display_errors', 1);
//include the config and the gocoin api
require_once __DIR__ . '/../includes/config.php';
require_once __DIR__ . '/../includes/functions.php';
require_once __DIR__ . '/../../src/GoCoinAdmin.php';
//pick a token
$token = $TOKENS['full_access'];
//echo an HTML block
echo '<html><head><title>GoCoin Admin User Test</title></head><body>' . "\n";
//get the current user
$user = GoCoin::getUser($token);
//get a list of users (admin only function)
$users = GoCoinAdmin::listUsers($token);
//show the current user
echo '<hr/>' . "\n";
echo '<h3 style="color:blue">Current User</h3>';
showObject($user);
//show the application users
echo '<hr/>' . "\n";
echo '<h3 style="color:blue">Application Users</h3>';
if (!empty($users)) {
    foreach ($users as $u) {
        showObject($u);
        echo '<hr/>' . "\n";
        break;
    }
    echo '<div style="color:#aa0000">NOTE: There are ' . (sizeof($users) - 1) . ' other users not shown</div>';
}
//create user tests
Beispiel #3
0
<?php

ini_set('display_errors', 1);
//include the config and the gocoin api
require_once __DIR__ . '/includes/config.php';
require_once __DIR__ . '/includes/functions.php';
require_once __DIR__ . '/../src/GoCoin.php';
//pick a token
$token = $TOKENS['full_access'];
//echo an HTML block
echo '<html><head><title>GoCoin User Test</title></head><body>' . "\n";
//get the current user
$user = GoCoin::getUser($token);
//get a specific user
$specific = GoCoin::getUser($token, USER_ID);
//get the exchange rate from the gocoin web service
$exchange = GoCoin::getExchangeRates();
//echo an HTML block
echo '<html><head><title>GoCoin User Test</title></head><body>' . "\n";
//get the current version
echo '<h3 style="color:blue">Library Version</h3>';
$version = GoCoin::getVersion();
echo '<ul><li>' . $version . '</li></ul>';
//show the current exchange
echo '<h3 style="color:blue">Current Exchange</h3>';
showObject($exchange);
//show the current user
echo '<hr/>' . "\n";
echo '<h3 style="color:blue">Current User</h3>';
showObject($user);
//show the specific user