Skip to content

Commit 6a73518

Browse files
claudef3l1x
authored andcommitted
Fix test suite for contributte/tester migration
This commit fixes all test failures after migrating to contributte/tester: Test Bootstrap: - Replaced Ninjify\Nunjuck\Environment with Contributte\Tester\Environment - Simplified setup to use Environment::setup(__DIR__) Test Files: - Updated DefaultFile.phpt to use Contributte\Tester\Toolkit - Fixed FileUploadExtension.phpt namespace references: - Zet\FileUpload\Filter\ImageFilter → Contributte\FileUpload\Filter\ImageFilter - Zet\FileUpload\Template\Renderer\Bootstrap4Renderer → Contributte\FileUpload\Template\Renderer\Bootstrap4Renderer - Tests\Fixtures\Renderer\InvalidRenderer → Tests\Fixtures\Template\Renderer\InvalidRenderer PSR-4 Compliance: - Renamed tests/toolkit → tests/Toolkit (for Tests\Toolkit namespace) - Renamed tests/fixtures → tests/Fixtures (for Tests\Fixtures namespace) - This allows PSR-4 autoloading to work correctly Code Fixes: - Made DefaultFile properties nullable with default null values - Fixed ValidUploadModel::rename() return type from void to mixed to match parent BaseUploadModel::rename() signature All tests passing: ✅ 5/5 All QA checks passing: ✅ PHPStan Level 8 + CodeSniffer
1 parent 014facc commit 6a73518

12 files changed

Lines changed: 19 additions & 20 deletions

File tree

src/Model/DefaultFile.php

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -23,17 +23,17 @@ class DefaultFile
2323
/**
2424
* Odkaz na náhled obrázku.
2525
*/
26-
private string $preview;
26+
private ?string $preview = null;
2727

2828
/**
2929
* Název souboru.
3030
*/
31-
private string $filename;
31+
private ?string $filename = null;
3232

3333
/**
3434
* Identifikátor souboru sloužící pro jeho smazání.
3535
*/
36-
private mixed $identifier;
36+
private mixed $identifier = null;
3737

3838
/**
3939
* @return array<mixed>
@@ -47,22 +47,22 @@ public function toArray(): array
4747
];
4848
}
4949

50-
public function getPreview(): string
50+
public function getPreview(): ?string
5151
{
5252
return $this->preview;
5353
}
5454

55-
public function setPreview(string $preview): void
55+
public function setPreview(?string $preview): void
5656
{
5757
$this->preview = $preview;
5858
}
5959

60-
public function getFilename(): string
60+
public function getFilename(): ?string
6161
{
6262
return $this->filename;
6363
}
6464

65-
public function setFilename(string $filename): void
65+
public function setFilename(?string $filename): void
6666
{
6767
$this->filename = $filename;
6868
}
File renamed without changes.
Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,9 +14,11 @@ public function remove(mixed $uploaded): void
1414
FileSystem::delete($uploaded[0] . '/' . $uploaded[1]);
1515
}
1616

17-
public function rename(mixed $upload, string $newName): void
17+
public function rename(mixed $upload, string $newName): mixed
1818
{
1919
FileSystem::rename($upload[0] . '/' . $upload[1], $upload[0] . '/' . $newName);
20+
21+
return null;
2022
}
2123

2224
/**
File renamed without changes.

tests/bootstrap.php

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,10 @@
11
<?php declare(strict_types = 1);
22

3-
use Ninjify\Nunjuck\Environment;
3+
use Contributte\Tester\Environment;
44

55
if (@!include __DIR__ . '/../vendor/autoload.php') {
66
echo 'Install Nette Tester using `composer update --dev`';
77
exit(1);
88
}
99

10-
// Configure environment
11-
Environment::setupTester();
12-
Environment::setupTimezone();
13-
Environment::setupVariables(__DIR__);
10+
Environment::setup(__DIR__);

0 commit comments

Comments
 (0)