-
-
Notifications
You must be signed in to change notification settings - Fork 1.6k
Expand file tree
/
Copy pathTcpdfColorTest.php
More file actions
60 lines (48 loc) · 1.75 KB
/
Copy pathTcpdfColorTest.php
File metadata and controls
60 lines (48 loc) · 1.75 KB
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
<?php
declare(strict_types=1);
/**
* Color family tests (legacy component conventions to engine operators).
*
* @package com.tecnick.tcpdf
*/
require_once __DIR__ . '/TcpdfTestCase.php';
class TcpdfColorTest extends TcpdfTestCase
{
public function testDrawColorOperators(): void
{
$pdf = $this->newPdf();
$pdf->AddPage();
// RGB 0-255 components produce a stroking 'RG' operator.
$cmd = $pdf->setDrawColor(255, 0, 0, -1, true);
$this->assertIsString($cmd);
$this->assertStringContainsString('RG', $cmd);
// Grayscale single component produces a stroking gray operator.
$cmd = $pdf->setDrawColor(128, -1, -1, -1, true);
$this->assertIsString($cmd);
$this->assertMatchesRegularExpression('/(G|RG)/', $cmd);
// CMYK 0-100 four components produce a 'K' operator.
$cmd = $pdf->setDrawColor(100, 0, 0, 50, true);
$this->assertIsString($cmd);
$this->assertStringContainsString('K', $cmd);
}
public function testFillColorOperators(): void
{
$pdf = $this->newPdf();
$pdf->AddPage();
$cmd = $pdf->setFillColor(0, 255, 0, -1, true);
$this->assertIsString($cmd);
$this->assertStringContainsString('rg', $cmd);
$cmd = $pdf->setFillColorArray([0, 0, 100, 0], true);
$this->assertIsString($cmd);
$this->assertStringContainsString('k', $cmd);
}
public function testTextColorIsAppliedToText(): void
{
$pdf = $this->newPdf();
$pdf->setFont('helvetica', '', 12);
$pdf->AddPage();
$pdf->setTextColor(200, 10, 10);
$pdf->Cell(0, 0, 'colored text', 0, 1);
$this->assertStringContainsString('colored text', $this->extractText($pdf));
}
}