@@ -73,115 +73,137 @@ composer update
7373
7474## Basic Usage
7575
76- ### Using TestSupport trait
76+ ### Accessing private properties
7777
7878``` php
7979<?php
80-
8180declare(strict_types=1);
8281
8382use PHPForge\Support\TestSupport;
8483use PHPUnit\Framework\TestCase;
8584
86- final class MyTest extends TestCase
85+ final class AccessPrivatePropertyTest extends TestCase
8786{
8887 use TestSupport;
8988
90- public function testInaccessibleProperty()
89+ public function testInaccesibleProperty():void
9190 {
9291 $object = new class () {
9392 private string $secretValue = 'hidden';
9493 };
9594
9695 $value = self::inaccessibleProperty($object, 'secretValue');
9796
98- self::assertSame('hidden', $value);
97+ self::assertSame('hidden', $value, "Should access the private property and return its value." );
9998 }
10099}
101100```
102101
103- ### Accessing private properties
102+ ### Invoking protected methods
104103
105104``` php
106105<?php
107-
108106declare(strict_types=1);
109107
110- $object = new class () {
111- private string $secretValue = 'hidden';
112- };
113-
114- // access private properties for testing
115- $value = self::inaccessibleProperty($object, 'secretValue');
116-
117- self::assertSame('hidden', $value);
118- ```
108+ use PHPForge\Support\TestSupport;
109+ use PHPUnit\Framework\TestCase;
119110
120- ### Equals without line ending
111+ final class InvokeProtectedMethodTest extends TestCase
112+ {
113+ use TestSupport;
121114
122- ``` php
123- <?php
115+ public function testInvokeMethod(): void
116+ {
117+ $object = new class () {
118+ protected function calculate(int $a, int $b): int
119+ {
120+ return $a + $b;
121+ }
122+ };
124123
125- declare(strict_types=1 );
124+ $result = self::invokeMethod($object, 'calculate', [5, 3] );
126125
127- // normalize line endings for consistent comparisons
128- self::assertSame(
129- self::normalizeLineEndings("Foo\r\nBar"),
130- self::normalizeLineEndings("Foo\nBar"),
131- "Should match regardless of line ending style"
132- );
126+ self::assertSame(8, $result, "Should invoke the protected method and return the correct sum.");
127+ }
128+ }
133129```
134130
135- ### Invoking protected methods
131+ ### Normalize line endings
136132
137133``` php
138134<?php
139-
140135declare(strict_types=1);
141136
142- $object = new class () {
143- protected function calculate(int $a, int $b): int
144- {
145- return $a + $b;
146- }
147- };
137+ use PHPForge\Support\TestSupport;
138+ use PHPUnit\Framework\TestCase;
148139
149- // test protected method behavior
150- $result = self::invokeMethod($object, 'calculate', [5, 3]);
140+ final class NormalizeLineEndingsTest extends TestCase
141+ {
142+ use TestSupport;
151143
152- self::assertSame(8, $result);
144+ public function testNormalizedComparison(): void
145+ {
146+ self::assertSame(
147+ self::normalizeLineEndings("Foo\r\nBar"),
148+ self::normalizeLineEndings("Foo\nBar"),
149+ "Should match regardless of line ending style",
150+ );
151+ }
152+ }
153153```
154154
155155### Remove files from directory
156156
157157``` php
158158<?php
159-
160159declare(strict_types=1);
161160
162- $testDir = dirname(__DIR__) . '/runtime';
161+ use PHPForge\Support\TestSupport;
162+ use PHPUnit\Framework\TestCase;
163+
164+ final class RemoveFilesFromDirectoryTest extends TestCase
165+ {
166+ use TestSupport;
163167
164- // clean up test artifacts (preserves '.gitignore' and '.gitkeep')
165- self::removeFilesFromDirectory($testDir);
168+ public function testCleanup(): void
169+ {
170+ $testDir = dirname(__DIR__) . '/runtime';
171+ // clean up test artifacts (preserves '.gitignore' and '.gitkeep')
172+
173+ self::removeFilesFromDirectory($testDir);
174+
175+ self::assertTrue(true, "Should remove all files in the test directory while preserving Git-tracked files.");
176+ }
177+ }
166178```
167179
168180### Set inaccessible property
169181
170182``` php
171183<?php
172-
173184declare(strict_types=1);
174185
175- $object = new class () {
176- private string $config = 'default';
177- };
186+ use PHPForge\Support\TestSupport;
187+ use PHPUnit\Framework\TestCase;
178188
179- // set private property for testing scenarios
180- self::setInaccessibleProperty($object, 'config', 'test-mode');
189+ final class SetInaccessiblePropertyTest extends TestCase
190+ {
191+ use TestSupport;
181192
182- $newValue = self::inaccessibleProperty($object, 'config');
193+ public function testSetProperty()
194+ {
195+ $object = new class () {
196+ private string $config = 'default';
197+ };
198+
199+ // set private property for testing scenarios
200+ self::setInaccessibleProperty($object, 'config', 'test-mode');
183201
184- self::assertSame('test-mode', $newValue);
202+ $newValue = self::inaccessibleProperty($object, 'config');
203+
204+ self::assertSame('test-mode', $newValue, "Should set the inaccessible property to 'test-mode'.");
205+ }
206+ }
185207```
186208
187209## Documentation
0 commit comments