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
46 'assertion' => new Entity\Report(
49 new \DateTime('now', new \DateTimeZone('UTC')),
64 'comment' => 'Report',
65 'category' => 'violation',
67 'created' => '2021-10-12 12:23:00'
69 'postUriIds' => [89, 90],
70 'assertion' => new Entity\Report(
73 new \DateTime('2021-10-12 12:23:00', new \DateTimeZone('UTC')),
85 public function assertReport(Entity\Report $assertion, Entity\Report $report)
91 self::assertEquals($assertion->uid, $report->uid);
92 self::assertEquals($assertion->reporterId, $report->reporterId);
93 self::assertEquals($assertion->cid, $report->cid);
94 self::assertEquals($assertion->comment, $report->comment);
95 self::assertEquals($assertion->category, $report->category);
96 self::assertEquals($assertion->forward, $report->forward);
97 // No way to test "now" at the moment
98 //self::assertEquals($assertion->created, $report->created);
99 self::assertEquals($assertion->postUriIds, $report->postUriIds);
103 * @dataProvider dataCreateFromTableRow
105 public function testCreateFromTableRow(array $row, array $postUriIds, Entity\Report $assertion)
107 $factory = new Factory\Report(new NullLogger());
109 $this->assertReport($factory->createFromTableRow($row, $postUriIds), $assertion);
112 public function dataCreateFromReportsRequest(): array
123 'assertion' => new Entity\Report(
126 new \DateTime('now', new \DateTimeZone('UTC')),
138 'comment' => 'Report',
139 'category' => 'violation',
141 'postUriIds' => [89, 90],
143 'assertion' => new Entity\Report(
146 new \DateTime('now', new \DateTimeZone('UTC')),
159 * @dataProvider dataCreateFromReportsRequest
161 public function testCreateFromReportsRequest(int $reporter, int $cid, string $comment, string $category = null, bool $forward, array $postUriIds, int $uid, Entity\Report $assertion)
163 $factory = new Factory\Report(new NullLogger());
165 $this->assertReport($factory->createFromReportsRequest($reporter, $cid, $comment, $category, $forward, $postUriIds, $uid), $assertion);