File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff 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 ();
Original file line number Diff line number Diff line change 22
33namespace Tests \Unit ;
44
5- use PHPUnit \Framework \TestCase ;
65use ProcessMaker \Services \MetricsService ;
76use Prometheus \Storage \InMemory ;
7+ use Illuminate \Support \Facades \App ;
8+ use Tests \TestCase ;
89
910class 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 /**
You can’t perform that action at this time.
0 commit comments