2021-08-19 01:33:13 +09:00
|
|
|
<?php
|
|
|
|
|
2021-10-10 17:26:18 +09:00
|
|
|
declare(strict_types = 1);
|
|
|
|
|
2021-08-19 01:33:13 +09:00
|
|
|
// {{{ License
|
|
|
|
// This file is part of GNU social - https://www.gnu.org/software/social
|
|
|
|
//
|
|
|
|
// GNU social is free software: you can redistribute it and/or modify
|
|
|
|
// it under the terms of the GNU Affero General Public License as published by
|
|
|
|
// the Free Software Foundation, either version 3 of the License, or
|
|
|
|
// (at your option) any later version.
|
|
|
|
//
|
|
|
|
// GNU social is distributed in the hope that it will be useful,
|
|
|
|
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
// GNU Affero General Public License for more details.
|
|
|
|
//
|
|
|
|
// You should have received a copy of the GNU Affero General Public License
|
|
|
|
// along with GNU social. If not, see <http://www.gnu.org/licenses/>.
|
|
|
|
// }}}
|
|
|
|
|
|
|
|
namespace App\Tests\Entity;
|
|
|
|
|
2022-03-08 01:17:44 +09:00
|
|
|
use App\Core\Cache;
|
2022-03-27 23:19:09 +09:00
|
|
|
use App\Core\DB;
|
2022-03-08 01:17:44 +09:00
|
|
|
use App\Entity\Actor;
|
2021-08-19 01:33:13 +09:00
|
|
|
use App\Util\GNUsocialTestCase;
|
2022-01-05 07:22:48 +09:00
|
|
|
use Component\Circle\Entity\ActorTag;
|
2022-03-08 01:17:44 +09:00
|
|
|
use Component\Tag\Tag as CompTag;
|
2021-08-19 01:33:13 +09:00
|
|
|
use Jchook\AssertThrows\AssertThrows;
|
|
|
|
|
2021-09-18 11:22:27 +09:00
|
|
|
class ActorTest extends GNUsocialTestCase
|
2021-08-19 01:33:13 +09:00
|
|
|
{
|
|
|
|
use AssertThrows;
|
|
|
|
|
|
|
|
public function testGetAvatarUrl()
|
|
|
|
{
|
2022-03-08 01:17:44 +09:00
|
|
|
$actor = DB::findOneBy(Actor::class, ['nickname' => 'taken_user']);
|
2021-11-16 23:10:19 +09:00
|
|
|
static::assertSame('/avatar/default', $actor->getAvatarUrl());
|
2021-08-19 01:33:13 +09:00
|
|
|
}
|
|
|
|
|
2022-10-30 03:56:03 +09:00
|
|
|
// public function testSelfTags()
|
|
|
|
// {
|
|
|
|
// $actor = DB::findOneBy(Actor::class, ['nickname' => 'taken_user']);
|
|
|
|
// // Start with no self-tags
|
|
|
|
// static::assertSame(
|
|
|
|
// expected: [],
|
|
|
|
// actual: $actor->getSelfTags(),
|
|
|
|
// );
|
|
|
|
// // Add one self-tag 'foo'
|
|
|
|
// $tag = CompTag::sanitize('foo');
|
|
|
|
// DB::persist($actor_tag_foo = ActorTag::create([
|
|
|
|
// 'tagger' => $actor->getId(), // self tag means tagger = tagger in ActorTag
|
|
|
|
// 'tagged' => $actor->getId(),
|
|
|
|
// 'tag' => $tag,
|
|
|
|
// ]));
|
|
|
|
// static::assertNotNull($actor_tag_foo);
|
|
|
|
// DB::flush();
|
|
|
|
// Cache::delete(Actor::cacheKeys($actor->getId())['self-tags']);
|
|
|
|
// $actual = $actor->getSelfTags();
|
|
|
|
// static::assertCount(1, $actual);
|
|
|
|
// static::assertObjectEquals(expected: $actor_tag_foo, actual: $actual[0]);
|
|
|
|
// // Add a second self-tag 'foo'
|
|
|
|
// $tag = CompTag::sanitize('bar');
|
|
|
|
// DB::persist($actor_tag_bar = ActorTag::create([
|
|
|
|
// 'tagger' => $actor->getId(), // self tag means tagger = tagger in ActorTag
|
|
|
|
// 'tagged' => $actor->getId(),
|
|
|
|
// 'tag' => $tag,
|
|
|
|
// ]));
|
|
|
|
// static::assertNotNull($actor_tag_foo);
|
|
|
|
// DB::flush();
|
|
|
|
// Cache::delete(Actor::cacheKeys($actor->getId())['self-tags']);
|
|
|
|
// $actual = $actor->getSelfTags();
|
|
|
|
// static::assertCount(2, $actual);
|
|
|
|
// foreach ([$actor_tag_bar, $actor_tag_foo] as $expected) {
|
|
|
|
// /** @var ActorTag $a */
|
|
|
|
// $a = array_shift($actual);
|
|
|
|
// static::assertObjectEquals($expected, $a);
|
|
|
|
// }
|
|
|
|
// }
|
2021-08-19 01:33:13 +09:00
|
|
|
}
|