2021-10-22 21:30:54 +02:00
|
|
|
<?php
|
|
|
|
|
|
|
|
namespace Friendica\Test\src\Contact\FriendSuggest\Factory;
|
|
|
|
|
|
|
|
use Friendica\Contact\FriendSuggest\Factory\FriendSuggest;
|
|
|
|
use Friendica\Contact\FriendSuggest\Entity;
|
|
|
|
use Friendica\Test\MockedTest;
|
2021-10-23 12:26:06 +02:00
|
|
|
use Psr\Log\NullLogger;
|
2021-10-22 21:30:54 +02:00
|
|
|
|
|
|
|
class FriendSuggestTest extends MockedTest
|
|
|
|
{
|
|
|
|
public function dataCreate()
|
|
|
|
{
|
|
|
|
return [
|
|
|
|
'default' => [
|
|
|
|
'input' => [
|
|
|
|
'uid' => 12,
|
|
|
|
'cid' => 13,
|
|
|
|
'name' => 'test',
|
|
|
|
'url' => 'https://friendica.local/profile/test',
|
|
|
|
'request' => 'https://friendica.local/dfrn_request/test',
|
|
|
|
'photo' => 'https://friendica.local/photo/profile/test',
|
|
|
|
'note' => 'a common note',
|
|
|
|
'created' => '2021-10-12 12:23:00'
|
|
|
|
],
|
2021-10-22 21:54:36 +02:00
|
|
|
'assertion' => new Entity\FriendSuggest(
|
|
|
|
12,
|
|
|
|
13,
|
|
|
|
'test',
|
|
|
|
'https://friendica.local/profile/test',
|
|
|
|
'https://friendica.local/dfrn_request/test',
|
|
|
|
'https://friendica.local/photo/profile/test',
|
|
|
|
'a common note',
|
|
|
|
new \DateTime('2021-10-12 12:23:00', new \DateTimeZone('UTC'))
|
|
|
|
),
|
2021-10-22 21:30:54 +02:00
|
|
|
],
|
|
|
|
'minimum' => [
|
|
|
|
'input' => [
|
|
|
|
'id' => 20,
|
|
|
|
],
|
2021-10-22 21:54:36 +02:00
|
|
|
'assertion' => new Entity\FriendSuggest(
|
|
|
|
0,
|
|
|
|
0,
|
|
|
|
'',
|
|
|
|
'',
|
|
|
|
'',
|
|
|
|
'',
|
|
|
|
'',
|
2021-11-16 23:57:12 +00:00
|
|
|
new \DateTime('now', new \DateTimeZone('UTC')),
|
2021-10-22 21:54:36 +02:00
|
|
|
28
|
|
|
|
),
|
2021-10-22 21:30:54 +02:00
|
|
|
],
|
|
|
|
'full' => [
|
|
|
|
'input' => [
|
|
|
|
'uid' => 12,
|
|
|
|
'cid' => 13,
|
|
|
|
'name' => 'test',
|
|
|
|
'url' => 'https://friendica.local/profile/test',
|
|
|
|
'request' => 'https://friendica.local/dfrn_request/test',
|
|
|
|
'photo' => 'https://friendica.local/photo/profile/test',
|
|
|
|
'note' => 'a common note',
|
|
|
|
'created' => '2021-10-12 12:23:00',
|
|
|
|
'id' => 666,
|
|
|
|
],
|
2021-10-22 21:54:36 +02:00
|
|
|
'assertion' => new Entity\FriendSuggest(
|
|
|
|
12,
|
|
|
|
13,
|
|
|
|
'test',
|
|
|
|
'https://friendica.local/profile/test',
|
|
|
|
'https://friendica.local/dfrn_request/test',
|
|
|
|
'https://friendica.local/photo/profile/test',
|
|
|
|
'a common note',
|
|
|
|
new \DateTime('2021-10-12 12:23:00', new \DateTimeZone('UTC')),
|
|
|
|
666
|
|
|
|
),
|
2021-10-22 21:30:54 +02:00
|
|
|
],
|
|
|
|
];
|
|
|
|
}
|
|
|
|
|
2021-10-22 21:54:36 +02:00
|
|
|
public function assertFriendSuggest(Entity\FriendSuggest $assertion, Entity\FriendSuggest $friendSuggest)
|
2021-10-22 21:30:54 +02:00
|
|
|
{
|
2021-10-22 21:54:36 +02:00
|
|
|
self::assertEquals($assertion->id, $friendSuggest->id);
|
|
|
|
self::assertEquals($assertion->uid, $friendSuggest->uid);
|
|
|
|
self::assertEquals($assertion->cid, $friendSuggest->cid);
|
|
|
|
self::assertEquals($assertion->name, $friendSuggest->name);
|
|
|
|
self::assertEquals($assertion->url, $friendSuggest->url);
|
|
|
|
self::assertEquals($assertion->request, $friendSuggest->request);
|
|
|
|
self::assertEquals($assertion->photo, $friendSuggest->photo);
|
|
|
|
self::assertEquals($assertion->note, $friendSuggest->note);
|
2021-10-22 21:30:54 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
public function testCreateNew()
|
|
|
|
{
|
2021-10-23 12:26:06 +02:00
|
|
|
$factory = new FriendSuggest(new NullLogger());
|
2021-10-22 21:30:54 +02:00
|
|
|
|
2021-10-22 21:54:36 +02:00
|
|
|
$this->assertFriendSuggest(
|
|
|
|
$factory->createNew(12, 13),
|
|
|
|
new Entity\FriendSuggest(12, 13, '', '', '', '', '',
|
|
|
|
new \DateTime('now', new \DateTimeZone('UTC')), null
|
|
|
|
)
|
|
|
|
);
|
2021-10-22 21:30:54 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @dataProvider dataCreate
|
|
|
|
*/
|
2021-10-22 21:54:36 +02:00
|
|
|
public function testCreateFromTableRow(array $input, Entity\FriendSuggest $assertion)
|
2021-10-22 21:30:54 +02:00
|
|
|
{
|
2021-10-23 12:26:06 +02:00
|
|
|
$factory = new FriendSuggest(new NullLogger());
|
2021-10-22 21:30:54 +02:00
|
|
|
|
|
|
|
$this->assertFriendSuggest($factory->createFromTableRow($input), $assertion);
|
|
|
|
}
|
|
|
|
|
|
|
|
public function testCreateEmpty()
|
|
|
|
{
|
2021-10-23 12:26:06 +02:00
|
|
|
$factory = new FriendSuggest(new NullLogger());
|
2021-10-22 21:30:54 +02:00
|
|
|
|
2021-10-22 21:54:36 +02:00
|
|
|
$this->assertFriendSuggest($factory->createEmpty(66), new Entity\FriendSuggest(0, 0, '', '', '', '', '',
|
|
|
|
new \DateTime('now', new \DateTimeZone('UTC')), 66
|
|
|
|
));
|
2021-10-22 21:30:54 +02:00
|
|
|
}
|
|
|
|
}
|