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"; }
echo '<h3 style="color:blue">Specific User</h3>'; showObject($specific); //update user tests $UPDATE = FALSE; if ($UPDATE) { //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); //show the updates echo '<h3 style="color:blue">Updated User</h3>'; showObject($updated); //reset the last name $updates['last_name'] = $last_name; GoCoin::updateUser($token, $updates); } //show the applications echo '<h3 style="color:blue">Applications</h3>'; //get the user applications $apps = GoCoin::getUserApplications($token, USER_ID); foreach ($apps as $app) { showObject($app); } //update password tests $PASSWORD = FALSE; if ($PASSWORD) { echo '<h3 style="color:blue">Password Update Test</h3>'; //an array to update the password $pw_array = array("current_password" => "passw0rd", "password" => "newpassw0rd", "password_confirmation" => "newpassw0rd"); //update the password