diff --git a/tests/legacy/ApiTest.php b/tests/legacy/ApiTest.php index f42b837e3d..a76a59f5cc 100644 --- a/tests/legacy/ApiTest.php +++ b/tests/legacy/ApiTest.php @@ -504,154 +504,6 @@ class ApiTest extends FixtureTest */ } - /** - * Test the api_get_user() function. - * - * @return void - */ - public function testApiGetUser() - { - // $user = api_get_user(); - // self::assertSelfUser($user); - // self::assertEquals('708fa0', $user['profile_sidebar_fill_color']); - // self::assertEquals('6fdbe8', $user['profile_link_color']); - // self::assertEquals('ededed', $user['profile_background_color']); - } - - /** - * Test the api_get_user() function with a Frio schema. - * - * @return void - */ - public function testApiGetUserWithFrioSchema() - { - // $pConfig = $this->dice->create(IManagePersonalConfigValues::class); - // $pConfig->set($this->selfUser['id'], 'frio', 'schema', 'red'); - // $user = api_get_user(); - // self::assertSelfUser($user); - // self::assertEquals('708fa0', $user['profile_sidebar_fill_color']); - // self::assertEquals('6fdbe8', $user['profile_link_color']); - // self::assertEquals('ededed', $user['profile_background_color']); - } - - /** - * Test the api_get_user() function with an empty Frio schema. - * - * @return void - */ - public function testApiGetUserWithEmptyFrioSchema() - { - // $pConfig = $this->dice->create(IManagePersonalConfigValues::class); - // $pConfig->set($this->selfUser['id'], 'frio', 'schema', '---'); - // $user = api_get_user(); - // self::assertSelfUser($user); - // self::assertEquals('708fa0', $user['profile_sidebar_fill_color']); - // self::assertEquals('6fdbe8', $user['profile_link_color']); - // self::assertEquals('ededed', $user['profile_background_color']); - } - - /** - * Test the api_get_user() function with a custom Frio schema. - * - * @return void - */ - public function testApiGetUserWithCustomFrioSchema() - { - // $pConfig = $this->dice->create(IManagePersonalConfigValues::class); - // $pConfig->set($this->selfUser['id'], 'frio', 'schema', '---'); - // $pConfig->set($this->selfUser['id'], 'frio', 'nav_bg', '#123456'); - // $pConfig->set($this->selfUser['id'], 'frio', 'link_color', '#123456'); - // $pConfig->set($this->selfUser['id'], 'frio', 'background_color', '#123456'); - // $user = api_get_user(); - // self::assertSelfUser($user); - // self::assertEquals('123456', $user['profile_sidebar_fill_color']); - // self::assertEquals('123456', $user['profile_link_color']); - // self::assertEquals('123456', $user['profile_background_color']); - } - - /** - * Test the api_get_user() function with an user that is not allowed to use the API. - * - * @runInSeparateProcess - * @preserveGlobalState disabled - */ - public function testApiGetUserWithoutApiUser() - { - // api_get_user() with empty parameters is not used anymore - /* - $_SERVER['PHP_AUTH_USER'] = 'Test user'; - $_SERVER['PHP_AUTH_PW'] = 'password'; - BasicAuth::setCurrentUserID(); - self::assertFalse(api_get_user()); - */ - } - - /** - * Test the api_get_user() function with an user ID in a GET parameter. - * - * @return void - */ - public function testApiGetUserWithGetId() - { - // self::assertOtherUser(api_get_user()); - } - - /** - * Test the api_get_user() function with a wrong user ID in a GET parameter. - * - * @return void - */ - public function testApiGetUserWithWrongGetId() - { - // $this->expectException(\Friendica\Network\HTTPException\BadRequestException::class); - // self::assertOtherUser(api_get_user()); - } - - /** - * Test the api_get_user() function with an user name in a GET parameter. - * - * @return void - */ - public function testApiGetUserWithGetName() - { - // self::assertSelfUser(api_get_user()); - } - - /** - * Test the api_get_user() function with a profile URL in a GET parameter. - * - * @return void - */ - public function testApiGetUserWithGetUrl() - { - // self::assertSelfUser(api_get_user()); - } - - /** - * Test the api_get_user() function with an user ID in the API path. - * - * @return void - */ - public function testApiGetUserWithNumericCalledApi() - { - // global $called_api; - // $called_api = ['api_path']; - // DI::args()->setArgv(['', $this->otherUser['id'] . '.json']); - // self::assertOtherUser(api_get_user()); - } - - /** - * Test the api_get_user() function with the $called_api global variable. - * - * @return void - */ - public function testApiGetUserWithCalledApi() - { - // global $called_api; - // $called_api = ['api', 'api_path']; - // self::assertSelfUser(api_get_user()); - } - /** * Test the Arrays::walkRecursive() function. * diff --git a/tests/src/Factory/Api/Twitter/UserTest.php b/tests/src/Factory/Api/Twitter/UserTest.php new file mode 100644 index 0000000000..93de318e6a --- /dev/null +++ b/tests/src/Factory/Api/Twitter/UserTest.php @@ -0,0 +1,127 @@ +createFromUserId(ApiTest::SELF_USER['id']); + $user = $userObj->toArray(); + + $this->assertSelfUser($user); + } + + /** + * Test the api_get_user() function with a Frio schema. + * + * @return void + */ + public function testApiGetUserWithFrioSchema() + { + $this->markTestIncomplete('Needs missing fields for profile colors at API User object first.'); + + /* + DI::pConfig()->set(ApiTest::SELF_USER['id'], 'frio', 'schema', 'red'); + + $userFactory = new User(DI::logger(), DI::twitterStatus()); + $user = $userFactory->createFromUserId(42); + + $this->assertSelfUser($user->toArray()); + self::assertEquals('708fa0', $user['profile_sidebar_fill_color']); + self::assertEquals('6fdbe8', $user['profile_link_color']); + self::assertEquals('ededed', $user['profile_background_color']); + */ + } + + /** + * Test the api_get_user() function with an empty Frio schema. + * + * @return void + */ + public function testApiGetUserWithEmptyFrioSchema() + { + $this->markTestIncomplete('Needs missing fields for profile colors at API User object first.'); + + /* + DI::pConfig()->set(ApiTest::SELF_USER['id'], 'frio', 'schema', '---'); + + $userFactory = new User(DI::logger(), DI::twitterStatus()); + $user = $userFactory->createFromUserId(42); + + $this->assertSelfUser($user->toArray()); + self::assertEquals('708fa0', $user['profile_sidebar_fill_color']); + self::assertEquals('6fdbe8', $user['profile_link_color']); + self::assertEquals('ededed', $user['profile_background_color']); + */ + } + + /** + * Test the api_get_user() function with a custom Frio schema. + * + * @return void + */ + public function testApiGetUserWithCustomFrioSchema() + { + $this->markTestIncomplete('Needs missing fields for profile colors at API User object first.'); + + /* + DI::pConfig()->set(ApiTest::SELF_USER['id'], 'frio', 'schema', '---'); + DI::pConfig()->set(ApiTest::SELF_USER['id'], 'frio', 'nav_bg', '#123456'); + DI::pConfig()->set(ApiTest::SELF_USER['id'], 'frio', 'link_color', '#123456'); + DI::pConfig()->set(ApiTest::SELF_USER['id'], 'frio', 'background_color', '#123456'); + + $userFactory = new User(DI::logger(), DI::twitterStatus()); + $user = $userFactory->createFromUserId(42); + + $this->assertSelfUser($user->toArray()); + self::assertEquals('123456', $user['profile_sidebar_fill_color']); + self::assertEquals('123456', $user['profile_link_color']); + self::assertEquals('123456', $user['profile_background_color']); + */ + } + + /** + * Test the api_get_user() function with a wrong user ID in a GET parameter. + * + * @return void + */ + public function testApiGetUserWithWrongGetId() + { + $userFactory = new User(DI::logger(), DI::twitterStatus()); + $userObj = $userFactory->createFromUserId(-1); + $user = $userObj->toArray(); + + self::assertEquals(0, $user['id']); + self::assertEquals(0, $user['uid']); + self::assertEquals(0, $user['cid']); + self::assertEquals(0, $user['pid']); + self::assertEmpty($user['name']); + } +}