Skip to content

Commit a609ee8

Browse files
committed
Refactor - Add helper classes for testing internal class defaults and final methods in StopwatchDecorator
1 parent ea31806 commit a609ee8

File tree

3 files changed

+56
-36
lines changed

3 files changed

+56
-36
lines changed
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
<?php
2+
declare(strict_types = 1);
3+
/**
4+
* /tests/Integration/Decorator/FinalTestService.php
5+
*
6+
* @author TLe, Tarmo Leppänen <tarmo.leppanen@pinja.com>
7+
*/
8+
9+
namespace App\Tests\Integration\Decorator;
10+
11+
/**
12+
* Helper final class for testing
13+
*/
14+
final class FinalTestService
15+
{
16+
public function testMethod(): string
17+
{
18+
return 'final-test';
19+
}
20+
}
21+
Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
<?php
2+
declare(strict_types = 1);
3+
/**
4+
* /tests/Integration/Decorator/ServiceWithInternalDefaults.php
5+
*
6+
* @author TLe, Tarmo Leppänen <tarmo.leppanen@pinja.com>
7+
*/
8+
9+
namespace App\Tests\Integration\Decorator;
10+
11+
use SplFileInfo;
12+
13+
/**
14+
* Helper class for testing internal class default values
15+
* Extends an internal class to potentially trigger reflection edge cases
16+
*/
17+
class ServiceWithInternalDefaults extends SplFileInfo
18+
{
19+
public function __construct()
20+
{
21+
parent::__construct(__FILE__);
22+
}
23+
24+
/**
25+
* Method with parameter that has complex default values
26+
* This is for testing the catch block in getDefaultValueString when the decorator
27+
* tries to get the default value via reflection for certain edge cases
28+
*
29+
* @param array<string, mixed> $options
30+
*/
31+
public function methodWithInternalDefault(array $options = []): string
32+
{
33+
return 'test';
34+
}
35+
}

tests/Integration/Decorator/StopwatchDecoratorTest.php

Lines changed: 0 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -203,39 +203,3 @@ public static function dataProviderTestThatDecorateMethodReturnsExpected(): Gene
203203
yield [stdClass::class, new stdClass()];
204204
}
205205
}
206-
207-
/**
208-
* Helper final class for testing
209-
*/
210-
final class FinalTestService
211-
{
212-
public function testMethod(): string
213-
{
214-
return 'final-test';
215-
}
216-
}
217-
218-
/**
219-
* Helper class for testing internal class default values
220-
* Extends an internal class to potentially trigger reflection edge cases
221-
*/
222-
class ServiceWithInternalDefaults extends \SplFileInfo
223-
{
224-
public function __construct()
225-
{
226-
parent::__construct(__FILE__);
227-
}
228-
229-
/**
230-
* Method with parameter that has complex default values
231-
* This is for testing the catch block in getDefaultValueString when the decorator
232-
* tries to get the default value via reflection for certain edge cases
233-
*
234-
* @param array<string, mixed> $options
235-
*/
236-
public function methodWithInternalDefault(array $options = []): string
237-
{
238-
return 'test';
239-
}
240-
}
241-

0 commit comments

Comments
 (0)