• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

LibreSign / libresign / 20244117004

15 Dec 2025 07:02PM UTC coverage: 45.15%. First build
20244117004

Pull #6197

github

web-flow
Merge 5618b286e into 54b16f7f5
Pull Request #6197: refactor: consolidate pdf fixtures

13 of 16 new or added lines in 2 files covered. (81.25%)

6084 of 13475 relevant lines covered (45.15%)

5.22 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

0.0
/lib/Controller/DevelopController.php
1
<?php
2

3
declare(strict_types=1);
4
/**
5
 * SPDX-FileCopyrightText: 2020-2024 LibreCode coop and contributors
6
 * SPDX-License-Identifier: AGPL-3.0-or-later
7
 */
8

9
namespace OCA\Libresign\Controller;
10

11
use OCA\Libresign\AppInfo\Application;
12
use OCP\AppFramework\Controller;
13
use OCP\AppFramework\Http;
14
use OCP\AppFramework\Http\Attribute\FrontpageRoute;
15
use OCP\AppFramework\Http\Attribute\NoCSRFRequired;
16
use OCP\AppFramework\Http\Attribute\PublicPage;
17
use OCP\AppFramework\Http\DataResponse;
18
use OCP\AppFramework\Http\FileDisplayResponse;
19
use OCP\AppFramework\Http\Response;
20
use OCP\Files\SimpleFS\InMemoryFile;
21
use OCP\IConfig;
22
use OCP\IRequest;
23

24
class DevelopController extends Controller {
25
        public function __construct(
26
                IRequest $request,
27
                private IConfig $config,
28
        ) {
29
                parent::__construct(Application::APP_ID, $request);
×
30
        }
31

32
        /**
33
         * Get a demo PDF file to be used by test purpose
34
         *
35
         * To use this endpoint is necessary to enable the debug mode in your instance. To do this, run the command:
36
         *
37
         * `occ config:system:set debug --value true --type boolean`
38
         *
39
         * @return FileDisplayResponse<Http::STATUS_OK, array{Content-Type: 'application/pdf',Content-Disposition: 'inline; filename="file.pdf"'}>|DataResponse<Http::STATUS_NOT_FOUND, array<empty>, array{}>
40
         *
41
         * 200: PDF returned
42
         * 404: Debug mode not enabled
43
         */
44
        #[NoCSRFRequired]
45
        #[PublicPage]
46
        #[FrontpageRoute(verb: 'GET', url: '/develop/pdf')]
47
        public function pdf(): FileDisplayResponse|Response {
48
                if (!$this->isDebugMode()) {
×
49
                        return new DataResponse([], Http::STATUS_NOT_FOUND);
×
50
                }
NEW
51
                $file = new InMemoryFile('file.pdf', file_get_contents(__DIR__ . '/../../tests/php/fixtures/pdfs/small_valid.pdf'));
×
52
                $response = new FileDisplayResponse($file);
×
53
                $response->setHeaders([
×
54
                        'Content-Disposition' => 'inline; filename="file.pdf"',
×
55
                        'Content-Type' => 'application/pdf',
×
56
                ]);
×
57
                return $response;
×
58
        }
59

60
        public function isDebugMode(): bool {
61
                return $this->config->getSystemValue('debug', false) === true;
×
62
        }
63
}
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2026 Coveralls, Inc