3 * @copyright Copyright (C) 2010-2022, the Friendica project
5 * @license GNU AGPL version 3 or any later version
7 * This program is free software: you can redistribute it and/or modify
8 * it under the terms of the GNU Affero General Public License as
9 * published by the Free Software Foundation, either version 3 of the
10 * License, or (at your option) any later version.
12 * This program is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 * GNU Affero General Public License for more details.
17 * You should have received a copy of the GNU Affero General Public License
18 * along with this program. If not, see <https://www.gnu.org/licenses/>.
22 namespace Friendica\Test\src\Moderation\Factory;
24 use Friendica\Moderation\Factory;
25 use Friendica\Moderation\Entity;
26 use Friendica\Test\MockedTest;
27 use Psr\Log\NullLogger;
29 class ReportTest extends MockedTest
31 public function dataCreateFromTableRow(): array
47 'assertion' => new Entity\Report(
50 new \DateTime('now', new \DateTimeZone('UTC')),
66 'comment' => 'Report',
67 'category' => 'violation',
70 'created' => '2021-10-12 12:23:00'
72 'postUriIds' => [89, 90],
73 'assertion' => new Entity\Report(
76 new \DateTime('2021-10-12 12:23:00', new \DateTimeZone('UTC')),
89 public function assertReport(Entity\Report $assertion, Entity\Report $report)
95 self::assertEquals($assertion->uid, $report->uid);
96 self::assertEquals($assertion->reporterId, $report->reporterId);
97 self::assertEquals($assertion->cid, $report->cid);
98 self::assertEquals($assertion->comment, $report->comment);
99 self::assertEquals($assertion->category, $report->category);
100 self::assertEquals($assertion->rules, $report->rules);
101 self::assertEquals($assertion->forward, $report->forward);
102 // No way to test "now" at the moment
103 //self::assertEquals($assertion->created, $report->created);
104 self::assertEquals($assertion->postUriIds, $report->postUriIds);
108 * @dataProvider dataCreateFromTableRow
110 public function testCreateFromTableRow(array $row, array $postUriIds, Entity\Report $assertion)
112 $factory = new Factory\Report(new NullLogger());
114 $this->assertReport($factory->createFromTableRow($row, $postUriIds), $assertion);
117 public function dataCreateFromReportsRequest(): array
129 'assertion' => new Entity\Report(
132 new \DateTime('now', new \DateTimeZone('UTC')),
145 'comment' => 'Report',
146 'category' => 'violation',
149 'postUriIds' => [89, 90],
151 'assertion' => new Entity\Report(
154 new \DateTime('now', new \DateTimeZone('UTC')),
168 * @dataProvider dataCreateFromReportsRequest
170 public function testCreateFromReportsRequest(int $reporter, int $cid, string $comment, string $category = null, string $rules = '', bool $forward, array $postUriIds, int $uid, Entity\Report $assertion)
172 $factory = new Factory\Report(new NullLogger());
174 $this->assertReport($factory->createFromReportsRequest($reporter, $cid, $comment, $category, $rules, $forward, $postUriIds, $uid), $assertion);