mirror of
https://git.friendi.ca/friendica/friendica.git
synced 2025-06-10 10:14:25 +02:00
Move API DirectMessage tests
This commit is contained in:
parent
f0b97d8e13
commit
6412484fa6
5 changed files with 99 additions and 83 deletions
95
tests/src/Factory/Api/Twitter/DirectMessageTest.php
Normal file
95
tests/src/Factory/Api/Twitter/DirectMessageTest.php
Normal file
|
@ -0,0 +1,95 @@
|
|||
<?php
|
||||
|
||||
namespace Friendica\Test\src\Factory\Api\Twitter;
|
||||
|
||||
use Friendica\DI;
|
||||
use Friendica\Factory\Api\Twitter\DirectMessage;
|
||||
use Friendica\Test\FixtureTest;
|
||||
use Friendica\Test\src\Module\Api\ApiTest;
|
||||
|
||||
class DirectMessageTest extends FixtureTest
|
||||
{
|
||||
/**
|
||||
* Test the api_format_messages() function.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function testApiFormatMessages()
|
||||
{
|
||||
$this->loadFixture(__DIR__ . '/../../../../datasets/mail/mail.fixture.php', DI::dba());
|
||||
$ids = DI::dba()->selectToArray('mail', ['id']);
|
||||
$id = $ids[0]['id'];
|
||||
|
||||
$directMessageFactory = new DirectMessage(DI::logger(), DI::dba(), DI::twitterUser());
|
||||
$directMessageObj = $directMessageFactory->createFromMailId($id, ApiTest::SELF_USER['id']);
|
||||
$directMessage = $directMessageObj->toArray();
|
||||
|
||||
self::assertEquals('item_title' . "\n" . 'item_body', $directMessage['text']);
|
||||
self::assertIsInt($directMessage['id']);
|
||||
self::assertIsInt($directMessage['recipient_id']);
|
||||
self::assertIsInt($directMessage['sender_id']);
|
||||
self::assertEquals('selfcontact', $directMessage['recipient_screen_name']);
|
||||
self::assertEquals('friendcontact', $directMessage['sender_screen_name']);
|
||||
}
|
||||
|
||||
/**
|
||||
* Test the api_format_messages() function with HTML.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function testApiFormatMessagesWithHtmlText()
|
||||
{
|
||||
$this->loadFixture(__DIR__ . '/../../../../datasets/mail/mail.fixture.php', DI::dba());
|
||||
$ids = DI::dba()->selectToArray('mail', ['id']);
|
||||
$id = $ids[0]['id'];
|
||||
|
||||
$directMessageFactory = new DirectMessage(DI::logger(), DI::dba(), DI::twitterUser());
|
||||
$directMessageObj = $directMessageFactory->createFromMailId($id, ApiTest::SELF_USER['id'], 'html');
|
||||
$directMessage = $directMessageObj->toArray();
|
||||
|
||||
self::assertEquals('item_title', $directMessage['title']);
|
||||
self::assertEquals('<strong>item_body</strong>', $directMessage['text']);
|
||||
}
|
||||
|
||||
/**
|
||||
* Test the api_format_messages() function with plain text.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function testApiFormatMessagesWithPlainText()
|
||||
{
|
||||
$this->loadFixture(__DIR__ . '/../../../../datasets/mail/mail.fixture.php', DI::dba());
|
||||
$ids = DI::dba()->selectToArray('mail', ['id']);
|
||||
$id = $ids[0]['id'];
|
||||
|
||||
$directMessageFactory = new DirectMessage(DI::logger(), DI::dba(), DI::twitterUser());
|
||||
$directMessageObj = $directMessageFactory->createFromMailId($id, ApiTest::SELF_USER['id'], 'plain');
|
||||
$directMessage = $directMessageObj->toArray();
|
||||
|
||||
self::assertEquals('item_title', $directMessage['title']);
|
||||
self::assertEquals('item_body', $directMessage['text']);
|
||||
}
|
||||
|
||||
/**
|
||||
* Test the api_format_messages() function with the getUserObjects GET parameter set to false.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function testApiFormatMessagesWithoutUserObjects()
|
||||
{
|
||||
self::markTestIncomplete('Needs processing of "getUserObjects" first');
|
||||
|
||||
/*
|
||||
$this->loadFixture(__DIR__ . '/../../../../datasets/mail/mail.fixture.php', DI::dba());
|
||||
$ids = DI::dba()->selectToArray('mail', ['id']);
|
||||
$id = $ids[0]['id'];
|
||||
|
||||
$directMessageFactory = new DirectMessage(DI::logger(), DI::dba(), DI::twitterUser());
|
||||
$directMessageObj = $directMessageFactory->createFromMailId($id, ApiTest::SELF_USER['id'], 'plain', $$GETUSEROBJECTS$$);
|
||||
$directMessage = $directMessageObj->toArray();
|
||||
|
||||
self::assertTrue(!isset($directMessage['sender']));
|
||||
self::assertTrue(!isset($directMessage['recipient']));
|
||||
*/
|
||||
}
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue