Skip to content

Commit 637c7df

Browse files
test: replace reflection with explicit test double for status fallback
Signed-off-by: Vitor Mattos <1079143+vitormattos@users.noreply.github.com>
1 parent 8770272 commit 637c7df

1 file changed

Lines changed: 9 additions & 4 deletions

File tree

tests/php/Unit/Db/FileTest.php

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,12 @@
1515
use OCA\Libresign\Tests\Unit\TestCase;
1616
use PHPUnit\Framework\Attributes\DataProvider;
1717

18+
final class FileWithNullableStatusForTest extends File {
19+
public function forceNullStatusForTest(): void {
20+
$this->status = null;
21+
}
22+
}
23+
1824
final class FileTest extends TestCase {
1925
private File $file;
2026

@@ -58,11 +64,10 @@ public function testHasParentReturnsTrueWhenParentFileIdIsSet(): void {
5864
}
5965

6066
public function testGetStatusReturnsDraftWhenInternalStatusIsNull(): void {
61-
$reflectionProperty = new \ReflectionProperty($this->file, 'status');
62-
$reflectionProperty->setAccessible(true);
63-
$reflectionProperty->setValue($this->file, null);
67+
$file = new FileWithNullableStatusForTest();
68+
$file->forceNullStatusForTest();
6469

65-
$this->assertSame(FileStatus::DRAFT->value, $this->file->getStatus());
70+
$this->assertSame(FileStatus::DRAFT->value, $file->getStatus());
6671
}
6772

6873
public function testSetStatusRejectsInvalidStatusCode(): void {

0 commit comments

Comments
 (0)