1
1
Fork 0

Move API Status tests

This commit is contained in:
Philipp Holzer 2021-12-30 21:52:18 +01:00
parent 6412484fa6
commit c03ddf0891
Signed by: nupplaPhil
GPG key ID: 24A7501396EB5432
3 changed files with 187 additions and 88 deletions

View file

@ -105,7 +105,11 @@ return [
'uri' => '6',
'guid' => '6',
],
[
'id' => 7,
'uri' => '7',
'guid' => '7',
],
[
'id' => 42,
'uri' => 'http://localhost/profile/selfcontact',
@ -342,6 +346,34 @@ return [
'body' => 'Friend user status',
'plink' => 'http://localhost/display/6',
],
[
'uri-id' => 7,
'title' => 'item_title',
'body' => 'perspiciatis impedit voluptatem quis molestiae ea qui ' .
'reiciendis dolorum aut ducimus sunt consequatur inventore dolor ' .
'officiis pariatur doloremque nemo culpa aut quidem qui dolore ' .
'laudantium atque commodi alias voluptatem non possimus aperiam ' .
'ipsum rerum consequuntur aut amet fugit quia aliquid praesentium ' .
'repellendus quibusdam et et inventore mollitia rerum sit autem ' .
'pariatur maiores ipsum accusantium perferendis vel sit possimus ' .
'veritatis nihil distinctio qui eum repellat officia illum quos ' .
'impedit quam iste esse unde qui suscipit aut facilis ut inventore ' .
'omnis exercitationem quo magnam consequatur maxime aut illum ' .
'soluta quaerat natus unde aspernatur et sed beatae nihil ullam ' .
'temporibus corporis ratione blanditiis perspiciatis impedit ' .
'voluptatem quis molestiae ea qui reiciendis dolorum aut ducimus ' .
'sunt consequatur inventore dolor officiis pariatur doloremque ' .
'nemo culpa aut quidem qui dolore laudantium atque commodi alias ' .
'voluptatem non possimus aperiam ipsum rerum consequuntur aut ' .
'amet fugit quia aliquid praesentium repellendus quibusdam et et ' .
'inventore mollitia rerum sit autem pariatur maiores ipsum accusantium ' .
'perferendis vel sit possimus veritatis nihil distinctio qui eum ' .
'repellat officia illum quos impedit quam iste esse unde qui ' .
'suscipit aut facilis ut inventore omnis exercitationem quo magnam ' .
'consequatur maxime aut illum soluta quaerat natus unde aspernatur ' .
'et sed beatae nihil ullam temporibus corporis ratione blanditiis',
'plink' => 'http://localhost/display/6',
],
],
'post' => [
[
@ -434,6 +466,21 @@ return [
'visible' => 1,
'deleted' => 0,
],
[
'uri-id' => 7,
'parent-uri-id' => 7,
'thr-parent-id' => 7,
'gravity' => GRAVITY_PARENT,
'network' => Protocol::DFRN,
'owner-id' => 42,
'author-id' => 44,
'causer-id' => 44,
'vid' => 8,
'private' => Item::PUBLIC,
'global' => true,
'visible' => 1,
'deleted' => 0,
],
],
'post-user' => [
[
@ -687,6 +734,27 @@ return [
'deleted' => 0,
'wall' => 0,
],
[
'id' => 13,
'uri-id' => 7,
'visible' => 1,
'contact-id' => 44,
'author-id' => 44,
'owner-id' => 42,
'causer-id' => 44,
'uid' => 0,
'vid' => 8,
'unseen' => 0,
'parent-uri-id' => 7,
'thr-parent-id' => 7,
'private' => Item::PUBLIC,
'global' => true,
'gravity' => GRAVITY_PARENT,
'network' => Protocol::DFRN,
'origin' => 0,
'deleted' => 0,
'wall' => 0,
],
],
'post-thread' => [
[
@ -710,6 +778,13 @@ return [
'causer-id' => 44,
'network' => Protocol::DFRN,
],
[
'uri-id' => 7,
'author-id' => 44,
'owner-id' => 44,
'causer-id' => 44,
'network' => Protocol::DFRN,
],
],
'post-thread-user' => [
[
@ -790,6 +865,32 @@ return [
'starred' => 0,
'origin' => 0,
],
[
'uri-id' => 7,
'uid' => 42,
'wall' => 1,
'post-user-id' => 7,
'author-id' => 44,
'owner-id' => 44,
'causer-id' => 44,
'contact-id' => 44,
'network' => Protocol::DFRN,
'starred' => 0,
'origin' => 1,
],
[
'uri-id' => 7,
'uid' => 0,
'wall' => 0,
'post-user-id' => 12,
'author-id' => 44,
'owner-id' => 44,
'causer-id' => 44,
'contact-id' => 44,
'network' => Protocol::DFRN,
'starred' => 0,
'origin' => 0,
],
],
'notify' => [
[

View file

@ -679,93 +679,6 @@ class ApiTest extends FixtureTest
// api_statuses_mediap('json');
}
/**
* Test the api_convert_item() function.
*
* @return void
*/
public function testApiConvertItem()
{
/*
$result = api_convert_item(
[
'network' => 'feed',
'title' => 'item_title',
'uri-id' => 1,
// We need a long string to test that it is correctly cut
'body' => 'perspiciatis impedit voluptatem quis molestiae ea qui ' .
'reiciendis dolorum aut ducimus sunt consequatur inventore dolor ' .
'officiis pariatur doloremque nemo culpa aut quidem qui dolore ' .
'laudantium atque commodi alias voluptatem non possimus aperiam ' .
'ipsum rerum consequuntur aut amet fugit quia aliquid praesentium ' .
'repellendus quibusdam et et inventore mollitia rerum sit autem ' .
'pariatur maiores ipsum accusantium perferendis vel sit possimus ' .
'veritatis nihil distinctio qui eum repellat officia illum quos ' .
'impedit quam iste esse unde qui suscipit aut facilis ut inventore ' .
'omnis exercitationem quo magnam consequatur maxime aut illum ' .
'soluta quaerat natus unde aspernatur et sed beatae nihil ullam ' .
'temporibus corporis ratione blanditiis perspiciatis impedit ' .
'voluptatem quis molestiae ea qui reiciendis dolorum aut ducimus ' .
'sunt consequatur inventore dolor officiis pariatur doloremque ' .
'nemo culpa aut quidem qui dolore laudantium atque commodi alias ' .
'voluptatem non possimus aperiam ipsum rerum consequuntur aut ' .
'amet fugit quia aliquid praesentium repellendus quibusdam et et ' .
'inventore mollitia rerum sit autem pariatur maiores ipsum accusantium ' .
'perferendis vel sit possimus veritatis nihil distinctio qui eum ' .
'repellat officia illum quos impedit quam iste esse unde qui ' .
'suscipit aut facilis ut inventore omnis exercitationem quo magnam ' .
'consequatur maxime aut illum soluta quaerat natus unde aspernatur ' .
'et sed beatae nihil ullam temporibus corporis ratione blanditiis',
'plink' => 'item_plink'
]
);
self::assertStringStartsWith('item_title', $result['text']);
self::assertStringStartsWith('<h4>item_title</h4><br>perspiciatis impedit voluptatem', $result['html']);
*/
}
/**
* Test the api_convert_item() function with an empty item body.
*
* @return void
*/
public function testApiConvertItemWithoutBody()
{
/*
$result = api_convert_item(
[
'network' => 'feed',
'title' => 'item_title',
'uri-id' => -1,
'body' => '',
'plink' => 'item_plink'
]
);
self::assertEquals("item_title", $result['text']);
self::assertEquals('<h4>item_title</h4><br>item_plink', $result['html']);
*/
}
/**
* Test the api_convert_item() function with the title in the body.
*
* @return void
*/
public function testApiConvertItemWithTitleInBody()
{
/*
$result = api_convert_item(
[
'title' => 'item_title',
'body' => 'item_title item_body',
'uri-id' => 1,
]
);
self::assertEquals('item_title item_body', $result['text']);
self::assertEquals('<h4>item_title</h4><br>item_title item_body', $result['html']);
*/
}
/**
* Test the api_get_attachments() function.
*

View file

@ -0,0 +1,85 @@
<?php
namespace Friendica\Test\src\Factory\Api\Twitter;
use Friendica\DI;
use Friendica\Factory\Api\Friendica\Activities;
use Friendica\Factory\Api\Twitter\Attachment;
use Friendica\Factory\Api\Twitter\Hashtag;
use Friendica\Factory\Api\Twitter\Media;
use Friendica\Factory\Api\Twitter\Mention;
use Friendica\Factory\Api\Twitter\Status;
use Friendica\Factory\Api\Twitter\Url;
use Friendica\Test\FixtureTest;
use Friendica\Test\src\Module\Api\ApiTest;
class StatusTest extends FixtureTest
{
/**
* Test the api_convert_item() function.
*
* @return void
*/
public function testApiConvertItem()
{
$hashTagFac = new Hashtag(DI::logger());
$mediaFac = new Media(DI::logger(), DI::baseUrl());
$urlFac = new Url(DI::logger());
$mentionFac = new Mention(DI::logger(), DI::baseUrl());
$activitiesFac = new Activities(DI::logger(), DI::baseUrl(), DI::twitterUser());
$attachmentFac = new Attachment(DI::logger());
$statusFac = new Status(DI::logger(), DI::dba(), DI::twitterUser(), $hashTagFac, $mediaFac, $urlFac, $mentionFac, $activitiesFac, $attachmentFac);
$statusObj = $statusFac->createFromItemId(13, ApiTest::SELF_USER['id']);
$status = $statusObj->toArray();
self::assertStringStartsWith('item_title', $status['text']);
self::assertStringStartsWith('<h4>item_title</h4><br>perspiciatis impedit voluptatem', $status['html']);
}
/**
* Test the api_convert_item() function with an empty item body.
*
* @return void
*/
public function testApiConvertItemWithoutBody()
{
self::markTestIncomplete('Needs a dataset first');
/*
$result = api_convert_item(
[
'network' => 'feed',
'title' => 'item_title',
'uri-id' => -1,
'body' => '',
'plink' => 'item_plink'
]
);
self::assertEquals("item_title", $result['text']);
self::assertEquals('<h4>item_title</h4><br>item_plink', $result['html']);
*/
}
/**
* Test the api_convert_item() function with the title in the body.
*
* @return void
*/
public function testApiConvertItemWithTitleInBody()
{
self::markTestIncomplete('Needs a dataset first');
/*
$result = api_convert_item(
[
'title' => 'item_title',
'body' => 'item_title item_body',
'uri-id' => 1,
]
);
self::assertEquals('item_title item_body', $result['text']);
self::assertEquals('<h4>item_title</h4><br>item_title item_body', $result['html']);
*/
}
}