mirror of
https://github.com/friendica/friendica
synced 2025-04-22 05:50:13 +00:00
Move API User tests
This commit is contained in:
parent
84ca2d6e98
commit
51c94016cd
2 changed files with 127 additions and 148 deletions
127
tests/src/Factory/Api/Twitter/UserTest.php
Normal file
127
tests/src/Factory/Api/Twitter/UserTest.php
Normal file
|
@ -0,0 +1,127 @@
|
|||
<?php
|
||||
|
||||
namespace Friendica\Test\src\Factory\Api\Twitter;
|
||||
|
||||
use Friendica\DI;
|
||||
use Friendica\Factory\Api\Twitter\User;
|
||||
use Friendica\Test\FixtureTest;
|
||||
use Friendica\Test\src\Module\Api\ApiTest;
|
||||
|
||||
class UserTest extends FixtureTest
|
||||
{
|
||||
/**
|
||||
* Assert that an user array contains expected keys.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
protected function assertSelfUser(array $user)
|
||||
{
|
||||
self::assertEquals(ApiTest::SELF_USER['id'], $user['uid']);
|
||||
self::assertEquals(ApiTest::SELF_USER['id'], $user['cid']);
|
||||
self::assertEquals('DFRN', $user['location']);
|
||||
self::assertEquals(ApiTest::SELF_USER['name'], $user['name']);
|
||||
self::assertEquals(ApiTest::SELF_USER['nick'], $user['screen_name']);
|
||||
self::assertTrue($user['verified']);
|
||||
}
|
||||
|
||||
/**
|
||||
* Test the api_get_user() function.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function testApiGetUser()
|
||||
{
|
||||
$userFactory = new User(DI::logger(), DI::twitterStatus());
|
||||
$userObj = $userFactory->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']);
|
||||
}
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue