From 6b03ee29229e1c56e1ba71fb3ff062fa4f1ce51a Mon Sep 17 00:00:00 2001 From: Philipp Date: Sat, 4 Dec 2021 23:16:16 +0100 Subject: [PATCH] Re enable UpdateProfile test --- .../Api/Twitter/Account/UpdateProfile.php | 18 +++++------ .../Api/Twitter/Account/UpdateProfileTest.php | 32 +++++++++++++++++++ .../Module/Api/Twitter/Account/UpdateTest.php | 28 ---------------- 3 files changed, 41 insertions(+), 37 deletions(-) create mode 100644 tests/src/Module/Api/Twitter/Account/UpdateProfileTest.php delete mode 100644 tests/src/Module/Api/Twitter/Account/UpdateTest.php diff --git a/src/Module/Api/Twitter/Account/UpdateProfile.php b/src/Module/Api/Twitter/Account/UpdateProfile.php index 5a66e2772e..a518fbad2f 100644 --- a/src/Module/Api/Twitter/Account/UpdateProfile.php +++ b/src/Module/Api/Twitter/Account/UpdateProfile.php @@ -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); diff --git a/tests/src/Module/Api/Twitter/Account/UpdateProfileTest.php b/tests/src/Module/Api/Twitter/Account/UpdateProfileTest.php new file mode 100644 index 0000000000..5bfa789e02 --- /dev/null +++ b/tests/src/Module/Api/Twitter/Account/UpdateProfileTest.php @@ -0,0 +1,32 @@ + 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); + } +} diff --git a/tests/src/Module/Api/Twitter/Account/UpdateTest.php b/tests/src/Module/Api/Twitter/Account/UpdateTest.php deleted file mode 100644 index 0be8700424..0000000000 --- a/tests/src/Module/Api/Twitter/Account/UpdateTest.php +++ /dev/null @@ -1,28 +0,0 @@ -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']); - */ - } -}