. * */ namespace Friendica\Test\src\Module\Api\Friendica; use Friendica\Capabilities\ICanCreateResponses; use Friendica\DI; use Friendica\Module\Api\Friendica\Notification; use Friendica\Test\src\Module\Api\ApiTest; use Friendica\Util\DateTimeFormat; use Friendica\Util\Temporal; class NotificationTest extends ApiTest { public function testEmpty() { self::markTestIncomplete('Needs BasicAuth as dynamic method for overriding first'); /* $this->expectException(BadRequestException::class); DI::session()->set('uid', ''); Notification::rawContent(); */ } public function testWithoutAuthenticatedUser() { self::markTestIncomplete('Needs BasicAuth as dynamic method for overriding first'); /* $this->expectException(BadRequestException::class); DI::session()->set('uid', 41); Notification::rawContent(); */ } public function testWithXmlResult() { $date = DateTimeFormat::local('2020-01-01 12:12:02'); $dateRel = Temporal::getRelativeDate('2020-01-01 07:12:02'); $assertXml = << XML; $notification = new Notification(DI::app(), DI::l10n(), DI::baseUrl(), DI::args(), DI::logger(), DI::profiler(), DI::apiResponse(), [], ['extension' => 'xml']); $response = $notification->run(); self::assertXmlStringEqualsXmlString($assertXml, (string)$response->getBody()); self::assertEquals(['Content-type' => ['text/xml'], ICanCreateResponses::X_HEADER => ['xml']], $response->getHeaders()); } public function testWithJsonResult() { $notification = new Notification(DI::app(), DI::l10n(), DI::baseUrl(), DI::args(), DI::logger(), DI::profiler(), DI::apiResponse(), [], ['extension' => 'json']); $response = $notification->run(); self::assertJson($response->getBody()); self::assertEquals(['Content-type' => ['application/json'], ICanCreateResponses::X_HEADER => ['json']], $response->getHeaders()); } }