Skip to content

Commit 645823c

Browse files
committed
PhpUnit: remove dynamic calls to static methods
Signed-off-by: Julien Dephix <[email protected]>
1 parent d8550ba commit 645823c

File tree

3 files changed

+25
-55
lines changed

3 files changed

+25
-55
lines changed

phpstan-baseline.neon

Lines changed: 0 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -125,37 +125,7 @@ parameters:
125125
count: 1
126126
path: src/ShapeRecord.php
127127

128-
-
129-
message: "#^Dynamic call to static method PHPUnit\\\\Framework\\\\Assert\\:\\:assertEquals\\(\\)\\.$#"
130-
count: 18
131-
path: tests/ShapeFileTest.php
132-
133-
-
134-
message: "#^Dynamic call to static method PHPUnit\\\\Framework\\\\Assert\\:\\:assertFileDoesNotExist\\(\\)\\.$#"
135-
count: 1
136-
path: tests/ShapeFileTest.php
137-
138-
-
139-
message: "#^Dynamic call to static method PHPUnit\\\\Framework\\\\Assert\\:\\:assertNotEquals\\(\\)\\.$#"
140-
count: 1
141-
path: tests/ShapeFileTest.php
142-
143-
-
144-
message: "#^Dynamic call to static method PHPUnit\\\\Framework\\\\Assert\\:\\:assertNull\\(\\)\\.$#"
145-
count: 1
146-
path: tests/ShapeFileTest.php
147-
148-
-
149-
message: "#^Dynamic call to static method PHPUnit\\\\Framework\\\\Assert\\:\\:markTestSkipped\\(\\)\\.$#"
150-
count: 3
151-
path: tests/ShapeFileTest.php
152-
153128
-
154129
message: "#^Parameter \\#1 \\$value of function count expects array\\|Countable, mixed given\\.$#"
155130
count: 1
156131
path: tests/ShapeFileTest.php
157-
158-
-
159-
message: "#^Dynamic call to static method PHPUnit\\\\Framework\\\\Assert\\:\\:assertEquals\\(\\)\\.$#"
160-
count: 1
161-
path: tests/UtilTest.php

tests/ShapeFileTest.php

Lines changed: 24 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -47,13 +47,13 @@ public function testLoad(string $filename, int $records, int|null $parts): void
4747
{
4848
$shp = new ShapeFile(ShapeType::Point);
4949
$shp->loadFromFile($filename);
50-
$this->assertEquals('', $shp->lastError);
51-
$this->assertEquals($records, count($shp->records));
50+
self::assertEquals('', $shp->lastError);
51+
self::assertEquals($records, count($shp->records));
5252
if ($parts === null) {
5353
return;
5454
}
5555

56-
$this->assertEquals($parts, count($shp->records[0]->shpData['parts']));
56+
self::assertEquals($parts, count($shp->records[0]->shpData['parts']));
5757
}
5858

5959
/**
@@ -108,7 +108,7 @@ public function testLoadError(string $filename): void
108108
{
109109
$shp = new ShapeFile(ShapeType::Point);
110110
$shp->loadFromFile($filename);
111-
$this->assertNotEquals('', $shp->lastError);
111+
self::assertNotEquals('', $shp->lastError);
112112
}
113113

114114
/**
@@ -119,12 +119,12 @@ public function testLoadEmptyFilename(): void
119119
$shp = new ShapeFile(ShapeType::Point);
120120
$shp->loadFromFile('');
121121
if (ShapeFile::supportsDbase()) {
122-
$this->assertEquals('It wasn\'t possible to find the DBase file ""', $shp->lastError);
122+
self::assertEquals('It wasn\'t possible to find the DBase file ""', $shp->lastError);
123123

124124
return;
125125
}
126126

127-
$this->assertEquals('Not a SHP file (file code mismatch)', $shp->lastError);
127+
self::assertEquals('Not a SHP file (file code mismatch)', $shp->lastError);
128128
}
129129

130130
/**
@@ -133,7 +133,7 @@ public function testLoadEmptyFilename(): void
133133
public function testGetDBFHeader(): void
134134
{
135135
$shp = new ShapeFile(ShapeType::Point);
136-
$this->assertNull($shp->getDBFHeader());
136+
self::assertNull($shp->getDBFHeader());
137137
}
138138

139139
/**
@@ -222,14 +222,14 @@ private function createTestData(): void
222222
public function testCreate(): void
223223
{
224224
if (! ShapeFile::supportsDbase()) {
225-
$this->markTestSkipped('dbase extension missing');
225+
self::markTestSkipped('dbase extension missing');
226226
}
227227

228228
$this->createTestData();
229229

230230
$shp = new ShapeFile(ShapeType::Point);
231231
$shp->loadFromFile('./data/test_shape.*');
232-
$this->assertEquals(4, count($shp->records));
232+
self::assertEquals(4, count($shp->records));
233233
}
234234

235235
/**
@@ -238,7 +238,7 @@ public function testCreate(): void
238238
public function testDelete(): void
239239
{
240240
if (! ShapeFile::supportsDbase()) {
241-
$this->markTestSkipped('dbase extension missing');
241+
self::markTestSkipped('dbase extension missing');
242242
}
243243

244244
$this->createTestData();
@@ -247,11 +247,11 @@ public function testDelete(): void
247247
$shp->loadFromFile('./data/test_shape.*');
248248
$shp->deleteRecord(1);
249249
$shp->saveToFile();
250-
$this->assertEquals(3, count($shp->records));
250+
self::assertEquals(3, count($shp->records));
251251

252252
$shp = new ShapeFile(ShapeType::Point);
253253
$shp->loadFromFile('./data/test_shape.*');
254-
$this->assertEquals(3, count($shp->records));
254+
self::assertEquals(3, count($shp->records));
255255
}
256256

257257
/**
@@ -260,7 +260,7 @@ public function testDelete(): void
260260
public function testAdd(): void
261261
{
262262
if (! ShapeFile::supportsDbase()) {
263-
$this->markTestSkipped('dbase extension missing');
263+
self::markTestSkipped('dbase extension missing');
264264
}
265265

266266
$this->createTestData();
@@ -276,11 +276,11 @@ public function testAdd(): void
276276
$shp->records[4]->dbfData['DESC'] = 'CCCCCCCCCCC';
277277

278278
$shp->saveToFile();
279-
$this->assertEquals(5, count($shp->records));
279+
self::assertEquals(5, count($shp->records));
280280

281281
$shp = new ShapeFile(ShapeType::Point);
282282
$shp->loadFromFile('./data/test_shape.*');
283-
$this->assertEquals(5, count($shp->records));
283+
self::assertEquals(5, count($shp->records));
284284
}
285285

286286
/**
@@ -291,7 +291,7 @@ public function testSaveNoDBF(): void
291291
$shp = new ShapeFile(ShapeType::Point);
292292
$shp->saveToFile('./data/test_nodbf.*');
293293

294-
$this->assertFileDoesNotExist('./data/test_nodbf.dbf');
294+
self::assertFileDoesNotExist('./data/test_nodbf.dbf');
295295
}
296296

297297
/**
@@ -300,13 +300,13 @@ public function testSaveNoDBF(): void
300300
public function testShapeName(): void
301301
{
302302
$obj = new ShapeRecord(ShapeType::Point);
303-
$this->assertEquals('Point', $obj->getShapeName());
303+
self::assertEquals('Point', $obj->getShapeName());
304304
$obj = new ShapeFile(ShapeType::Point);
305-
$this->assertEquals('Point', $obj->getShapeName());
305+
self::assertEquals('Point', $obj->getShapeName());
306306
$obj = new ShapeRecord(ShapeType::Null);
307-
$this->assertEquals('Null Shape', $obj->getShapeName());
307+
self::assertEquals('Null Shape', $obj->getShapeName());
308308
$obj = new ShapeRecord(ShapeType::Unknown);
309-
$this->assertEquals('Unknown Shape', $obj->getShapeName());
309+
self::assertEquals('Unknown Shape', $obj->getShapeName());
310310
}
311311

312312
/**
@@ -335,7 +335,7 @@ public function testShapeSaveLoad(ShapeType $shapeType, array $points): void
335335
$shp2 = new ShapeFile($shapeType);
336336
$shp2->loadFromFile($filename);
337337

338-
$this->assertEquals(count($shp->records), count($shp2->records));
338+
self::assertEquals(count($shp->records), count($shp2->records));
339339

340340
$record = $shp->records[0];
341341
$record2 = $shp2->records[0];
@@ -346,7 +346,7 @@ public function testShapeSaveLoad(ShapeType $shapeType, array $points): void
346346
continue;
347347
}
348348

349-
$this->assertEquals($record->shpData[$item], $record2->shpData[$item]);
349+
self::assertEquals($record->shpData[$item], $record2->shpData[$item]);
350350
}
351351

352352
/* Test deletion works */
@@ -405,15 +405,15 @@ public function testSearch(): void
405405
$shp = new ShapeFile(ShapeType::Null);
406406
$shp->loadFromFile('data/capitals.*');
407407
/* Nonexisting entry or no dbase support */
408-
$this->assertEquals(
408+
self::assertEquals(
409409
-1,
410410
$shp->getIndexFromDBFData('CNTRY_NAME', 'nonexisting'),
411411
);
412412
if (! ShapeFile::supportsDbase()) {
413413
return;
414414
}
415415

416-
$this->assertEquals(
416+
self::assertEquals(
417417
218,
418418
$shp->getIndexFromDBFData('CNTRY_NAME', 'Czech Republic'),
419419
);

tests/UtilTest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ class UtilTest extends TestCase
4040
*/
4141
public function testLoadData(string $type, string|false $data, mixed $expected): void
4242
{
43-
$this->assertEquals(
43+
self::assertEquals(
4444
$expected,
4545
Util::loadData($type, $data),
4646
);

0 commit comments

Comments
 (0)