File: 0003-Change-font-dir-for-local-build-tests.patch

package info (click to toggle)
php-dompdf 3.1.0%2Bdfsg-1
  • links: PTS, VCS
  • area: main
  • in suites: sid
  • size: 5,848 kB
  • sloc: php: 26,450; sh: 109; xml: 100; makefile: 42
file content (686 lines) | stat: -rw-r--r-- 26,409 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
From: William Desportes <williamdes@wdes.fr>
Date: Thu, 2 Feb 2023 16:06:40 +0100
Subject: Change fontDir for tests and runtime

Origin: vendor
Forwarded: not-needed
---
 src/FontMetrics.php                   |  2 +-
 tests/Canvas/CPDFTest.php             | 10 +++----
 tests/Css/AttributeTranslatorTest.php |  2 +-
 tests/Css/SelectorTest.php            |  2 +-
 tests/Css/ShorthandTest.php           |  2 +-
 tests/Css/StyleTest.php               | 52 +++++++++++++++++------------------
 tests/Css/StylesheetTest.php          |  4 +--
 tests/DompdfTest.php                  | 18 ++++++------
 tests/FrameReflower/ImageTest.php     |  2 +-
 tests/GeneratedContentTest.php        |  2 +-
 tests/Helpers/MockHelper.php          |  4 +--
 tests/LayoutTest/ImageTest.php        |  4 ++-
 tests/LayoutTest/PageTest.php         |  2 +-
 tests/OptionsTest.php                 | 23 +++++++++++-----
 tests/OutputTest/Dataset.php          | 31 ++++++++++++++++++++-
 tests/Renderer/RendererTest.php       |  2 +-
 tests/TestCase.php                    | 29 +++++++++++++++++++
 17 files changed, 130 insertions(+), 61 deletions(-)

diff --git a/src/FontMetrics.php b/src/FontMetrics.php
index 9adfdb0..3442c2a 100644
--- a/src/FontMetrics.php
+++ b/src/FontMetrics.php
@@ -619,7 +619,7 @@ class FontMetrics
             foreach ($this->bundledFonts as $family => $variants) {
                 if (!isset($fontFamilies[$family])) {
                     $fontFamilies[$family] = array_map(function ($variant) {
-                        return $this->getOptions()->getRootDir() . '/lib/fonts/' . $variant;
+                        return $this->getOptions()->getFontDir() . '/' . $variant;
                     }, $variants);
                 }
             }
diff --git a/tests/Canvas/CPDFTest.php b/tests/Canvas/CPDFTest.php
index fa3a0a6..92c33c1 100644
--- a/tests/Canvas/CPDFTest.php
+++ b/tests/Canvas/CPDFTest.php
@@ -14,7 +14,7 @@ class CPDFTest extends TestCase
         $basePath = realpath(__DIR__ . "/..");
         $imagePath = "$basePath/_files/red-dot.png";
 
-        $dompdf = new Dompdf();
+        $dompdf = $this->getDompdf();
         $canvas = new CPDF([0, 0, 200, 200], "portrait", $dompdf);
         $canvas->new_page();
         $canvas->image($imagePath, 0, 0, 5, 5);
@@ -27,7 +27,7 @@ class CPDFTest extends TestCase
         global $called;
         $called = 0;
 
-        $dompdf = new Dompdf();
+        $dompdf = $this->getDompdf();
         $canvas = new CPDF([0, 0, 200, 200], "portrait", $dompdf);
         $canvas->new_page();
 
@@ -57,7 +57,7 @@ class CPDFTest extends TestCase
 
     public function testPageText(): void
     {
-        $dompdf = new Dompdf();
+        $dompdf = $this->getDompdf();
         $canvas = new CPDF([0, 0, 200, 200], "portrait", $dompdf);
         $canvas->new_page();
 
@@ -70,7 +70,7 @@ class CPDFTest extends TestCase
 
     public function testPageLine(): void
     {
-        $dompdf = new Dompdf();
+        $dompdf = $this->getDompdf();
         $canvas = new CPDF([0, 0, 200, 200], "portrait", $dompdf);
         $canvas->new_page();
 
@@ -145,7 +145,7 @@ class CPDFTest extends TestCase
     #[\PHPUnit\Framework\Attributes\DataProvider('fontSupportsCharProvider')]
     public function testFontSupportsChar(string $font, string $char, bool $expected): void
     {
-        $dompdf = new Dompdf();
+        $dompdf = $this->getDompdf();
         $canvas = new CPDF("letter", "portrait", $dompdf);
         $fontFile = $dompdf->getFontMetrics()->getFont($font);
 
diff --git a/tests/Css/AttributeTranslatorTest.php b/tests/Css/AttributeTranslatorTest.php
index 9c11043..f154a1b 100644
--- a/tests/Css/AttributeTranslatorTest.php
+++ b/tests/Css/AttributeTranslatorTest.php
@@ -88,7 +88,7 @@ HTML
         $styles = array_fill_keys(array_keys($expectedStyles), []);
 
         // Use callback to inspect frame tree
-        $dompdf = new Dompdf();
+        $dompdf = $this->getDompdf();
         $dompdf->setCallbacks([
             [
                 "event" => "begin_frame",
diff --git a/tests/Css/SelectorTest.php b/tests/Css/SelectorTest.php
index d1a24f7..677361a 100644
--- a/tests/Css/SelectorTest.php
+++ b/tests/Css/SelectorTest.php
@@ -13,7 +13,7 @@ class SelectorTest extends TestCase
 {
     private function stylesheet()
     {
-        return new class(new Dompdf()) extends Stylesheet {
+        return new class($this->getDompdf()) extends Stylesheet {
             public function specificity(string $selector, int $origin = self::ORIG_AUTHOR): int
             {
                 return parent::specificity($selector, $origin);
diff --git a/tests/Css/ShorthandTest.php b/tests/Css/ShorthandTest.php
index faa6167..bbb6dee 100644
--- a/tests/Css/ShorthandTest.php
+++ b/tests/Css/ShorthandTest.php
@@ -10,7 +10,7 @@ class ShorthandTest extends TestCase
 {
     protected function style(): Style
     {
-        $dompdf = new Dompdf();
+        $dompdf = $this->getDompdf();
         $sheet = new Stylesheet($dompdf);
         $sheet->set_base_path(__DIR__); // Treat stylesheet as being located in this directory
 
diff --git a/tests/Css/StyleTest.php b/tests/Css/StyleTest.php
index 3a4a233..45ef7bb 100644
--- a/tests/Css/StyleTest.php
+++ b/tests/Css/StyleTest.php
@@ -22,7 +22,7 @@ class StyleTest extends TestCase
 {
     public function testInitial(): void
     {
-        $dompdf = new Dompdf();
+        $dompdf = $this->getDompdf();
         $sheet = new Stylesheet($dompdf);
         $style = new Style($sheet);
 
@@ -35,7 +35,7 @@ class StyleTest extends TestCase
 
     public function testUnsetNonInherited(): void
     {
-        $dompdf = new Dompdf();
+        $dompdf = $this->getDompdf();
         $sheet = new Stylesheet($dompdf);
         $s1 = new Style($sheet);
         $s2 = new Style($sheet);
@@ -52,7 +52,7 @@ class StyleTest extends TestCase
 
     public function testUnsetInherited(): void
     {
-        $dompdf = new Dompdf();
+        $dompdf = $this->getDompdf();
         $sheet = new Stylesheet($dompdf);
         $s1 = new Style($sheet);
         $s2 = new Style($sheet);
@@ -190,7 +190,7 @@ class StyleTest extends TestCase
     #[\PHPUnit\Framework\Attributes\DataProvider('lengthInPtProvider')]
     public function testLengthInPt(string $length, ?float $ref_size, $expected, ?int $precision = null): void
     {
-        $dompdf = new Dompdf();
+        $dompdf = $this->getDompdf();
         $sheet = new Stylesheet($dompdf);
         $s = new Style($sheet);
 
@@ -218,7 +218,7 @@ class StyleTest extends TestCase
     #[\PHPUnit\Framework\Attributes\DataProvider('widthProvider')]
     public function testSetWidth(array $properties, ?float $ref_size, $expected, ?int $precision = null): void
     {
-        $dompdf = new Dompdf();
+        $dompdf = $this->getDompdf();
         $sheet = new Stylesheet($dompdf);
         $s = new Style($sheet);
 
@@ -284,7 +284,7 @@ class StyleTest extends TestCase
     #[\PHPUnit\Framework\Attributes\DataProvider('cssImageNoBaseHrefProvider')]
     public function testCssImageNoBaseHref(string $value, $expected): void
     {
-        $dompdf = new Dompdf();
+        $dompdf = $this->getDompdf();
         $sheet = new Stylesheet($dompdf);
         $sheet->set_base_path(__DIR__); // Treat stylesheet as being located in this directory
         $s = new Style($sheet);
@@ -303,7 +303,7 @@ class StyleTest extends TestCase
     #[\PHPUnit\Framework\Attributes\DataProvider('cssImageWithBaseHrefProvider')]
     public function testCssImageWithBaseHref(string $value, $expected): void
     {
-        $dompdf = new Dompdf();
+        $dompdf = $this->getDompdf();
         $dompdf->setProtocol("https://");
         $dompdf->setBaseHost("example.com");
         $dompdf->setBasePath("/");
@@ -325,7 +325,7 @@ class StyleTest extends TestCase
     #[\PHPUnit\Framework\Attributes\DataProvider('cssImageWithStylesheetBaseHrefProvider')]
     public function testCssImageWithStylesheetBaseHref(string $value, $expected): void
     {
-        $dompdf = new Dompdf();
+        $dompdf = $this->getDompdf();
         $sheet = new Stylesheet($dompdf);
         $sheet->set_protocol("https://");
         $sheet->set_host("example.com");
@@ -408,7 +408,7 @@ class StyleTest extends TestCase
     #[\PHPUnit\Framework\Attributes\DataProvider('backgroundPositionProvider')]
     public function testBackgroundPosition(string $value, $expected): void
     {
-        $dompdf = new Dompdf();
+        $dompdf = $this->getDompdf();
         $sheet = new Stylesheet($dompdf);
         $style = new Style($sheet);
 
@@ -457,7 +457,7 @@ class StyleTest extends TestCase
     #[\PHPUnit\Framework\Attributes\DataProvider('backgroundSizeProvider')]
     public function testBackgroundSize(string $value, $expected): void
     {
-        $dompdf = new Dompdf();
+        $dompdf = $this->getDompdf();
         $sheet = new Stylesheet($dompdf);
         $style = new Style($sheet);
 
@@ -520,7 +520,7 @@ class StyleTest extends TestCase
     #[\PHPUnit\Framework\Attributes\DataProvider('fontWeightProvider')]
     public function testFontWeight(string $value, $expected, int $parentWeight = 400): void
     {
-        $dompdf = new Dompdf();
+        $dompdf = $this->getDompdf();
         $sheet = new Stylesheet($dompdf);
         $style = new Style($sheet);
         $parentStyle = new Style($sheet);
@@ -539,7 +539,7 @@ class StyleTest extends TestCase
         $expected,
         $initialProps = []
     ): void {
-        $dompdf = new Dompdf();
+        $dompdf = $this->getDompdf();
         $sheet = new Stylesheet($dompdf);
         $style = new Style($sheet);
 
@@ -909,7 +909,7 @@ class StyleTest extends TestCase
     #[\PHPUnit\Framework\Attributes\DataProvider('borderSpacingProvider')]
     public function testBorderSpacing(string $value, $expected): void
     {
-        $dompdf = new Dompdf();
+        $dompdf = $this->getDompdf();
         $sheet = new Stylesheet($dompdf);
         $style = new Style($sheet);
 
@@ -961,7 +961,7 @@ class StyleTest extends TestCase
     #[\PHPUnit\Framework\Attributes\DataProvider('counterIncrementProvider')]
     public function testCounterIncrement(string $value, $expected): void
     {
-        $dompdf = new Dompdf();
+        $dompdf = $this->getDompdf();
         $sheet = new Stylesheet($dompdf);
         $style = new Style($sheet);
 
@@ -1013,7 +1013,7 @@ class StyleTest extends TestCase
     #[\PHPUnit\Framework\Attributes\DataProvider('counterResetProvider')]
     public function testCounterReset(string $value, $expected): void
     {
-        $dompdf = new Dompdf();
+        $dompdf = $this->getDompdf();
         $sheet = new Stylesheet($dompdf);
         $style = new Style($sheet);
 
@@ -1054,7 +1054,7 @@ class StyleTest extends TestCase
     #[\PHPUnit\Framework\Attributes\DataProvider('quotesProvider')]
     public function testQuotes(string $value, $expected): void
     {
-        $dompdf = new Dompdf();
+        $dompdf = $this->getDompdf();
         $sheet = new Stylesheet($dompdf);
         $style = new Style($sheet);
 
@@ -1177,7 +1177,7 @@ class StyleTest extends TestCase
     #[\PHPUnit\Framework\Attributes\DataProvider('contentProvider')]
     public function testContent(string $value, $expected): void
     {
-        $dompdf = new Dompdf();
+        $dompdf = $this->getDompdf();
         $sheet = new Stylesheet($dompdf);
         $style = new Style($sheet);
 
@@ -1241,7 +1241,7 @@ class StyleTest extends TestCase
     {
         $options = new Options();
         $options->setDefaultPaperSize("A5");
-        $dompdf = new Dompdf($options);
+        $dompdf = $this->getDompdf($options);
         $sheet = new Stylesheet($dompdf);
         $style = new Style($sheet);
 
@@ -1309,7 +1309,7 @@ class StyleTest extends TestCase
     #[\PHPUnit\Framework\Attributes\DataProvider('transformProvider')]
     public function testTransform(string $value, $expected, array $initial = []): void
     {
-        $dompdf = new Dompdf();
+        $dompdf = $this->getDompdf();
         $sheet = new Stylesheet($dompdf);
         $style = new Style($sheet);
 
@@ -1397,7 +1397,7 @@ class StyleTest extends TestCase
     #[\PHPUnit\Framework\Attributes\DataProvider('transformOriginProvider')]
     public function testTransformOrigin(string $value, $expected): void
     {
-        $dompdf = new Dompdf();
+        $dompdf = $this->getDompdf();
         $sheet = new Stylesheet($dompdf);
         $style = new Style($sheet);
 
@@ -1438,7 +1438,7 @@ class StyleTest extends TestCase
     #[\PHPUnit\Framework\Attributes\DataProvider('opacityProvider')]
     public function testOpacity(string $value, $expected): void
     {
-        $dompdf = new Dompdf();
+        $dompdf = $this->getDompdf();
         $sheet = new Stylesheet($dompdf);
         $style = new Style($sheet);
 
@@ -1472,7 +1472,7 @@ class StyleTest extends TestCase
     #[\PHPUnit\Framework\Attributes\DataProvider('zIndexProvider')]
     public function testZIndex(string $value, $expected): void
     {
-        $dompdf = new Dompdf();
+        $dompdf = $this->getDompdf();
         $sheet = new Stylesheet($dompdf);
         $style = new Style($sheet);
 
@@ -1482,7 +1482,7 @@ class StyleTest extends TestCase
 
     public function testWordBreakBreakWord(): void
     {
-        $dompdf = new Dompdf();
+        $dompdf = $this->getDompdf();
         $sheet = new Stylesheet($dompdf);
         $style = new Style($sheet);
 
@@ -1594,7 +1594,7 @@ class StyleTest extends TestCase
     #[\PHPUnit\Framework\Attributes\DataProvider('varValueProvider')]
     public function testVar(array $properties, $lookup_property, $expected): void
     {
-        $dompdf = new Dompdf();
+        $dompdf = $this->getDompdf();
         $sheet = new Stylesheet($dompdf);
         $style = new Style($sheet);
 
@@ -1656,7 +1656,7 @@ class StyleTest extends TestCase
     #[\PHPUnit\Framework\Attributes\DataProvider('mergedVarValueProvider')]
     public function testMergeVar(array $styleDefs, $lookup_property, $expected): void
     {
-        $dompdf = new Dompdf();
+        $dompdf = $this->getDompdf();
         $sheet = new Stylesheet($dompdf);
         $styles = [
             new Style($sheet),
@@ -1774,7 +1774,7 @@ class StyleTest extends TestCase
 
         $styles = [];
 
-        $dompdf = new Dompdf();
+        $dompdf = $this->getDompdf();
 
         $dompdf->setCallbacks(['test' => [
             'event' => 'end_frame',
diff --git a/tests/Css/StylesheetTest.php b/tests/Css/StylesheetTest.php
index 5fcbf49..cd54d41 100644
--- a/tests/Css/StylesheetTest.php
+++ b/tests/Css/StylesheetTest.php
@@ -52,7 +52,7 @@ CSS
     #[\PHPUnit\Framework\Attributes\DataProvider('parseCssProvider')]
     public function testParseCss(string $css, array $expected): void
     {
-        $dompdf = new Dompdf();
+        $dompdf = $this->getDompdf();
         $sheet = new Stylesheet($dompdf);
         $sheet->load_css($css);
 
@@ -88,7 +88,7 @@ CSS
         $dataUri = "data:image/jpeg;base64," . $imageEncoded;
         $css = "div { background-color: #000; background-image: url(\"$dataUri\"); }";
 
-        $dompdf = new Dompdf();
+        $dompdf = $this->getDompdf();
         $sheet = new Stylesheet($dompdf);
         $sheet->load_css($css);
 
diff --git a/tests/DompdfTest.php b/tests/DompdfTest.php
index 384d5f6..dc1bd23 100644
--- a/tests/DompdfTest.php
+++ b/tests/DompdfTest.php
@@ -16,7 +16,7 @@ class DompdfTest extends TestCase
 {
     public function testConstructor()
     {
-        $dompdf = new Dompdf();
+        $dompdf = $this->getDompdf();
         $this->assertInstanceOf(CPDF::class, $dompdf->getCanvas());
         $this->assertSame("", $dompdf->getProtocol());
         $this->assertSame("", $dompdf->getBaseHost());
@@ -31,7 +31,7 @@ class DompdfTest extends TestCase
 
     public function testSetters()
     {
-        $dompdf = new Dompdf();
+        $dompdf = $this->getDompdf();
         $dompdf->setBaseHost('test1');
         $dompdf->setBasePath('test2');
         $dompdf->setCallbacks(['test' => ['event' => 'test', 'f' => function () {}]]);
@@ -52,7 +52,7 @@ class DompdfTest extends TestCase
         $this->assertEquals('test3', $dompdf->getProtocol());
         $this->assertInstanceOf(FrameTree::class, $dompdf->getTree());
 
-        $dompdf = new Dompdf();
+        $dompdf = $this->getDompdf();
         $dompdf->setHttpContext(['ssl' => ['verify_peer' => false]]);
         $this->assertIsResource($dompdf->getHttpContext());
     }
@@ -166,7 +166,7 @@ class DompdfTest extends TestCase
         ?string $encoding,
         string $expectedText
     ): void {
-        $dompdf = new Dompdf();
+        $dompdf = $this->getDompdf();
         $dompdf->loadHtml($html, $encoding);
 
         $this->assertSame($expectedText, $dompdf->getDom()->textContent);
@@ -174,7 +174,7 @@ class DompdfTest extends TestCase
 
     public function testRender()
     {
-        $dompdf = new Dompdf();
+        $dompdf = $this->getDompdf();
         $dompdf->loadHtml('<html><body><strong>Hello</strong></body></html>');
         $dompdf->render();
 
@@ -200,7 +200,7 @@ class DompdfTest extends TestCase
     {
         $called = 0;
 
-        $dompdf = new Dompdf();
+        $dompdf = $this->getDompdf();
         $dompdf->setCallbacks([
             [
                 "event" => $event,
@@ -223,7 +223,7 @@ class DompdfTest extends TestCase
     {
         $called = 0;
 
-        $dompdf = new Dompdf();
+        $dompdf = $this->getDompdf();
         $dompdf->setCallbacks([
             [
                 "event" => "end_document",
@@ -269,7 +269,7 @@ class DompdfTest extends TestCase
         $options = new Options();
         $options->setDefaultPaperSize("Letter");
 
-        $dompdf = new Dompdf($options);
+        $dompdf = $this->getDompdf($options);
 
         if ($setPaper) {
             $dompdf->setPaper($size, $orientation);
@@ -288,7 +288,7 @@ class DompdfTest extends TestCase
     {
         $text_frame_contents = [];
 
-        $dompdf = new Dompdf();
+        $dompdf = $this->getDompdf();
 
         // Use a callback to inspect the frame tree; otherwise FrameReflower\Page::reflow()
         // will dispose of it before dompdf->render finishes
diff --git a/tests/FrameReflower/ImageTest.php b/tests/FrameReflower/ImageTest.php
index 0829d3e..96c406f 100644
--- a/tests/FrameReflower/ImageTest.php
+++ b/tests/FrameReflower/ImageTest.php
@@ -128,7 +128,7 @@ class ImageTest extends TestCase
         ?ImageFrameDecorator $parentFrame = null,
         array $containingBlock = [0, 0, 400, 400]
     ): ImageFrameDecorator {
-        $style = new Style(new Stylesheet(new Dompdf()));
+        $style = new Style(new Stylesheet($this->getDompdf()));
 
         foreach ($styleProperties as $prop => $val) {
             $style->set_prop($prop, $val);
diff --git a/tests/GeneratedContentTest.php b/tests/GeneratedContentTest.php
index 03e0ff7..0613b32 100644
--- a/tests/GeneratedContentTest.php
+++ b/tests/GeneratedContentTest.php
@@ -602,7 +602,7 @@ HTML
         $content = array_fill_keys(array_keys($expectedContent), []);
 
         // Use callback to inspect frame tree
-        $dompdf = new Dompdf();
+        $dompdf = $this->getDompdf();
         $dompdf->setCallbacks([
             [
                 "event" => "begin_frame",
diff --git a/tests/Helpers/MockHelper.php b/tests/Helpers/MockHelper.php
index c3fddf5..cba82af 100644
--- a/tests/Helpers/MockHelper.php
+++ b/tests/Helpers/MockHelper.php
@@ -17,9 +17,9 @@ class MockHelper
         // initialize static properties
         // For now we cannot mock methods in a constructor
         // https://github.com/mockery/mockery/issues/534
-        // $style = \Mockery::mock(Style::class, [new Stylesheet(new Dompdf())]);
+        // $style = \Mockery::mock(Style::class, [new Stylesheet($this->getDompdf())]);
 
-        new Style(new Stylesheet(new Dompdf()));
+        new Style(new Stylesheet($this->getDompdf()));
         $style = \Mockery::mock(Style::class);
 
         foreach ($properties as $property => $value) {
diff --git a/tests/LayoutTest/ImageTest.php b/tests/LayoutTest/ImageTest.php
index 201840a..d861b08 100644
--- a/tests/LayoutTest/ImageTest.php
+++ b/tests/LayoutTest/ImageTest.php
@@ -183,7 +183,9 @@ HTML
         $options = new Options();
 
         // Use callback to inspect frame tree
-        $dompdf = new Dompdf($options);
+        $dompdf = $this->getDompdf($options);
+        $rootDir = realpath(__DIR__ . '/../../');
+        $options->setChroot([$rootDir, '/usr/share/php/dompdf']);
         $dompdf->setBasePath(__DIR__);
         $dompdf->setCallbacks([
             [
diff --git a/tests/LayoutTest/PageTest.php b/tests/LayoutTest/PageTest.php
index bf37685..6f5ba2c 100644
--- a/tests/LayoutTest/PageTest.php
+++ b/tests/LayoutTest/PageTest.php
@@ -93,7 +93,7 @@ HTML
         $options = new Options();
 
         // Use callback to inspect frame tree
-        $dompdf = new Dompdf($options);
+        $dompdf = $this->getDompdf($options);
         $dompdf->setCallbacks([
             [
                 "event" => "begin_frame",
diff --git a/tests/OptionsTest.php b/tests/OptionsTest.php
index 2231c30..9bb4bcd 100644
--- a/tests/OptionsTest.php
+++ b/tests/OptionsTest.php
@@ -8,12 +8,21 @@ class OptionsTest extends TestCase
 {
     public function testConstructor()
     {
-        $root = realpath(dirname(__DIR__));
-        $option = new Options();
-        $this->assertEquals(sys_get_temp_dir(), $option->getTempDir());
-        $this->assertEquals($root . '/lib/fonts', $option->getFontDir());
-        $this->assertEquals($root . '/lib/fonts', $option->getFontCache());
-        $this->assertEquals([$root], $option->getChroot());
+        $option = $this->getOptions();
+        if (is_dir('/usr/share/php/dompdf/lib/fonts')) {
+            $root = '/usr/share/php/dompdf';
+            $this->assertEquals('/var/cache/php-dompdf/tmp', $option->getTempDir());
+            $this->assertEquals($root . '/lib/fonts', $option->getFontDir());
+            $this->assertEquals('/var/cache/php-dompdf/fonts/', $option->getFontCache());
+            $this->assertEquals([$root], $option->getChroot());
+        }
+        if (! is_dir('/usr/share/php/dompdf/lib/fonts')) {
+            $root = realpath(dirname(__DIR__));
+            $this->assertEquals($root . '/tmp', $option->getTempDir());
+            $this->assertEquals($root . '/lib/fonts', $option->getFontDir());
+            $this->assertEquals($root . '/lib/fonts', $option->getFontCache());
+            $this->assertEquals([$root], $option->getChroot());
+        }
         $this->assertEmpty($option->getLogOutputFile());
         $this->assertEquals('screen', $option->getDefaultMediaType());
         $this->assertEquals('letter', $option->getDefaultPaperSize());
@@ -114,7 +123,7 @@ class OptionsTest extends TestCase
         [$validation_result] = $allowedProtocols["http://"]["rules"][0]("http://example.com/");
         $this->assertFalse($validation_result);
 
-        
+
         $mock_protocol = [
             "mock://" => [
                 "rules" => [
diff --git a/tests/OutputTest/Dataset.php b/tests/OutputTest/Dataset.php
index 2760586..9b74200 100644
--- a/tests/OutputTest/Dataset.php
+++ b/tests/OutputTest/Dataset.php
@@ -34,12 +34,41 @@ final class Dataset
         return new SplFileInfo("$path/$name.pdf");
     }
 
+    protected function getDompdf(Options $options = null): Dompdf
+    {
+        return new Dompdf($this->getOptions($options));
+    }
+
+    protected function getOptions(Options $options = null): Options
+    {
+        $options = $options === null ? new Options() : $options;
+
+        if (is_dir('/usr/share/php/dompdf/lib/fonts')) {
+
+            $rootDir = realpath(__DIR__ . '/../../');
+            $options = $options
+                ->setChroot(array($rootDir))
+                ->setRootDir($rootDir);
+            return $options;
+        }
+
+        $rootDir = realpath(__DIR__ . '/../../');
+        $options = $options
+            ->setChroot(array($rootDir))
+            ->setRootDir($rootDir)
+            ->setTempDir($rootDir . '/tmp')
+            ->setFontDir($rootDir . '/lib/fonts')
+            ->setFontCache($rootDir . '/lib/fonts');
+
+        return $options;
+    }
+
     public function render(string $backend = "cpdf"): Dompdf
     {
         $options = new Options();
         $options->setPdfBackend($backend);
 
-        $pdf = new Dompdf($options);
+        $pdf = $this->getDompdf($options);
         $pdf->loadHtmlFile($this->file->getPathname());
         $pdf->setBasePath($this->file->getPath());
         $pdf->render();
diff --git a/tests/Renderer/RendererTest.php b/tests/Renderer/RendererTest.php
index 9ef8648..fb71dee 100644
--- a/tests/Renderer/RendererTest.php
+++ b/tests/Renderer/RendererTest.php
@@ -16,7 +16,7 @@ class RendererTest extends TestCase
 
     public function setUp() : void
     {
-        $dompdf = new Dompdf();
+        $dompdf = $this->getDompdf();
         $this->renderer = new Renderer($dompdf);
         $this->resizeBackgroundImageMethod = self::getMethod('_resize_background_image');
     }
diff --git a/tests/TestCase.php b/tests/TestCase.php
index b9ad809..bdaa24a 100644
--- a/tests/TestCase.php
+++ b/tests/TestCase.php
@@ -3,9 +3,38 @@ namespace Dompdf\Tests;
 
 use PHPUnit\Framework\TestCase as BaseTestCase;
 use Mockery\Adapter\Phpunit\MockeryPHPUnitIntegration;
+use Dompdf\Dompdf;
+use Dompdf\Options;
 
 class TestCase extends BaseTestCase
 {
     use MockeryPHPUnitIntegration;
 
+    protected function getDompdf(Options $options = null): Dompdf
+    {
+        if (is_dir('/usr/share/php/dompdf/lib/fonts')) {
+            return new Dompdf($options);
+        }
+
+        return new Dompdf($this->getOptions($options));
+    }
+
+    protected function getOptions(Options $options = null): Options
+    {
+        $options = $options === null ? new Options() : $options;
+
+        if (is_dir('/usr/share/php/dompdf/lib/fonts')) {
+            return $options;
+        }
+
+        $rootDir = realpath(__DIR__ . '/../');
+        $options = $options
+            ->setChroot(array($rootDir))
+            ->setRootDir($rootDir)
+            ->setTempDir($rootDir . '/tmp')
+            ->setFontDir($rootDir . '/lib/fonts')
+            ->setFontCache($rootDir . '/lib/fonts');
+
+        return $options;
+    }
 }