mirror of
https://github.com/friendica/friendica
synced 2024-12-22 19:20:17 +00:00
Re enable UpdateProfile test
This commit is contained in:
parent
226f6038de
commit
6b03ee2922
3 changed files with 41 additions and 37 deletions
|
@ -39,17 +39,17 @@ class UpdateProfile extends BaseApi
|
|||
|
||||
$api_user = DI::twitterUser()->createFromUserId($uid, true)->toArray();
|
||||
|
||||
if (!empty($_POST['name'])) {
|
||||
DBA::update('profile', ['name' => $_POST['name']], ['uid' => $uid]);
|
||||
DBA::update('user', ['username' => $_POST['name']], ['uid' => $uid]);
|
||||
Contact::update(['name' => $_POST['name']], ['uid' => $uid, 'self' => 1]);
|
||||
Contact::update(['name' => $_POST['name']], ['id' => $api_user['id']]);
|
||||
if (!empty($request['name'])) {
|
||||
DBA::update('profile', ['name' => $request['name']], ['uid' => $uid]);
|
||||
DBA::update('user', ['username' => $request['name']], ['uid' => $uid]);
|
||||
Contact::update(['name' => $request['name']], ['uid' => $uid, 'self' => 1]);
|
||||
Contact::update(['name' => $request['name']], ['id' => $api_user['id']]);
|
||||
}
|
||||
|
||||
if (isset($_POST['description'])) {
|
||||
DBA::update('profile', ['about' => $_POST['description']], ['uid' => $uid]);
|
||||
Contact::update(['about' => $_POST['description']], ['uid' => $uid, 'self' => 1]);
|
||||
Contact::update(['about' => $_POST['description']], ['id' => $api_user['id']]);
|
||||
if (isset($request['description'])) {
|
||||
DBA::update('profile', ['about' => $request['description']], ['uid' => $uid]);
|
||||
Contact::update(['about' => $request['description']], ['uid' => $uid, 'self' => 1]);
|
||||
Contact::update(['about' => $request['description']], ['id' => $api_user['id']]);
|
||||
}
|
||||
|
||||
Profile::publishUpdate($uid);
|
||||
|
|
32
tests/src/Module/Api/Twitter/Account/UpdateProfileTest.php
Normal file
32
tests/src/Module/Api/Twitter/Account/UpdateProfileTest.php
Normal file
|
@ -0,0 +1,32 @@
|
|||
<?php
|
||||
|
||||
namespace Friendica\Test\src\Module\Api\Twitter\Account;
|
||||
|
||||
use Friendica\App\Router;
|
||||
use Friendica\DI;
|
||||
use Friendica\Module\Api\Twitter\Account\UpdateProfile;
|
||||
use Friendica\Test\src\Module\Api\ApiTest;
|
||||
|
||||
class UpdateProfileTest extends ApiTest
|
||||
{
|
||||
/**
|
||||
* Test the api_account_update_profile() function.
|
||||
*/
|
||||
public function testApiAccountUpdateProfile()
|
||||
{
|
||||
$updateProfile = new UpdateProfile(DI::app(), DI::l10n(), DI::baseUrl(), DI::args(), DI::logger(), DI::profiler(), DI::apiResponse(), ['REQUEST_METHOD' => Router::POST], ['extension' => 'json']);
|
||||
$response = $updateProfile->run(['name' => 'new_name', 'description' => 'new_description']);
|
||||
|
||||
$body = (string)$response->getBody();
|
||||
|
||||
self::assertJson($body);
|
||||
|
||||
$json = json_decode($body);
|
||||
|
||||
self::assertEquals(42, $json->id);
|
||||
self::assertEquals('DFRN', $json->location);
|
||||
self::assertEquals('selfcontact', $json->screen_name);
|
||||
self::assertEquals('new_name', $json->name);
|
||||
self::assertEquals('new_description', $json->description);
|
||||
}
|
||||
}
|
|
@ -1,28 +0,0 @@
|
|||
<?php
|
||||
|
||||
namespace Friendica\Test\src\Module\Api\Twitter\Account;
|
||||
|
||||
use Friendica\Test\src\Module\Api\ApiTest;
|
||||
|
||||
class UpdateTest extends ApiTest
|
||||
{
|
||||
/**
|
||||
* Test the api_account_update_profile() function.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function testApiAccountUpdateProfile()
|
||||
{
|
||||
/*
|
||||
$_POST['name'] = 'new_name';
|
||||
$_POST['description'] = 'new_description';
|
||||
$result = api_account_update_profile('json');
|
||||
// We can't use assertSelfUser() here because the user object is missing some properties.
|
||||
self::assertEquals($this->selfUser['id'], $result['user']['cid']);
|
||||
self::assertEquals('DFRN', $result['user']['location']);
|
||||
self::assertEquals($this->selfUser['nick'], $result['user']['screen_name']);
|
||||
self::assertEquals('new_name', $result['user']['name']);
|
||||
self::assertEquals('new_description', $result['user']['description']);
|
||||
*/
|
||||
}
|
||||
}
|
Loading…
Reference in a new issue