Skip to content

Commit 913e795

Browse files
authored
Merge pull request #7840 from ProcessMaker/feature/FOUR-21301
FOUR-21301 Fix the tests MetricsServiceTest.php and MetricsFacadeTest…
2 parents 1c1fd9c + 05c31b9 commit 913e795

2 files changed

Lines changed: 9 additions & 5 deletions

File tree

‎tests/Feature/MetricsFacadeTest.php‎

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -31,10 +31,10 @@ protected function setUp(): void
3131
public function test_facade_can_register_and_increment_counter()
3232
{
3333
// Register a counter using the Facade
34-
Metrics::registerCounter('facade_counter', 'Test counter via facade');
34+
$counter = Metrics::counter('facade_counter', 'Test counter via facade');
3535

3636
// Increment the counter
37-
Metrics::incrementCounter('facade_counter');
37+
$counter->inc();
3838

3939
// Verify that the metric was registered and incremented
4040
$this->assertTrue(true); // In this point we assume that there are no errors
@@ -46,8 +46,8 @@ public function test_facade_can_register_and_increment_counter()
4646
public function test_facade_can_render_metrics()
4747
{
4848
// Register and increment a counter
49-
Metrics::registerCounter('facade_render_test', 'Render test via facade');
50-
Metrics::incrementCounter('facade_render_test');
49+
$counter = Metrics::counter('facade_render_test', 'Render test via facade');
50+
$counter->inc();
5151

5252
// Render the metrics
5353
$output = Metrics::renderMetrics();

‎tests/unit/MetricsServiceTest.php‎

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,10 @@
22

33
namespace Tests\Unit;
44

5-
use PHPUnit\Framework\TestCase;
65
use ProcessMaker\Services\MetricsService;
76
use Prometheus\Storage\InMemory;
7+
use Illuminate\Support\Facades\App;
8+
use Tests\TestCase;
89

910
class MetricsServiceTest extends TestCase
1011
{
@@ -19,9 +20,12 @@ class MetricsServiceTest extends TestCase
1920
*/
2021
protected function setUp(): void
2122
{
23+
parent::setUp();
24+
2225
// Use InMemory storage for testing
2326
$adapter = new InMemory();
2427
$this->metricsService = new MetricsService($adapter);
28+
App::instance(MetricsService::class, $this->metricsService); // Replace the service in the container
2529
}
2630

2731
/**

0 commit comments

Comments
 (0)