Skip to content

Commit 97ebf29

Browse files
committed
Allow GIS tests to test against different TCPDF versions
Signed-off-by: Maurício Meneghini Fauth <mauricio@fauth.dev>
1 parent 0b097b3 commit 97ebf29

13 files changed

Lines changed: 27 additions & 50 deletions

composer.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -118,7 +118,7 @@
118118
"psalm/plugin-phpunit": "^0.18.4",
119119
"roave/security-advisories": "dev-latest",
120120
"symfony/console": "^6.2",
121-
"tecnickcom/tcpdf": "6.6.2",
121+
"tecnickcom/tcpdf": "^6.4.4",
122122
"vimeo/psalm": "^5.14",
123123
"web-auth/webauthn-lib": "^3.3.12"
124124
},

phpstan-baseline.neon

Lines changed: 0 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -15905,11 +15905,6 @@ parameters:
1590515905
count: 2
1590615906
path: src/Plugins/Schema/Pdf/RelationStatsPdf.php
1590715907

15908-
-
15909-
message: "#^Binary operation \"\\+\\=\" between float\\|int and array\\<float\\>\\|float results in an error\\.$#"
15910-
count: 1
15911-
path: src/Plugins/Schema/Pdf/TableStatsPdf.php
15912-
1591315908
-
1591415909
message: "#^Call to function in_array\\(\\) requires parameter \\#3 to be set\\.$#"
1591515910
count: 1
@@ -15945,16 +15940,6 @@ parameters:
1594515940
count: 2
1594615941
path: src/Plugins/Schema/Pdf/TableStatsPdf.php
1594715942

15948-
-
15949-
message: "#^Property PhpMyAdmin\\\\Plugins\\\\Schema\\\\TableStats\\:\\:\\$width \\(float\\|int\\) does not accept array\\<float\\>\\|float\\|int\\.$#"
15950-
count: 1
15951-
path: src/Plugins/Schema/Pdf/TableStatsPdf.php
15952-
15953-
-
15954-
message: "#^Property PhpMyAdmin\\\\Plugins\\\\Schema\\\\TableStats\\:\\:\\$width \\(float\\|int\\) does not accept mixed\\.$#"
15955-
count: 1
15956-
path: src/Plugins/Schema/Pdf/TableStatsPdf.php
15957-
1595815943
-
1595915944
message: "#^Binary operation \"\\+\" between int\\|string\\|false and 1\\.5 results in an error\\.$#"
1596015945
count: 1

psalm-baseline.xml

Lines changed: 8 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -8124,6 +8124,10 @@
81248124
<ParamNameMismatch>
81258125
<code>$errorMessage</code>
81268126
</ParamNameMismatch>
8127+
<PropertyNotSetInConstructor>
8128+
<code>Pdf</code>
8129+
<code>Pdf</code>
8130+
</PropertyNotSetInConstructor>
81278131
</file>
81288132
<file src="src/Plugins.php">
81298133
<DeprecatedMethod>
@@ -9340,6 +9344,8 @@
93409344
<code>$results</code>
93419345
<code>Pdf</code>
93429346
<code>Pdf</code>
9347+
<code>Pdf</code>
9348+
<code>Pdf</code>
93439349
</PropertyNotSetInConstructor>
93449350
</file>
93459351
<file src="src/Plugins/ExportPlugin.php">
@@ -10199,6 +10205,8 @@
1019910205
<PropertyNotSetInConstructor>
1020010206
<code>Pdf</code>
1020110207
<code>Pdf</code>
10208+
<code>Pdf</code>
10209+
<code>Pdf</code>
1020210210
</PropertyNotSetInConstructor>
1020310211
<UnsupportedPropertyReferenceUsage>
1020410212
<code><![CDATA[$cw = &$this->CurrentFont['cw']]]></code>
@@ -10401,16 +10409,6 @@
1040110409
<MixedOperand>
1040210410
<code>$field</code>
1040310411
</MixedOperand>
10404-
<PossiblyInvalidOperand>
10405-
<code><![CDATA[$this->diagram->GetStringWidth(' ')]]></code>
10406-
<code><![CDATA[$this->width]]></code>
10407-
<code>5</code>
10408-
</PossiblyInvalidOperand>
10409-
<PossiblyInvalidPropertyAssignmentValue>
10410-
<code><![CDATA[$this->width += $this->diagram->GetStringWidth(' ')]]></code>
10411-
<code><![CDATA[$this->width += 5]]></code>
10412-
<code><![CDATA[max($this->width, $this->diagram->GetStringWidth($field))]]></code>
10413-
</PossiblyInvalidPropertyAssignmentValue>
1041410412
</file>
1041510413
<file src="src/Plugins/Schema/RelationStats.php">
1041610414
<InvalidOperand>

src/Plugins/Export/Helpers/Pdf.php

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -696,7 +696,6 @@ public function mysqlReport(string $query): void
696696
$colAs = $this->aliases[$db]['tables'][$table]['columns'][$colAs];
697697
}
698698

699-
/** @var float $stringWidth */
700699
$stringWidth = $this->GetStringWidth($colAs);
701700
$stringWidth += 6;
702701
// save the real title's width
@@ -751,7 +750,6 @@ public function mysqlReport(string $query): void
751750
/** @todo force here a LIMIT to avoid reading all rows */
752751
while ($row = $this->results->fetchRow()) {
753752
foreach ($colFits as $key => $val) {
754-
/** @var float $stringWidth */
755753
$stringWidth = $this->GetStringWidth($row[$key] ?? 'NULL');
756754
$stringWidth += 6;
757755
if ($adjustingMode && ($stringWidth > $sColWidth)) {

test/classes/Gis/GisGeomTestCase.php

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010
use PhpMyAdmin\Tests\AbstractTestCase;
1111
use ReflectionProperty;
1212
use TCPDF;
13+
use TCPDF_STATIC;
1314

1415
use function getcwd;
1516
use function md5;
@@ -29,6 +30,16 @@ protected function setUp(): void
2930
parent::setUp();
3031

3132
$this->testDir = 'file://' . getcwd() . '/test/test_data/gis';
33+
34+
(new ReflectionProperty(TCPDF_STATIC::class, 'tcpdf_version'))->setValue(null, '6.6.2');
35+
}
36+
37+
protected function tearDown(): void
38+
{
39+
parent::tearDown();
40+
41+
$property = new ReflectionProperty(TCPDF_STATIC::class, 'tcpdf_version');
42+
$property->setValue(null, $property->getDefaultValue());
3243
}
3344

3445
protected function getArch(): string

test/classes/Gis/GisGeometryCollectionTest.php

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -321,9 +321,7 @@ public function testPrepareRowAsPdf(
321321
$object->prepareRowAsPdf($spatial, $label, $color, $scaleData, $pdf);
322322

323323
$fileExpected = $this->testDir . '/geometrycollection-expected.pdf';
324-
$fileActual = $this->testDir . '/geometrycollection-actual.pdf';
325-
$pdf->Output($fileActual, 'F');
326-
$this->assertFileEquals($fileExpected, $fileActual);
324+
$this->assertStringEqualsFile($fileExpected, $pdf->Output(dest: 'S'));
327325
}
328326

329327
/**

test/classes/Gis/GisLineStringTest.php

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -193,9 +193,7 @@ public function testPrepareRowAsPdf(
193193
$object->prepareRowAsPdf($spatial, $label, $color, $scaleData, $pdf);
194194

195195
$fileExpected = $this->testDir . '/linestring-expected.pdf';
196-
$fileActual = $this->testDir . '/linestring-actual.pdf';
197-
$pdf->Output($fileActual, 'F');
198-
$this->assertFileEquals($fileExpected, $fileActual);
196+
$this->assertStringEqualsFile($fileExpected, $pdf->Output(dest: 'S'));
199197
}
200198

201199
/**

test/classes/Gis/GisMultiLineStringTest.php

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -201,9 +201,7 @@ public function testPrepareRowAsPdf(
201201
$object->prepareRowAsPdf($spatial, $label, $color, $scaleData, $pdf);
202202

203203
$fileExpected = $this->testDir . '/multilinestring-expected.pdf';
204-
$fileActual = $this->testDir . '/multilinestring-actual.pdf';
205-
$pdf->Output($fileActual, 'F');
206-
$this->assertFileEquals($fileExpected, $fileActual);
204+
$this->assertStringEqualsFile($fileExpected, $pdf->Output(dest: 'S'));
207205
}
208206

209207
/**

test/classes/Gis/GisMultiPointTest.php

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -180,9 +180,7 @@ public function testPrepareRowAsPdf(
180180
$fileExpectedArch = $this->testDir . '/multipoint-expected-' . $this->getArch() . '.pdf';
181181
$fileExpectedGeneric = $this->testDir . '/multipoint-expected.pdf';
182182
$fileExpected = file_exists($fileExpectedArch) ? $fileExpectedArch : $fileExpectedGeneric;
183-
$fileActual = $this->testDir . '/multipoint-actual.pdf';
184-
$pdf->Output($fileActual, 'F');
185-
$this->assertFileEquals($fileExpected, $fileActual);
183+
$this->assertStringEqualsFile($fileExpected, $pdf->Output(dest: 'S'));
186184
}
187185

188186
/**

test/classes/Gis/GisMultiPolygonTest.php

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -287,9 +287,7 @@ public function testPrepareRowAsPdf(
287287
$object->prepareRowAsPdf($spatial, $label, $color, $scaleData, $pdf);
288288

289289
$fileExpected = $this->testDir . '/multipolygon-expected.pdf';
290-
$fileActual = $this->testDir . '/multipolygon-actual.pdf';
291-
$pdf->Output($fileActual, 'F');
292-
$this->assertFileEquals($fileExpected, $fileActual);
290+
$this->assertStringEqualsFile($fileExpected, $pdf->Output(dest: 'S'));
293291
}
294292

295293
/**

0 commit comments

Comments
 (0)